@@ -50,6 +50,7 @@ export async function POST(request: Request) {
5050 const ollamaMessages: OllamaMessageInput[] = previousMessages.map((msg) => ({
5151 role: msg.role as "user" | "assistant" | "system",
5252 content: msg.content,
53+ toolCalls: msg.toolCalls || undefined,
5354 }));
5455
5556 // Add the new user message
@@ -80,7 +81,6 @@ export async function POST(request: Request) {
8081 };
8182
8283 try {
83-
8484 // Check if already aborted
8585 if (signal.aborted) {
8686 safeClose();
@@ -182,17 +182,17 @@ export async function POST(request: Request) {
182182 .update(threads)
183183 .set({ updatedAt: new Date() })
184184 .where(eq(threads.id, parseInt(threadId)));
185-
185+
186186 // Send done message with metadata for aborted generation
187187 if (!isControllerClosed) {
188188 try {
189189 controller.enqueue(
190190 encoder.encode(
191- `data: ${JSON.stringify({
192- type: "done",
191+ `data: ${JSON.stringify({
192+ type: "done",
193193 answer: accumulatedContent,
194194 model: threadModel,
195- maxPromptLength: threadMaxPromptLength
195+ maxPromptLength: threadMaxPromptLength,
196196 })}\n\n`
197197 )
198198 );
@@ -228,11 +228,11 @@ export async function POST(request: Request) {
228228 try {
229229 controller.enqueue(
230230 encoder.encode(
231- `data: ${JSON.stringify({
232- type: "done",
231+ `data: ${JSON.stringify({
232+ type: "done",
233233 answer: accumulatedContent,
234234 model: threadModel,
235- maxPromptLength: threadMaxPromptLength
235+ maxPromptLength: threadMaxPromptLength,
236236 })}\n\n`
237237 )
238238 );