Files

29 lines
830 B
C#
Raw Permalink Normal View History

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;
};
}
}