SuperAPI AI 工具集

ai-tracing-requests

测试与质量

查看项目

更新于 10-15 23:58

技能介绍

用途:对单个 AI 请求做细粒度追踪与调试,看到每次 LM 调用、检索步骤、中间结果、token 数与延迟。与监控关注整体健康度、批量评估不同,追踪针对单请求、实时、全细节,用于回答“为什么某次请求答错了/很慢”。

主要能力:快速查看最近 LM 调用(含完整提示词与原始响应、DSPy 字段解析);手动为每个步骤计时;用 JSONL 持久化 trace;使用 DSPy 内置回调系统(BaseCallback,钩子包括 on_module_start/end、on_lm_start/end、on_adapter_format/parse_start/end、on_tool_start/end、on_evaluate_start/end)自动化追踪;手动逐步骤追踪多步管道;OpenTelemetry 埋点;接入 Langtrace、Arize Phoenix、Jaeger、MLflow 等查看器;从 trace 中找慢步骤、失败模式并构建训练数据。

使用方式:本地快速调试可用 dspy.inspect_history(n=5),DSPy 3.2+ 可加 file_path 保存;结构化追踪推荐注册回调 dspy.configure(callbacks=[TracingCallback()]);自动接入示例:Langtrace 用 pip install langtrace-python-sdk 后 langtrace.init(api_key="your-key");Phoenix 用 pip install arize-phoenix openinference-instrumentation-dspy 后 px.launch_app() 与 DSPyInstrumentor().instrument();MLflow 用 pip install -U mlflow>=2.18.0 并 mlflow.dspy.autolog();Jaeger 可用 docker run -d -p 16686:16686 -p 4317:4317 jaegertracing/all-in-one:latest。安装技能:npx skills add lebsral/DSPy-Programming-not-prompting-LMs-skills --skill <name>。

限制与注意事项:inspect_history 只打印到 stdout 且仅记录 LM 调用,不适合生产;回调钩子不应修改输入输出数据,否则会静默污染管道;应逐步骤追踪而非只包裹整体请求;需在问题发生前就开启日志或接入追踪器;聚合健康检查请用 /ai-monitoring,代码级错误用 /ai-fixing-errors。具体收费、平台细节及更多示例暂未提供。