把图 JSON 编译成 CreateHandoffBuilderWith + WithHandoff;Agent 固定 Id 以免交接工具名错位;DeepSeek 关闭 thinking,避免多轮丢掉 reasoning_content 导致 400。
29 lines
830 B
C#
29 lines
830 B
C#
using System.ClientModel.Primitives;
|
||
using System.Text.Json;
|
||
using Microsoft.Extensions.AI;
|
||
using OpenAI.Chat;
|
||
|
||
namespace MAF1.Utils;
|
||
|
||
/// <summary>
|
||
/// DeepSeek V4 默认开 thinking。Handoff 多轮带 tools 时必须回传 reasoning_content,
|
||
/// 客户端会丢掉该字段导致 HTTP 400。请求里关闭 thinking 即可。
|
||
/// </summary>
|
||
internal static class DeepSeekThinking
|
||
{
|
||
public static void Disable(ChatOptions options)
|
||
{
|
||
options.RawRepresentationFactory = _ =>
|
||
{
|
||
ChatCompletionOptions raw = new();
|
||
#pragma warning disable SCME0001
|
||
raw.Patch.Set("$.thinking"u8, BinaryData.FromObjectAsJson(new Dictionary<string, string>
|
||
{
|
||
["type"] = "disabled",
|
||
}));
|
||
#pragma warning restore SCME0001
|
||
return raw;
|
||
};
|
||
}
|
||
}
|