Update app/api/chat/route.ts
Browse files- app/api/chat/route.ts +3 -9
app/api/chat/route.ts
CHANGED
|
@@ -19,21 +19,15 @@ const functions: any[] = [
|
|
| 19 |
|
| 20 |
export async function POST(req: Request) {
|
| 21 |
const openai = new OpenAI({
|
| 22 |
-
apiKey: process.env.OPENAI_API_KEY
|
| 23 |
-
baseURL: "https://api.mistral.ai/v1"
|
| 24 |
});
|
| 25 |
|
| 26 |
const { messages, function_call } = await req.json()
|
| 27 |
|
| 28 |
const response = await openai.chat.completions.create({
|
| 29 |
-
model: '
|
| 30 |
stream: true,
|
| 31 |
-
messages
|
| 32 |
-
.map(message => ({
|
| 33 |
-
// map "assistant" to "agent" for Mistral:
|
| 34 |
-
role: message.role === 'assistant' ? 'agent' : 'user',
|
| 35 |
-
content: message.content,
|
| 36 |
-
}) as any),
|
| 37 |
functions,
|
| 38 |
function_call
|
| 39 |
})
|
|
|
|
| 19 |
|
| 20 |
export async function POST(req: Request) {
|
| 21 |
const openai = new OpenAI({
|
| 22 |
+
apiKey: process.env.OPENAI_API_KEY
|
|
|
|
| 23 |
});
|
| 24 |
|
| 25 |
const { messages, function_call } = await req.json()
|
| 26 |
|
| 27 |
const response = await openai.chat.completions.create({
|
| 28 |
+
model: 'gpt-3.5-turbo',
|
| 29 |
stream: true,
|
| 30 |
+
messages,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
functions,
|
| 32 |
function_call
|
| 33 |
})
|