feat: 新增方案 C 的 Handoff 路由宿主,并让抽城市支持自然语言。
把图 JSON 编译成 CreateHandoffBuilderWith + WithHandoff;Agent 固定 Id 以免交接工具名错位;DeepSeek 关闭 thinking,避免多轮丢掉 reasoning_content 导致 400。
This commit is contained in:
@@ -11,16 +11,30 @@ namespace MAF1.Agents.Weather;
|
||||
/// </summary>
|
||||
public static class WeatherAgent
|
||||
{
|
||||
public const string DefaultDescription = "按城市列表查询天气并汇总。";
|
||||
|
||||
/// <summary>创建带 GetWeather 工具的 Agent。instructions 要求每个城市都调工具,禁止编造气温。</summary>
|
||||
public static AIAgent Create(AgentFactory factory, WeatherTools weatherTools)
|
||||
public static AIAgent Create(
|
||||
AgentFactory factory,
|
||||
WeatherTools weatherTools,
|
||||
string name = "WeatherAgent",
|
||||
string? description = null,
|
||||
string? extraInstructions = null)
|
||||
{
|
||||
return factory.CreateAgent(
|
||||
name: "WeatherAgent",
|
||||
instructions:
|
||||
string instructions =
|
||||
"""
|
||||
你负责查询天气。用户给出的每个城市都必须调用一次 GetWeather,不要编造天气。
|
||||
用中文汇总所有城市的天气。
|
||||
""",
|
||||
""";
|
||||
if (!string.IsNullOrWhiteSpace(extraInstructions))
|
||||
{
|
||||
instructions = instructions + "\n" + extraInstructions;
|
||||
}
|
||||
|
||||
return factory.CreateAgent(
|
||||
name: name,
|
||||
instructions: instructions,
|
||||
description: string.IsNullOrWhiteSpace(description) ? DefaultDescription : description,
|
||||
tools: [AIFunctionFactory.Create(weatherTools.GetWeather)]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user