Skip to content

Commit 9d7a9d5

Browse files
authored
Use environment variable for Ollama
Without specifying the baseURL, createOllama defaults to localhost. Updated to use the environment variable.
1 parent 75d33ba commit 9d7a9d5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/app/api/chat/route.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ export async function POST(req: Request) {
88
// Destructure request data
99
const { messages, selectedModel, data } = await req.json();
1010

11+
const ollamaUrl = process.env.NEXT_PUBLIC_OLLAMA_URL || "http://localhost:11434";
12+
1113
const initialMessages = messages.slice(0, -1);
1214
const currentMessage = messages[messages.length - 1];
1315

14-
const ollama = createOllama({});
16+
const ollama = createOllama({baseURL: ollamaUrl + "/api"});
1517

1618
// Build message content array directly
1719
const messageContent: UserContent = [{ type: 'text', text: currentMessage.content }];

0 commit comments

Comments
 (0)