Spaces:
Sleeping
Sleeping
Update app/api/chat/route.ts
Browse files- app/api/chat/route.ts +6 -1
app/api/chat/route.ts
CHANGED
@@ -28,7 +28,12 @@ export async function POST(req: Request) {
|
|
28 |
const response = await openai.chat.completions.create({
|
29 |
model: 'mistral-large-latest',
|
30 |
stream: true,
|
31 |
-
messages
|
|
|
|
|
|
|
|
|
|
|
32 |
functions,
|
33 |
function_call
|
34 |
})
|
|
|
28 |
const response = await openai.chat.completions.create({
|
29 |
model: 'mistral-large-latest',
|
30 |
stream: true,
|
31 |
+
messages: messages
|
32 |
+
.map(message => ({
|
33 |
+
// map "assistant" to "agent" for Mistral:
|
34 |
+
role: message.role === 'assistant' ? 'agent' : 'user',
|
35 |
+
content: message.content,
|
36 |
+
})),
|
37 |
functions,
|
38 |
function_call
|
39 |
})
|