mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-10 23:59:45 +08:00
fix(OpenAIProvider): ensure tool_calls are only yielded when present (#6861)
This update modifies the OpenAIProvider to yield tool_calls only if they exist and have a length greater than zero, improving the handling of delta content. Additionally, a minor cleanup was performed by removing an unnecessary blank line in the code.
This commit is contained in:
parent
b44b397cdd
commit
dd15b391c5
@ -635,7 +635,7 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
|
|||||||
if (delta?.content) {
|
if (delta?.content) {
|
||||||
yield { type: 'text-delta', textDelta: delta.content }
|
yield { type: 'text-delta', textDelta: delta.content }
|
||||||
}
|
}
|
||||||
if (delta?.tool_calls) {
|
if (delta?.tool_calls && delta?.tool_calls.length > 0) {
|
||||||
yield { type: 'tool-calls', delta: delta }
|
yield { type: 'tool-calls', delta: delta }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -664,7 +664,6 @@ export default class OpenAIProvider extends BaseOpenAIProvider {
|
|||||||
for await (const chunk of readableStreamAsyncIterable(processedStream)) {
|
for await (const chunk of readableStreamAsyncIterable(processedStream)) {
|
||||||
const delta = chunk.type === 'finish' ? chunk.delta : chunk
|
const delta = chunk.type === 'finish' ? chunk.delta : chunk
|
||||||
const rawChunk = chunk.type === 'finish' ? chunk.chunk : chunk
|
const rawChunk = chunk.type === 'finish' ? chunk.chunk : chunk
|
||||||
|
|
||||||
switch (chunk.type) {
|
switch (chunk.type) {
|
||||||
case 'reasoning': {
|
case 'reasoning': {
|
||||||
if (time_first_token_millsec === 0) {
|
if (time_first_token_millsec === 0) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user