mirror of
https://github.com/rowboatlabs/rowboat.git
synced 2026-04-25 08:26:22 +02:00
add ollama support
This commit is contained in:
parent
51e29af12e
commit
13955b6829
5 changed files with 55 additions and 6 deletions
|
|
@ -35,8 +35,11 @@ const baseModelConfig: z.infer<typeof ModelConfigT> = {
|
|||
flavor: "anthropic",
|
||||
},
|
||||
google: {
|
||||
flavor: "google"
|
||||
flavor: "google",
|
||||
},
|
||||
ollama: {
|
||||
flavor: "ollama",
|
||||
}
|
||||
},
|
||||
defaults: {
|
||||
provider: "openai",
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import z from "zod";
|
||||
|
||||
export const Provider = z.object({
|
||||
flavor: z.enum(["openai", "anthropic", "google"]),
|
||||
flavor: z.enum(["openai", "anthropic", "google", "ollama"]),
|
||||
apiKey: z.string().optional(),
|
||||
baseURL: z.string().optional(),
|
||||
headers: z.record(z.string(), z.string()).optional(),
|
||||
});
|
||||
|
||||
export const ModelConfig = z.object({
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
import { createOpenAI, OpenAIProvider } from "@ai-sdk/openai";
|
||||
import { createGoogleGenerativeAI, GoogleGenerativeAIProvider } from "@ai-sdk/google";
|
||||
import { AnthropicProvider, createAnthropic } from "@ai-sdk/anthropic";
|
||||
import { OllamaProvider, createOllama } from "ollama-ai-provider-v2";
|
||||
import { ModelConfig } from "../config/config.js";
|
||||
|
||||
const providerMap: Record<string, OpenAIProvider | GoogleGenerativeAIProvider | AnthropicProvider> = {};
|
||||
const providerMap: Record<string, OpenAIProvider | GoogleGenerativeAIProvider | AnthropicProvider | OllamaProvider> = {};
|
||||
|
||||
export function getProvider(name: string = "") {
|
||||
if (!name) {
|
||||
|
|
@ -21,18 +22,27 @@ export function getProvider(name: string = "") {
|
|||
providerMap[name] = createOpenAI({
|
||||
apiKey: providerConfig.apiKey,
|
||||
baseURL: providerConfig.baseURL,
|
||||
headers: providerConfig.headers,
|
||||
});
|
||||
break;
|
||||
case "anthropic":
|
||||
providerMap[name] = createAnthropic({
|
||||
apiKey: providerConfig.apiKey,
|
||||
baseURL: providerConfig.baseURL,
|
||||
headers: providerConfig.headers,
|
||||
});
|
||||
break;
|
||||
case "google":
|
||||
providerMap[name] = createGoogleGenerativeAI({
|
||||
apiKey: providerConfig.apiKey,
|
||||
baseURL: providerConfig.baseURL,
|
||||
headers: providerConfig.headers,
|
||||
});
|
||||
break;
|
||||
case "ollama":
|
||||
providerMap[name] = createOllama({
|
||||
baseURL: providerConfig.baseURL,
|
||||
headers: providerConfig.headers,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue