mirror of
https://github.com/cfngc4594/monaco-editor-lsp-next.git
synced 2025-07-04 17:30:52 +00:00
refactor(api): extract OpenAI client to shared module
This commit is contained in:
parent
1c031ce24e
commit
9443ab6d6d
@ -1,14 +1,9 @@
|
|||||||
import { streamText } from 'ai';
|
import { streamText } from "ai";
|
||||||
import { createOpenAI } from '@ai-sdk/openai';
|
import { openai } from "@/lib/ai";
|
||||||
|
|
||||||
// Allow streaming responses up to 30 seconds
|
// Allow streaming responses up to 30 seconds
|
||||||
export const maxDuration = 30;
|
export const maxDuration = 30;
|
||||||
|
|
||||||
const openai = createOpenAI({
|
|
||||||
apiKey: process.env.OPENAI_API_KEY || "",
|
|
||||||
baseURL: process.env.OPENAI_BASE_URL || "",
|
|
||||||
});
|
|
||||||
|
|
||||||
export async function POST(req: Request) {
|
export async function POST(req: Request) {
|
||||||
const { messages } = await req.json();
|
const { messages } = await req.json();
|
||||||
|
|
||||||
|
8
src/lib/ai.ts
Normal file
8
src/lib/ai.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import "server-only";
|
||||||
|
|
||||||
|
import { createOpenAI } from "@ai-sdk/openai";
|
||||||
|
|
||||||
|
export const openai = createOpenAI({
|
||||||
|
apiKey: process.env.OPENAI_API_KEY || "",
|
||||||
|
baseURL: process.env.OPENAI_BASE_URL || "",
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user