adachsoft/ai-agent-stats 问题修复 & 功能扩展

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

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

adachsoft/ai-agent-stats

最新稳定版本:v0.2.0

Composer 安装命令:

composer require adachsoft/ai-agent-stats

包简介

Library for calculating statistics from adachsoft/ai-agent conversation history.

README 文档

README

Library for calculating statistics from adachsoft/ai-agent conversation history.

Requirements

  • PHP ^8.2
  • adachsoft/ai-agent

Installation

composer require adachsoft/ai-agent-stats

Usage

The main entry point is AdachSoft\AiAgentStats\AgentStatsCalculator. It takes a ChatMessageDtoCollection (from adachsoft/ai-agent) and returns an AgentStatsDto with detailed metrics.

use AdachSoft\AiAgentStats\AgentStatsCalculator;
use AdachSoft\AiAgent\PublicApi\Dto\Collection\ChatMessageDtoCollection;

// Assume $messages is your ChatMessageDtoCollection from the agent
/** @var ChatMessageDtoCollection $messages */

$calculator = new AgentStatsCalculator();
$stats = $calculator->calculate($messages);

// Accessing statistics:

// 1. Message counts per role
echo "User messages: " . $stats->messageCountByRole['user'] . PHP_EOL;
echo "Assistant messages: " . $stats->messageCountByRole['assistant'] . PHP_EOL;

// 2. Total size of all messages (content length)
echo "Total size: " . $stats->totalMessagesSize . " bytes" . PHP_EOL;

// 3. Tool usage statistics
foreach ($stats->toolStats as $toolName => $toolStat) {
    echo "Tool: $toolName" . PHP_EOL;
    echo "  - Usage count: " . $toolStat->usageCount . PHP_EOL;
    echo "  - Input size: " . $toolStat->inputSize . " bytes" . PHP_EOL;
    echo "  - Output size: " . $toolStat->outputSize . " bytes" . PHP_EOL;
}

// 4. Advanced metrics
echo "Size of messages with tool calls: " . $stats->messagesWithToolCallsSize . PHP_EOL;
echo "Size of tool output messages: " . $stats->toolRoleMessagesSize . PHP_EOL;

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固