llmcosts/llm-cost-logger 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

llmcosts/llm-cost-logger

最新稳定版本:1.0.5

Composer 安装命令:

composer require llmcosts/llm-cost-logger

包简介

Reference code to log LLM Call metadata to the llmcosts.fyi service

README 文档

README

This repo contains the source code for the PHP class you might need to log into llmcosts.fyi

We wouldn't normally expect you to need to install from source, and this code is typically very simple

You need an API key from llmcosts.fyi. Reference code, prepopulated with your API key is available to users of that site, but the quick version is here.

For use with other clients, you will also need to replace the name "OpenAI" in the ->logCall function with a provider supported by the service.

Installation

The best way is to install via Composer, by adding to the "require" section of your composer.json file

{... other requirements ...}
"llmcosts/llm-cost-logger": "1.0.0"

Using with the OpenAI client:

/**
 * Your existing code
 */
$client = \OpenAI::Client("<your OpenAI token>");
$result = $client->chat()->create([
    'model' => self::MODEL,
    'messages' => [
        ['role' => 'user', 'content' => '<your query string>'],
    ],
]);
$resultArray = $result->toArray();

/**
 * The two lines you need to add logging
 * The <provider> can be anything, but see above
 */
+ $costLogger = new LLMCostLogger("{{key}}");
+ $costLogger->logCall("OpenAI", $resultArray);

统计信息

  • 总下载量: 259
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-2.1-only
  • 更新时间: 2025-02-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固