Skip to content

Commit 7aca7db

Browse files
authored
Update model information to support the new OpenAI models (#368)
1 parent 221dcde commit 7aca7db

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

shell/agents/AIShell.OpenAI.Agent/ModelInfo.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ static ModelInfo()
2525
// https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
2626
s_modelMap = new(StringComparer.OrdinalIgnoreCase)
2727
{
28-
["o1"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding),
28+
["o1"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding, reasoning: true),
29+
["o3"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding, reasoning: true),
30+
["o4-mini"] = new(tokenLimit: 200_000, encoding: Gpt4oEncoding, reasoning: true),
31+
["gpt-4.1"] = new(tokenLimit: 1_047_576, encoding: Gpt4oEncoding),
2932
["gpt-4o"] = new(tokenLimit: 128_000, encoding: Gpt4oEncoding),
3033
["gpt-4"] = new(tokenLimit: 8_192),
3134
["gpt-4-32k"] = new(tokenLimit: 32_768),
@@ -45,7 +48,7 @@ static ModelInfo()
4548
};
4649
}
4750

48-
private ModelInfo(int tokenLimit, string encoding = null)
51+
private ModelInfo(int tokenLimit, string encoding = null, bool reasoning = false)
4952
{
5053
TokenLimit = tokenLimit;
5154
_encodingName = encoding ?? Gpt34Encoding;
@@ -54,6 +57,7 @@ private ModelInfo(int tokenLimit, string encoding = null)
5457
// See https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
5558
TokensPerMessage = 3;
5659
TokensPerName = 1;
60+
Reasoning = reasoning;
5761
}
5862

5963
private readonly string _encodingName;
@@ -62,6 +66,7 @@ private ModelInfo(int tokenLimit, string encoding = null)
6266
internal int TokenLimit { get; }
6367
internal int TokensPerMessage { get; }
6468
internal int TokensPerName { get; }
69+
internal bool Reasoning { get; }
6570
internal Tokenizer Encoding
6671
{
6772
get {

shell/agents/AIShell.OpenAI.Agent/Service.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ internal ChatService(string historyRoot, Settings settings)
3535

3636
_chatOptions = new ChatCompletionOptions()
3737
{
38-
Temperature = 0,
3938
MaxOutputTokenCount = MaxResponseToken,
4039
};
4140
}
@@ -126,6 +125,8 @@ private void RefreshOpenAIClient()
126125
}
127126

128127
EndpointType type = _gptToUse.Type;
128+
// Reasoning models do not support the temperature setting.
129+
_chatOptions.Temperature = _gptToUse.ModelInfo.Reasoning ? null : 0;
129130

130131
if (type is EndpointType.AzureOpenAI)
131132
{

0 commit comments

Comments
 (0)