Compare commits

...

3 Commits

Author SHA1 Message Date
koalazf.99
172c05be26 Merge branch 'main' into fix/trimend 2025-08-14 19:17:27 +08:00
koalazf.99
04415bd19d tmp 2025-08-14 19:16:40 +08:00
koalazf.99
f9d3fe6fad fix: generate random tool call id when serving API does not have one 2025-08-14 19:09:02 +08:00

View File

@@ -564,7 +564,7 @@ export class OpenAIContentGenerator implements ContentGenerator {
// Add combined text if any
if (combinedText) {
combinedParts.push({ text: combinedText });
combinedParts.push({ text: combinedText.trimEnd() });
}
// Add function calls
@@ -1138,7 +1138,11 @@ export class OpenAIContentGenerator implements ContentGenerator {
// Handle text content
if (choice.message.content) {
parts.push({ text: choice.message.content });
if (typeof choice.message.content === 'string') {
parts.push({ text: choice.message.content.trimEnd() });
} else {
parts.push({ text: choice.message.content });
}
}
// Handle tool calls
@@ -1228,7 +1232,11 @@ export class OpenAIContentGenerator implements ContentGenerator {
// Handle text content
if (choice.delta?.content) {
parts.push({ text: choice.delta.content });
if (typeof choice.delta.content === 'string') {
parts.push({ text: choice.delta.content.trimEnd() });
} else {
parts.push({ text: choice.delta.content });
}
}
// Handle tool calls - only accumulate during streaming, emit when complete
@@ -1276,7 +1284,9 @@ export class OpenAIContentGenerator implements ContentGenerator {
parts.push({
functionCall: {
id: accumulatedCall.id,
id:
accumulatedCall.id ||
`call_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`,
name: accumulatedCall.name,
args,
},
@@ -1752,7 +1762,7 @@ export class OpenAIContentGenerator implements ContentGenerator {
}
}
messageContent = textParts.join('');
messageContent = textParts.join('').trimEnd();
}
const choice: OpenAIChoice = {