feat: make ollama host configurable in goose2 (#8912)

This commit is contained in:
Kalvin C
2026-04-29 11:16:10 -07:00
committed by GitHub
parent 5fcdf31ad5
commit 000d7c58de
6 changed files with 120 additions and 6 deletions
@@ -1,5 +1,26 @@
import { describe, expect, it } from "vitest";
import { resolveAgentProviderCatalogId } from "./providerCatalog";
import {
getCatalogEntry,
resolveAgentProviderCatalogId,
} from "./providerCatalog";
describe("provider catalog", () => {
it("exposes Ollama host configuration", () => {
const ollama = getCatalogEntry("ollama");
expect(ollama?.setupMethod).toBe("config_fields");
expect(ollama?.fields).toEqual([
{
key: "OLLAMA_HOST",
label: "Host",
secret: false,
required: true,
placeholder: "localhost or http://localhost:11434",
defaultValue: "http://localhost:11434",
},
]);
});
});
describe("resolveAgentProviderCatalogId", () => {
it("matches direct catalog ids", () => {
@@ -6,7 +6,6 @@ import {
} from "./providerCatalogAliases";
export const PROVIDER_CATALOG: ProviderCatalogEntry[] = [
// ── Agent providers ──────────────────────────────────────────────
{
id: "goose",
displayName: "Goose",
@@ -92,7 +91,6 @@ export const PROVIDER_CATALOG: ProviderCatalogEntry[] = [
showOnlyWhenInstalled: true,
},
// ── Model providers (power Goose) ────────────────────────────────
{
id: "anthropic",
displayName: "Anthropic",
@@ -164,8 +162,18 @@ export const PROVIDER_CATALOG: ProviderCatalogEntry[] = [
id: "ollama",
displayName: "Ollama",
category: "model",
description: "Run models locally",
setupMethod: "local",
description: "Run local or self-hosted models",
setupMethod: "config_fields",
fields: [
{
key: "OLLAMA_HOST",
label: "Host",
secret: false,
required: true,
placeholder: "localhost or http://localhost:11434",
defaultValue: "http://localhost:11434",
},
],
docsUrl: "https://ollama.com",
tier: "promoted",
},
@@ -73,6 +73,37 @@ describe("ModelProviderRow", () => {
]);
});
it("pre-fills and saves provider field defaults", async () => {
const user = userEvent.setup();
render(
<ModelProviderRow
provider={modelProvider("ollama", "not_configured")}
onGetConfig={onGetConfig}
onSaveFields={onSaveFields}
onRemoveConfig={onRemoveConfig}
onCompleteNativeSetup={onCompleteNativeSetup}
/>,
);
await user.click(screen.getByRole("button", { name: /ollama/i }));
expect(
await screen.findByDisplayValue("http://localhost:11434"),
).toBeVisible();
await user.click(screen.getByRole("button", { name: /^save$/i }));
await waitFor(() => expect(onSaveFields).toHaveBeenCalledTimes(1));
expect(onSaveFields).toHaveBeenCalledWith([
{
key: "OLLAMA_HOST",
value: "http://localhost:11434",
isSecret: false,
},
]);
});
it("shows the connected row while model inventory is still loading", async () => {
const user = userEvent.setup();
@@ -49,7 +49,7 @@ export function createDraftValues(
if (field.secret) {
return [field.key, ""];
}
return [field.key, currentValue?.value ?? ""];
return [field.key, currentValue?.value ?? field.defaultValue ?? ""];
}),
);
}
+1
View File
@@ -19,6 +19,7 @@ export interface ProviderField {
secret: boolean;
required: boolean;
placeholder?: string;
defaultValue?: string;
}
export interface ProviderFieldValue {