Skip to content

Commit bf0985d

Browse files
bug: fixed openai model
1 parent 4f66e2b commit bf0985d

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

actions/ai/generate-completion.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,21 @@ export const generateCompletion = async ({
5252

5353
try {
5454
for await (const event of completion as any) {
55-
if (event.type === 'response.output_text.delta') {
56-
const data = {
57-
item_id: event.item_id,
58-
output_index: event.output_index,
59-
content_index: event.content_index,
60-
delta: event.delta,
61-
};
62-
63-
await writer.write(encoder.encode(`data: ${JSON.stringify(data)}\n\n`));
64-
} else if (event.choices[0].finish_reason !== 'stop') {
55+
if (providerName === AI_PROVIDER.openai && event.type === 'response.output_text.delta') {
56+
await writer.write(
57+
encoder.encode(
58+
`data: ${JSON.stringify({
59+
item_id: event.item_id,
60+
output_index: event.output_index,
61+
content_index: event.content_index,
62+
delta: event.delta,
63+
})}\n\n`,
64+
),
65+
);
66+
} else if (
67+
[AI_PROVIDER.deepseek, AI_PROVIDER.ollama].includes(providerName as AI_PROVIDER) &&
68+
event.choices[0].finish_reason !== 'stop'
69+
) {
6570
await writer.write(encoder.encode(event.choices[0].delta.content ?? ''));
6671
}
6772
}

0 commit comments

Comments
 (0)