feat(connectors): add Ollama and LM Studio as a local auth kind
Both servers expose OpenAI-compatible /v1/chat/completions and /v1/models, so we route them through pi-ai's `openai-completions` API the same way Fireworks does — but with a per-installation base URL the user enters during onboarding instead of a hardcoded one. The shared schemas grow a `local` credential payload carrying just the baseUrl; the credential resolver surfaces it on `ResolvedCredential.baseUrl`, the runtime bridge forwards it through `prepareRun`, and the worker plumbs it into `resolveModel` so the streamed Model<openai-completions> targets the user's server. The local-cost path short-circuits to zero in cost-writer since users bill their own hardware, and the live model list is fetched from the saved baseUrl by `fetchLocalConnectorModels` (Ollama and LM Studio both speak the standard OpenAI catalog shape). Onboarding ships a new LocalProviderCard and the Settings panel a LocalForm; both default to the catalog's per-connector localhost URL and accept any custom URL.
This commit is contained in:
1 parent
07d9c00fab
commit
a532120649
26 files changed
+504
-18
No files matched your search
@@ -9,3 +9,4 @@
|
||||
export { OAUTH_CONNECTORS } from "./oauth";
|
||||
export { API_KEY_CONNECTORS } from "./apikey";
|
||||
export { CLOUD_CONNECTORS } from "./cloud";
|
||||
export { LOCAL_CONNECTORS } from "./local";
|
||||
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Local pi-mono connectors.
|
||||
*
|
||||
* Ollama and LM Studio both expose an OpenAI-compatible
|
||||
* `/v1/chat/completions` endpoint, so they are routed through pi-ai's
|
||||
* `openai-completions` API path with a per-installation `baseUrl` that
|
||||
* the user enters during onboarding. The provider ids are deliberately
|
||||
* absent from `@mariozechner/pi-ai`'s `KnownProvider` set — model
|
||||
* dispatch resolves them locally via `src/main/model-resolver.ts` the
|
||||
* same way `fireworks` and `fireworks-firepass` do.
|
||||
*
|
||||
* No environment variable name accompanies the auth descriptor: a local
|
||||
* server's address is a user choice, never read from `process.env`.
|
||||
*/
|
||||
|
||||
import type { ConnectorDefinition } from "../connector-definitions";
|
||||
|
||||
export const LOCAL_CONNECTORS: ConnectorDefinition[] = [
|
||||
{
|
||||
id: "ollama",
|
||||
provider: "ollama",
|
||||
label: "Ollama",
|
||||
description:
|
||||
"Local Ollama server (https://ollama.com) — runs open-weights models on your own machine through its OpenAI-compatible endpoint.",
|
||||
defaultModel: "llama3.2",
|
||||
auth: { type: "local", defaultBaseUrl: "http://localhost:11434/v1" },
|
||||
notes:
|
||||
"Ollama exposes /v1/chat/completions and /v1/models. The default port is 11434; override if you launched `ollama serve` on a different address.",
|
||||
},
|
||||
{
|
||||
id: "lm-studio",
|
||||
provider: "lm-studio",
|
||||
label: "LM Studio",
|
||||
description:
|
||||
"Local LM Studio server (https://lmstudio.ai) — host any loaded model through its OpenAI-compatible endpoint.",
|
||||
defaultModel: "local-model",
|
||||
auth: { type: "local", defaultBaseUrl: "http://localhost:1234/v1" },
|
||||
notes:
|
||||
"Enable LM Studio's local server from the Developer tab; the default port is 1234. Model ids match whatever you have loaded.",
|
||||
},
|
||||
];
|
||||
Reference in new issue
Block a user