feat(OpenAIProvider): Enhance model reasoning detection and stream output handling
- Update isOpenAIReasoning method to include 'o3' model prefix - Rename isOpenAIo1 method to isOpenAIReasoning for clarity
This commit is contained in:
parent
2c21553059
commit
4634c88f76
@ -166,7 +166,7 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.isOpenAIo1(model)) {
|
if (this.isOpenAIReasoning(model)) {
|
||||||
return {
|
return {
|
||||||
max_tokens: undefined,
|
max_tokens: undefined,
|
||||||
max_completion_tokens: maxTokens
|
max_completion_tokens: maxTokens
|
||||||
@ -232,8 +232,8 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
|
||||||
private isOpenAIo1(model: Model) {
|
private isOpenAIReasoning(model: Model) {
|
||||||
return model.id.startsWith('o1')
|
return model.id.startsWith('o1') || model.id.startsWith('o3')
|
||||||
}
|
}
|
||||||
|
|
||||||
async completions({ messages, assistant, onChunk, onFilterMessages, mcpTools }: CompletionsParams): Promise<void> {
|
async completions({ messages, assistant, onChunk, onFilterMessages, mcpTools }: CompletionsParams): Promise<void> {
|
||||||
@ -262,10 +262,10 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
userMessages.push(await this.getMessageParam(message, model))
|
userMessages.push(await this.getMessageParam(message, model))
|
||||||
}
|
}
|
||||||
|
|
||||||
const isOpenAIo1 = this.isOpenAIo1(model)
|
const isOpenAIReasoning = this.isOpenAIReasoning(model)
|
||||||
|
|
||||||
const isSupportStreamOutput = () => {
|
const isSupportStreamOutput = () => {
|
||||||
if (isOpenAIo1) {
|
if (isOpenAIReasoning) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return streamOutput
|
return streamOutput
|
||||||
@ -482,13 +482,13 @@ export default class OpenAIProvider extends BaseProvider {
|
|||||||
]
|
]
|
||||||
: [{ role: 'user', content: assistant.prompt }]
|
: [{ role: 'user', content: assistant.prompt }]
|
||||||
|
|
||||||
const isOpenAIo1 = this.isOpenAIo1(model)
|
const isOpenAIReasoning = this.isOpenAIReasoning(model)
|
||||||
|
|
||||||
const isSupportedStreamOutput = () => {
|
const isSupportedStreamOutput = () => {
|
||||||
if (!onResponse) {
|
if (!onResponse) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (isOpenAIo1) {
|
if (isOpenAIReasoning) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user