Skip to content

Commit 284842b

Browse files
Use gpt-5 in KattGpt
1 parent b20c09b commit 284842b

2 files changed

Lines changed: 25 additions & 14 deletions

File tree

src/Kattbot.Common/Models/KattGpt/ChatCompletionCreateRequest.cs

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,22 @@ public record ChatCompletionCreateRequest
103103
public bool? Stream { get; set; }
104104

105105
/// <summary>
106-
/// Gets or sets the maximum number of tokens to generate in the chat completion.
107-
/// The total length of input tokens and generated tokens is limited by the model's context length.
106+
/// An upper bound for the number of tokens that can be generated for a completion,
107+
/// including visible output tokens and reasoning tokens.
108108
/// Defaults to inf.
109-
/// https://platform.openai.com/docs/api-reference/chat/create#chat/create-max_tokens.
109+
/// https://platform.openai.com/docs/api-reference/chat/create#chat_create-max_completion_tokens
110110
/// </summary>
111-
[JsonPropertyName("max_tokens")]
112-
public int? MaxTokens { get; set; }
111+
[JsonPropertyName("max_completion_tokens")]
112+
public int? MaxCompletionTokens { get; set; }
113+
114+
/// <summary>
115+
/// Constrains effort on reasoning for reasoning models.
116+
/// Currently supported values are minimal, low, medium, and high
117+
/// Defaults to medium.
118+
/// https://platform.openai.com/docs/api-reference/chat/create#chat_create-reasoning_effort
119+
/// </summary>
120+
[JsonPropertyName("reasoning_effort")]
121+
public string? ReasoningEffort { get; set; }
113122

114123
/// <summary>
115124
/// Gets or sets number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the
@@ -130,9 +139,10 @@ public record ChatCompletionCreateRequest
130139
public float? FrequencyPenalty { get; set; }
131140

132141
/// <summary>
133-
/// Gets or sets a unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.
134-
/// https://platform.openai.com/docs/api-reference/chat/create#chat/create-user.
142+
/// A stable identifier used to help detect users of your application that may be violating OpenAI's
143+
/// usage policies. The IDs should be a string that uniquely identifies each user.
144+
/// https://platform.openai.com/docs/api-reference/chat/create#chat_create-safety_identifier
135145
/// </summary>
136-
[JsonPropertyName("user")]
137-
public string? User { get; set; }
146+
[JsonPropertyName("safety_identifier")]
147+
public string? SafetyIdentifier { get; set; }
138148
}

src/Kattbot/NotificationHandlers/KattGptMessageHandler.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ namespace Kattbot.NotificationHandlers;
2323
public class KattGptMessageHandler : BaseNotificationHandler,
2424
INotificationHandler<MessageCreatedNotification>
2525
{
26-
private const string ChatGptModel = "gpt-4o";
27-
private const string TokenizerModel = "gpt-4o";
26+
private const string ChatGptModel = "gpt-5";
27+
private const string TokenizerModel = "gpt-4o"; // TODO update to gpt5 when available
28+
private const string DefaultReasoningEffort = "minimal";
2829

2930
private const float DefaultTemperature = 1.1f;
3031
private const int MaxTotalTokens = 24_576;
@@ -172,8 +173,8 @@ private static ChatCompletionCreateRequest BuildRequest(
172173
{
173174
Model = ChatGptModel,
174175
Messages = requestMessages.ToArray(),
175-
Temperature = DefaultTemperature,
176-
MaxTokens = MaxTokensToGenerate,
176+
MaxCompletionTokens = MaxTokensToGenerate,
177+
ReasoningEffort = DefaultReasoningEffort,
177178
Tools = chatCompletionTools,
178179
ParallelToolCalls = parallelToolCalls,
179180
};
@@ -343,7 +344,7 @@ private KattGptChannelContext GetOrCreateCachedContext(
343344

344345
int remainingTokensForContextMessages = MaxTotalTokens - MaxTokensToGenerate - reservedTokenCount;
345346

346-
var tokenizer = new KattGptTokenizer(ChatGptModel);
347+
var tokenizer = new KattGptTokenizer(TokenizerModel);
347348

348349
channelContext = new KattGptChannelContext(remainingTokensForContextMessages, tokenizer);
349350

0 commit comments

Comments
 (0)