diff --git a/shell/agents/AIShell.OpenAI.Agent/ModelInfo.cs b/shell/agents/AIShell.OpenAI.Agent/ModelInfo.cs index 79674e85..2ce1dd9f 100644 --- a/shell/agents/AIShell.OpenAI.Agent/ModelInfo.cs +++ b/shell/agents/AIShell.OpenAI.Agent/ModelInfo.cs @@ -25,7 +25,10 @@ static ModelInfo() // https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb s_modelMap = new(StringComparer.OrdinalIgnoreCase) { - ["o1"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding), + ["o1"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding, reasoning: true), + ["o3"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding, reasoning: true), + ["o4-mini"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding, reasoning: true), + ["gpt-4.1"] = new(tokenLimit: 1_047_576, encoding: Gpt4oEncoding), ["gpt-4o"] = new(tokenLimit: 128_000, encoding: Gpt4oEncoding), ["gpt-4"] = new(tokenLimit: 8_192), ["gpt-4-32k"] = new(tokenLimit: 32_768), @@ -45,7 +48,7 @@ static ModelInfo() }; } - private ModelInfo(int tokenLimit, string encoding = null) + private ModelInfo(int tokenLimit, string encoding = null, bool reasoning = false) { TokenLimit = tokenLimit; _encodingName = encoding ?? Gpt34Encoding; @@ -54,6 +57,7 @@ private ModelInfo(int tokenLimit, string encoding = null) // See https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb TokensPerMessage = 3; TokensPerName = 1; + Reasoning = reasoning; } private readonly string _encodingName; @@ -62,6 +66,7 @@ private ModelInfo(int tokenLimit, string encoding = null) internal int TokenLimit { get; } internal int TokensPerMessage { get; } internal int TokensPerName { get; } + internal bool Reasoning { get; } internal Tokenizer Encoding { get { diff --git a/shell/agents/AIShell.OpenAI.Agent/Service.cs b/shell/agents/AIShell.OpenAI.Agent/Service.cs index ef387c1c..4f062ac9 100644 --- a/shell/agents/AIShell.OpenAI.Agent/Service.cs +++ b/shell/agents/AIShell.OpenAI.Agent/Service.cs @@ -35,7 +35,6 @@ internal ChatService(string historyRoot, Settings settings) _chatOptions = new ChatCompletionOptions() { - Temperature = 0, MaxOutputTokenCount = MaxResponseToken, }; } @@ -126,6 +125,8 @@ private void RefreshOpenAIClient() } EndpointType type = _gptToUse.Type; + // Reasoning models do not support the temperature setting. + _chatOptions.Temperature = _gptToUse.ModelInfo.Reasoning ? null : 0; if (type is EndpointType.AzureOpenAI) {