matthoffner commited on
Commit
640c3b0
β€’
1 Parent(s): 75a116d

Update app/api/chat/route.ts

Browse files
Files changed (1) hide show
  1. app/api/chat/route.ts +3 -4
app/api/chat/route.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Configuration, OpenAIApi } from "openai-edge";
2
  import { OpenAIStream, StreamingTextResponse } from "ai";
3
  import { createSearchApi } from "@/app/tools/search";
4
  import { createOddsApi } from "@/app/tools/odds";
@@ -10,11 +10,10 @@ const [, sportsApiResultsSchema] = createSportsResultsApi({ apiKey: process.env.
10
  const [, oddsApiSchema] = createOddsApi({ apiKey: process.env.ODDS_API_KEY || '' });
11
  const [, coinMarketCapApiSchema] = createCoinMarketCapApi({ apiKey: process.env.COINMARKETCAP_API_KEY || '' });
12
 
13
- const config = new Configuration({
14
  apiKey: process.env.MISTRAL_API_KEY,
15
  baseURL: "https://api.mistral.ai"
16
  });
17
- const openai = new OpenAIApi(config);
18
 
19
  const functions: any[] = [
20
  serpApiSchema,
@@ -26,7 +25,7 @@ const functions: any[] = [
26
  export async function POST(req: Request) {
27
  const { messages, function_call } = await req.json()
28
 
29
- const response = await openai.createChatCompletion({
30
  model: 'mistral-large-latest',
31
  stream: true,
32
  messages,
 
1
+ import OpenAI from "openai";
2
  import { OpenAIStream, StreamingTextResponse } from "ai";
3
  import { createSearchApi } from "@/app/tools/search";
4
  import { createOddsApi } from "@/app/tools/odds";
 
10
  const [, oddsApiSchema] = createOddsApi({ apiKey: process.env.ODDS_API_KEY || '' });
11
  const [, coinMarketCapApiSchema] = createCoinMarketCapApi({ apiKey: process.env.COINMARKETCAP_API_KEY || '' });
12
 
13
+ const openai = new OpenAI({
14
  apiKey: process.env.MISTRAL_API_KEY,
15
  baseURL: "https://api.mistral.ai"
16
  });
 
17
 
18
  const functions: any[] = [
19
  serpApiSchema,
 
25
  export async function POST(req: Request) {
26
  const { messages, function_call } = await req.json()
27
 
28
+ const response = await openai.chat.completions.create({
29
  model: 'mistral-large-latest',
30
  stream: true,
31
  messages,