import type { OpenClawConfig } from "openclaw/plugin-sdk/config-runtime"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { createOllamaWebSearchProvider as createContractOllamaWebSearchProvider } from "../web-search-contract-api.js"; import {
__testing as testing,
createOllamaWebSearchProvider,
runOllamaWebSearch,
} from "./web-search-provider.js";
it("registers a keyless web search provider", () => {
expect(createContractOllamaWebSearchProvider()).toMatchObject({
id: "ollama",
label: "Ollama Web Search",
requiresCredential: false,
envVars: [],
});
});
it("uses the configured Ollama host and enables the plugin in config", () => { const provider = createOllamaWebSearchProvider(); if (!provider.applySelectionConfig) { thrownew Error("Expected applySelectionConfig to be defined");
}
it("prefers the plugin web search base URL over the model provider host", () => {
expect(
testing.resolveOllamaWebSearchBaseUrl(
createOllamaConfigWithWebSearchBaseUrl("http://localhost:11434/v1"),
),
).toBe("http://localhost:11434");
});
it("falls back to the local Ollama host when the model provider uses ollama cloud", () => {
expect(
testing.resolveOllamaWebSearchBaseUrl(
createOllamaConfig({
baseUrl: "https://ollama.com",
}),
),
).toBe("http://127.0.0.1:11434");
});
it("warns when Ollama is not reachable during setup without cancelling", async () => {
fetchWithSsrFGuardMock.mockRejectedValueOnce(new Error("connect failed"));
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.