mirror of
https://github.com/lobehub/lobehub
synced 2026-04-21 09:37:28 +00:00
* ✨ feat(tts): Add tts and stt basic features * ✨ feat(tts): Handle error * 💄 style(tts): Add alert to error handler * 🐛 fix(tts): Error display * ♻️ refactor: refactor the openai initial code to the createBizOpenAI * ♻️ refactor(tts): Refactor header config * ✨ feat: Add TTS voice preview * 🐛 fix(tts): Fix header * 🐛 fix: Fix api --------- Co-authored-by: Arvin Xu <arvinx@foxmail.com>
17 lines
623 B
TypeScript
17 lines
623 B
TypeScript
import { OpenAIChatStreamPayload } from '@/types/openai/chat';
|
|
|
|
import { createBizOpenAI } from '../createBizOpenAI';
|
|
import { createChatCompletion } from './createChatCompletion';
|
|
|
|
export const runtime = 'edge';
|
|
|
|
export const POST = async (req: Request) => {
|
|
const payload = (await req.json()) as OpenAIChatStreamPayload;
|
|
|
|
const openaiOrErrResponse = createBizOpenAI(req, payload.model);
|
|
|
|
// if resOrOpenAI is a Response, it means there is an error,just return it
|
|
if (openaiOrErrResponse instanceof Response) return openaiOrErrResponse;
|
|
|
|
return createChatCompletion({ openai: openaiOrErrResponse, payload });
|
|
};
|