Skip to content

Commit dffec98

Browse files
authored
refactor: support o3 mini regex pattern for series models (#219)
- Replace `checkO1Serial` with `checkOSeriesModels` for better matching of model strings - Adjust regex pattern to `o\d((-mini|-preview))?` Signed-off-by: appleboy <[email protected]>
1 parent 5f210d4 commit dffec98

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

provider/openai/openai.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (c *Client) Completion(ctx context.Context, content string) (*core.Response
6464
func (c *Client) GetSummaryPrefix(ctx context.Context, content string) (*core.Response, error) {
6565
var resp openai.ChatCompletionResponse
6666
var err error
67-
if checkO1Serial.MatchString(c.model) {
67+
if checkOSeriesModels.MatchString(c.model) {
6868
resp, err = c.CreateChatCompletion(ctx, content)
6969
if err != nil || len(resp.Choices) != 1 {
7070
return nil, err
@@ -97,7 +97,7 @@ func (c *Client) GetSummaryPrefix(ctx context.Context, content string) (*core.Re
9797
}, nil
9898
}
9999

100-
var checkO1Serial = regexp.MustCompile(`o1-(mini|preview)`)
100+
var checkOSeriesModels = regexp.MustCompile(`o\d(-(mini|preview))?`)
101101

102102
// CreateChatCompletion is an API call to create a function call for a chat message.
103103
func (c *Client) CreateFunctionCall(
@@ -136,7 +136,7 @@ func (c *Client) CreateFunctionCall(
136136
},
137137
}
138138

139-
if checkO1Serial.MatchString(c.model) {
139+
if checkOSeriesModels.MatchString(c.model) {
140140
req.MaxTokens = 0
141141
req.MaxCompletionTokens = c.maxTokens
142142
}
@@ -168,7 +168,7 @@ func (c *Client) CreateChatCompletion(
168168
},
169169
}
170170

171-
if checkO1Serial.MatchString(c.model) {
171+
if checkOSeriesModels.MatchString(c.model) {
172172
req.MaxTokens = 0
173173
req.MaxCompletionTokens = c.maxTokens
174174
}

0 commit comments

Comments
 (0)