1
- import { openai } from '@ai-sdk/openai'
1
+ import { createOpenAI } from '@ai-sdk/openai'
2
2
import { ToolInvocation , convertToCoreMessages , streamText } from 'ai'
3
3
import { codeBlock } from 'common-tags'
4
4
import { convertToCoreTools , maxMessageContext , maxRowLimit , tools } from '~/lib/tools'
@@ -12,6 +12,15 @@ type Message = {
12
12
toolInvocations ?: ( ToolInvocation & { result : any } ) [ ]
13
13
}
14
14
15
+ const chatModel = process . env . OPENAI_MODEL || 'gpt-4o-2024-08-06'
16
+
17
+ // Configure OpenAI client with custom base URL
18
+ const openai = createOpenAI ( {
19
+ apiKey : process . env . OPENAI_API_KEY ,
20
+ baseURL : process . env . OPENAI_API_BASE || 'https://api.openai.com/v1' ,
21
+ compatibility : 'strict' ,
22
+ } )
23
+
15
24
export async function POST ( req : Request ) {
16
25
const { messages } : { messages : Message [ ] } = await req . json ( )
17
26
@@ -49,7 +58,7 @@ export async function POST(req: Request) {
49
58
50
59
When importing CSVs try to solve the problem yourself (eg. use a generic text column, then refine)
51
60
vs. asking the user to change the CSV. No need to select rows after importing.
52
-
61
+
53
62
You also know math. All math equations and expressions must be written in KaTex and must be wrapped in double dollar \`$$\`:
54
63
- Inline: $$\\sqrt{26}$$
55
64
- Multiline:
@@ -61,7 +70,7 @@ export async function POST(req: Request) {
61
70
62
71
Feel free to suggest corrections for suspected typos.
63
72
` ,
64
- model : openai ( 'gpt-4o-2024-08-06' ) ,
73
+ model : openai ( chatModel ) ,
65
74
messages : convertToCoreMessages ( trimmedMessageContext ) ,
66
75
tools : convertToCoreTools ( tools ) ,
67
76
} )
0 commit comments