Add ollama support (#7)

This commit is contained in:
Will Chen
2025-04-23 14:48:57 -07:00
committed by GitHub
parent a7b3e66499
commit b616598bab
14 changed files with 386 additions and 73 deletions

View File

@@ -2,6 +2,8 @@ import { createOpenAI } from "@ai-sdk/openai";
import { createGoogleGenerativeAI as createGoogle } from "@ai-sdk/google";
import { createAnthropic } from "@ai-sdk/anthropic";
import { createOpenRouter } from "@openrouter/ai-sdk-provider";
import { createOllama } from "ollama-ai-provider";
import type { LargeLanguageModel, UserSettings } from "../../lib/schemas";
import { PROVIDER_TO_ENV_VAR, AUTO_MODELS } from "../../constants/models";
import { getEnvVar } from "./read_env";
@@ -56,6 +58,10 @@ export function getModelClient(
const provider = createOpenRouter({ apiKey });
return provider(model.name);
}
case "ollama": {
const provider = createOllama();
return provider(model.name);
}
default: {
// Ensure exhaustive check if more providers are added
const _exhaustiveCheck: never = model.provider;