Appbuilder Trace跟踪功能基本用法
更新时间:2024-08-29
使用方法
启动Phoenix可视化软件
注意:没有可视化需求的可忽略此步骤
如果未安装phoenix,需要先安装phoenix软件(这里提供清华园下载方式)
python3 -m pip install arize-phoenix==4.5.0 -i https://pypi.tuna.tsinghua.edu.cn/simple
启动phoenix服务
appbuilder_trace_server
- 使用ctrl+c停止phoenix服务
启动Appbuilder-SDK TRACE
from appbuilder import AppBuilderTracer
tracer=AppBuilderTracer(
enable_phoenix = True,
enable_console = False,
)
- enable_phoenix:是否启动phoenix可视化跟踪
- enable_console:是否将trace信息反馈到控制台
# 启动trace
import os
import appbuilder
tracer.start_trace()
os.environ["APPBUILDER_TOKEN"] = "YOUR_APPBUILDER_TOKEN"
app_id = "YOUR_APP_ID"
builder = appbuilder.AppBuilderClient(app_id)
conversation_id = builder.create_conversation()
msg = builder.run(conversation_id=conversation_id, query="你可以做什么?",stream=True)
for m in msg.content:
print(m)
# 结束trace
tracer.end_trace()
- Phoenix可视化效果