mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
fix(onboard): default custom Ollama URL to native API
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { CONTEXT_WINDOW_HARD_MIN_TOKENS } from "../agents/context-window-guard.js";
|
||||
import { OLLAMA_DEFAULT_BASE_URL } from "../agents/ollama-models.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import {
|
||||
@@ -133,6 +134,23 @@ describe("promptCustomApiConfig", () => {
|
||||
expect(result.config.agents?.defaults?.models?.["custom/llama3"]?.alias).toBe("local");
|
||||
});
|
||||
|
||||
it("defaults custom onboarding to the native Ollama base URL", async () => {
|
||||
const prompter = createTestPrompter({
|
||||
text: ["http://localhost:11434", "", "llama3", "custom", ""],
|
||||
select: ["plaintext", "openai"],
|
||||
});
|
||||
stubFetchSequence([{ ok: true }]);
|
||||
|
||||
await runPromptCustomApi(prompter);
|
||||
|
||||
expect(prompter.text).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
message: "API Base URL",
|
||||
initialValue: OLLAMA_DEFAULT_BASE_URL,
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("retries when verification fails", async () => {
|
||||
const prompter = createTestPrompter({
|
||||
text: ["http://localhost:11434/v1", "", "bad-model", "good-model", "custom", ""],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { CONTEXT_WINDOW_HARD_MIN_TOKENS } from "../agents/context-window-guard.js";
|
||||
import { DEFAULT_PROVIDER } from "../agents/defaults.js";
|
||||
import { buildModelAliasIndex, modelKey } from "../agents/model-selection.js";
|
||||
import { OLLAMA_DEFAULT_BASE_URL } from "../agents/ollama-models.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { ModelProviderConfig } from "../config/types.models.js";
|
||||
import { isSecretRef, type SecretInput } from "../config/types.secrets.js";
|
||||
@@ -16,7 +17,6 @@ import { applyPrimaryModel } from "./model-picker.js";
|
||||
import { normalizeAlias } from "./models/shared.js";
|
||||
import type { SecretInputMode } from "./onboard-types.js";
|
||||
|
||||
const DEFAULT_OLLAMA_BASE_URL = "http://127.0.0.1:11434/v1";
|
||||
const DEFAULT_CONTEXT_WINDOW = CONTEXT_WINDOW_HARD_MIN_TOKENS;
|
||||
const DEFAULT_MAX_TOKENS = 4096;
|
||||
const VERIFY_TIMEOUT_MS = 30_000;
|
||||
@@ -389,7 +389,7 @@ async function promptBaseUrlAndKey(params: {
|
||||
}): Promise<{ baseUrl: string; apiKey?: SecretInput; resolvedApiKey: string }> {
|
||||
const baseUrlInput = await params.prompter.text({
|
||||
message: "API Base URL",
|
||||
initialValue: params.initialBaseUrl ?? DEFAULT_OLLAMA_BASE_URL,
|
||||
initialValue: params.initialBaseUrl ?? OLLAMA_DEFAULT_BASE_URL,
|
||||
placeholder: "https://api.example.com/v1",
|
||||
validate: (val) => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user