From 19e93033c83ce9392a03dd3875593a56a49f9a3b Mon Sep 17 00:00:00 2001 From: Stan Ke <156306548@qq.com> Date: Fri, 13 Sep 2024 12:30:47 +0800 Subject: [PATCH] rollback --- app/api/chat/route.ts | 34 ---------------------------------- 1 file changed, 34 deletions(-) delete mode 100644 app/api/chat/route.ts diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts deleted file mode 100644 index c13c053..0000000 --- a/app/api/chat/route.ts +++ /dev/null @@ -1,34 +0,0 @@ -// app/api/chat/route.ts -import { NextRequest, NextResponse } from 'next/server'; -import { AIServiceFactory } from '@/lib/ai/AIServiceFactory'; -import { ModelProviderConfig } from '@/lib/ModelSetting'; -import { verifyJWT } from '@/lib/auth'; // Assuming you have a JWT verification function - -export const runtime = 'edge'; - -export async function POST(req: NextRequest) { - try { - const { message, model, token } = await req.json(); - const payload = await verifyJWT(token); // Verify and decode JWT - - const config: ModelProviderConfig = { - modelProvider: model.split('-')[0] as 'openai' | 'gemini' | 'claude' | /* other providers */, - model: model, - // ... other config options - }; - - const service = await AIServiceFactory.createService(config, payload); - const stream = await service.generateResponse(message); - - return new NextResponse(stream, { - headers: { - 'Content-Type': 'text/event-stream', - 'Cache-Control': 'no-cache', - 'Connection': 'keep-alive', - }, - }); - } catch (error: any) { - console.error('Error in chat API:', error); - return NextResponse.json({ error: error.message }, { status: 500 }); - } -} \ No newline at end of file