From c0a74f2e1939b721f933610e8f7bea0eb741fe0a Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 28 Oct 2024 15:08:14 +0330 Subject: [PATCH] proxy deployment --- app/api/chat/route.ts | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index 70dfbda7f..dd49e756c 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -18,23 +18,27 @@ export async function POST(req: Request) { } try { - const response = await fetch('http://localhost:3131/proxy-openai', { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - assistant_id: assistantId, - temperature: 0, - thread: { - messages: messages + const response = await fetch( + 'https://gateway.openairan.info/proxy-openai', + { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + Authorization: `Bearer ${process.env.OPENAI_API_KEY}` }, - stream: true, - tool_resources: { - file_search: { vector_store_ids: ['vs_gPCtwiyn0sYXrdGHIpXrHVh9'] } - } - }) - }) + body: JSON.stringify({ + assistant_id: assistantId, + temperature: 0, + thread: { + messages: messages + }, + stream: true, + tool_resources: { + file_search: { vector_store_ids: ['vs_gPCtwiyn0sYXrdGHIpXrHVh9'] } + } + }) + } + ) if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`) @@ -63,7 +67,7 @@ export async function POST(req: Request) { try { eventData.data = JSON.parse(line.slice(6)) } catch (e) { - console.error('Failed to parse JSON:', e) + // console.error('Failed to parse JSON:', e) continue } } @@ -135,4 +139,3 @@ export async function POST(req: Request) { ) } } -‍ \ No newline at end of file