Skip to content

Commit e65011d

Browse files
committed
fix(onboard): default custom Ollama URL to native API
1 parent 620bae4 commit e65011d

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/commands/onboard-custom.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { afterEach, describe, expect, it, vi } from "vitest";
22
import { CONTEXT_WINDOW_HARD_MIN_TOKENS } from "../agents/context-window-guard.js";
3+
import { OLLAMA_DEFAULT_BASE_URL } from "../agents/ollama-models.js";
34
import type { OpenClawConfig } from "../config/config.js";
45
import { defaultRuntime } from "../runtime.js";
56
import {
@@ -133,6 +134,23 @@ describe("promptCustomApiConfig", () => {
133134
expect(result.config.agents?.defaults?.models?.["custom/llama3"]?.alias).toBe("local");
134135
});
135136

137+
it("defaults custom onboarding to the native Ollama base URL", async () => {
138+
const prompter = createTestPrompter({
139+
text: ["http://localhost:11434", "", "llama3", "custom", ""],
140+
select: ["plaintext", "openai"],
141+
});
142+
stubFetchSequence([{ ok: true }]);
143+
144+
await runPromptCustomApi(prompter);
145+
146+
expect(prompter.text).toHaveBeenCalledWith(
147+
expect.objectContaining({
148+
message: "API Base URL",
149+
initialValue: OLLAMA_DEFAULT_BASE_URL,
150+
}),
151+
);
152+
});
153+
136154
it("retries when verification fails", async () => {
137155
const prompter = createTestPrompter({
138156
text: ["http://localhost:11434/v1", "", "bad-model", "good-model", "custom", ""],

src/commands/onboard-custom.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CONTEXT_WINDOW_HARD_MIN_TOKENS } from "../agents/context-window-guard.js";
22
import { DEFAULT_PROVIDER } from "../agents/defaults.js";
33
import { buildModelAliasIndex, modelKey } from "../agents/model-selection.js";
4+
import { OLLAMA_DEFAULT_BASE_URL } from "../agents/ollama-models.js";
45
import type { OpenClawConfig } from "../config/config.js";
56
import type { ModelProviderConfig } from "../config/types.models.js";
67
import { isSecretRef, type SecretInput } from "../config/types.secrets.js";
@@ -16,7 +17,6 @@ import { applyPrimaryModel } from "./model-picker.js";
1617
import { normalizeAlias } from "./models/shared.js";
1718
import type { SecretInputMode } from "./onboard-types.js";
1819

19-
const DEFAULT_OLLAMA_BASE_URL = "http://127.0.0.1:11434/v1";
2020
const DEFAULT_CONTEXT_WINDOW = CONTEXT_WINDOW_HARD_MIN_TOKENS;
2121
const DEFAULT_MAX_TOKENS = 4096;
2222
const VERIFY_TIMEOUT_MS = 30_000;
@@ -389,7 +389,7 @@ async function promptBaseUrlAndKey(params: {
389389
}): Promise<{ baseUrl: string; apiKey?: SecretInput; resolvedApiKey: string }> {
390390
const baseUrlInput = await params.prompter.text({
391391
message: "API Base URL",
392-
initialValue: params.initialBaseUrl ?? DEFAULT_OLLAMA_BASE_URL,
392+
initialValue: params.initialBaseUrl ?? OLLAMA_DEFAULT_BASE_URL,
393393
placeholder: "https://api.example.com/v1",
394394
validate: (val) => {
395395
try {

0 commit comments

Comments
 (0)