Dedalus Runner
在非流式传输模式下执行 tool 时由
DedalusRunner 返回的响应对象。显示 属性
显示 属性
在所有 tool 执行完成后,由对话生成的最终文本输出
在此次运行中使用的总步骤数(LLM 调用次数)
此次运行期间被调用的 tool 名称列表
完整的对话历史,包括 system prompt、用户消息、assistant 响应以及 tool 调用/结果。可用于调试、日志记录或继续对话。
可选的检测到的意图列表(当
return_intent=true 时)final_output 的别名(向后兼容)final_output 的别名(向后兼容)显示 方法
显示 方法
返回完整对话历史(
messages)的副本,以便用于后续运行。通过将结果传递给后续的 runner.run() 调用,实现多轮对话。Example
报告错误代码
复制
询问AI
from dedalus_labs import Dedalus, DedalusRunner
client = Dedalus(api_key="YOUR_API_KEY")
runner = DedalusRunner(client)
def get_weather(location: str) -> str:
"""获取指定地点的当前天气。"""
return f"The weather in {location} is sunny and 72°F"
result = runner.run(
input="What's the weather like in San Francisco?",
tools=[get_weather],
model="openai/gpt-5-nano",
max_steps=5
)
# Access result properties
print(result.final_output) # "The weather in San Francisco is sunny and 72°F"
print(result.steps_used) # e.g., 2
print(result.tools_called) # ["get_weather"]
print(result.tool_results) # [{"name": "get_weather", "result": "The weather...", "step": 1}]
Accessing Message History
报告错误代码
复制
询问AI
import json
# 打印完整的对话历史记录
for msg in result.messages:
role = msg.get("role")
content = msg.get("content", "")
if role == "user":
print(f"User: {content}")
elif role == "assistant":
if msg.get("tool_calls"):
tools = [tc["function"]["name"] for tc in msg["tool_calls"]]
print(f"Assistant: [calling {', '.join(tools)}]")
else:
print(f"Assistant: {content}")
elif role == "tool":
print(f"Tool Result: {content[:100]}...")
# 将消息历史记录存储为 JSON 以便日志记录/调试
with open("conversation_log.json", "w") as f:
json.dump(result.messages, f, indent=2)
# 使用消息历史记录继续对话
follow_up = runner.run(
messages=result.to_input_list(), # 传递先前的对话
input="What about New York?", # 添加新用户消息
tools=[get_weather],
model="openai/gpt-5-nano"
)
Example Response
报告错误代码
复制
询问AI
{
"final_output": "The weather in San Francisco is sunny and 72°F",
"tool_results": [
{
"name": "get_weather",
"result": "The weather in San Francisco is sunny and 72°F",
"step": 1
}
],
"steps_used": 2,
"tools_called": ["get_weather"],
"messages": [
{ "role": "user", "content": "旧金山的天气怎么样?" },
{
"role": "assistant",
"tool_calls": [
{
"id": "call_abc123",
"type": "function",
"function": {
"name": "get_weather",
"arguments": "{\"location\": \"San Francisco\"}"
}
}
]
},
{
"role": "tool",
"tool_call_id": "call_abc123",
"content": "The weather in San Francisco is sunny and 72°F"
},
{
"role": "assistant",
"content": "The weather in San Francisco is sunny and 72°F"
}
],
"intents": null
}
聊天补全
非流式聊天补全的完整响应对象。
显示 属性
显示 属性
此聊天补全的唯一标识符
对象类型,始终为
chat.completion补全创建时的 Unix 时间戳(秒)
用于补全的模型(例如
openai/gpt-5-nano)用于结果可复现性的系统指纹
Example
报告错误代码
复制
询问AI
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1677652288,
"model": "openai/gpt-5-nano",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm doing well, thank you for asking."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 13,
"completion_tokens": 12,
"total_tokens": 25
}
}
用于流式传输补全结果(
stream=true)的分片响应。显示 Properties
显示 Properties
聊天补全结果的唯一标识符
对象类型,始终为
chat.completion.chunk创建该分片时的 Unix 时间戳
使用的模型
Example
报告错误代码
复制
询问AI
{
"id": "chatcmpl-abc123",
"object": "chat.completion.chunk",
"created": 1677652288,
"model": "openai/gpt-5-nano",
"choices": [
{
"index": 0,
"delta": {
"content": "Hello"
},
"finish_reason": null
}
]
}
向量嵌入
Example
报告错误代码
复制
询问AI
{
"object": "list",
"data": [
{
"object": "embedding",
"embedding": [0.0023064255, -0.009327292, -0.0028842222],
"index": 0
}
],
"model": "openai/text-embedding-3-small",
"usage": {
"prompt_tokens": 8,
"total_tokens": 8
}
}
模型
用于列出可用模型的响应对象。包含关于能力和路由的丰富元数据。
显示 属性
显示 属性
对象类型,始终为
list模型对象列表
显示 模型属性
显示 模型属性
带有提供商前缀的模型标识符(例如,
openai/gpt-4o、anthropic/claude-opus-4-5)提供商名称:
openai、anthropic、google、xai、deepseek、mistral 等。模型创建时的 ISO 8601 时间戳
人类可读的显示名称(可选)
模型描述(可选)
模型能力
显示 能力
显示 能力
通过聊天补全接口支持文本生成
支持图像输入/多模态
支持图像生成
支持音频输入/输出
支持 tool/函数调用
支持结构化 JSON 输出
支持流式传输响应
支持扩展推理(例如 o1、o3、Claude thinking)
最大输入上下文窗口(以 token 为单位)
最大输出 token 数
Example
报告错误代码
复制
询问AI
{
"object": "list",
"data": [
{
"id": "openai/gpt-4o",
"provider": "openai",
"created_at": "1970-01-01T00:00:00Z",
"display_name": null,
"description": null,
"capabilities": {
"text": true,
"vision": null,
"image_generation": null,
"audio": null,
"tools": null,
"structured_output": null,
"streaming": null,
"thinking": null,
"input_token_limit": null,
"output_token_limit": null
},
"provider_info": {
"status": "enabled",
"upstream_api": "openai/chat/completions"
}
},
{
"id": "openai/o1",
"provider": "openai",
"created_at": "1970-01-01T00:00:00Z",
"capabilities": {
"text": true,
"thinking": true
},
"provider_info": {
"status": "enabled",
"upstream_api": "openai/chat/completions"
}
},
{
"id": "anthropic/claude-opus-4-5",
"provider": "anthropic",
"created_at": "1970-01-01T00:00:00Z",
"capabilities": {
"text": true,
"vision": true,
"tools": true
},
"provider_info": {
"status": "enabled",
"upstream_api": "anthropic/messages"
}
}
]
}
图像
Example
报告错误代码
复制
询问AI
{
"created": 1677652288,
"data": [
{
"url": "https://images.example.com/abc123.png",
"revised_prompt": "A cute baby sea otter floating on its back in calm blue water"
}
]
}
音频
Example
报告错误代码
复制
询问AI
{
"text": "Hello, this is a test of audio transcription."
}
Example
报告错误代码
复制
询问AI
{
"text": "Hello, this is a test of audio translation."
}
错误
Example
报告错误代码
复制
询问AI
{
"error": {
"message": "提供的 API 密钥无效",
"type": "authentication_error",
"code": "invalid_api_key"
}
}