@morlay/dsh-web-search-ollama 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -6
- package/dist/client.cjs +2 -16698
- package/dist/client.d.cts +3 -2
- package/dist/client.d.mts +3 -2
- package/dist/client.mjs +51 -0
- package/dist/index.cjs +191 -0
- package/dist/index.d.mts +2 -2
- package/dist/rows.cjs +10 -0
- package/package.json +24 -17
- package/src/client/index.ts +0 -2
- package/src/client/locales.ts +2 -2
- package/dist/index.d.cts +0 -56
- package/dist/rows.d.cts +0 -12
package/dist/client.d.cts
CHANGED
|
@@ -8,7 +8,7 @@ declare const zh: {
|
|
|
8
8
|
readonly baseURL: "端点";
|
|
9
9
|
readonly baseURLHint: "端点根,`/api/web_search` 由 provider 拼;默认 https://ollama.com。";
|
|
10
10
|
readonly maxResults: "默认结果数";
|
|
11
|
-
readonly maxResultsHint: "
|
|
11
|
+
readonly maxResultsHint: "请求没带结果数时用它;默认就是让 Ollama 用自己的默认。";
|
|
12
12
|
};
|
|
13
13
|
type WebSearchFieldLocaleKey = keyof typeof zh;
|
|
14
14
|
//#endregion
|
|
@@ -22,4 +22,5 @@ declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
|
22
22
|
}
|
|
23
23
|
export declare const inject: string[];
|
|
24
24
|
export declare function apply(ctx: Context): void;
|
|
25
|
-
//#endregion
|
|
25
|
+
//#endregion
|
|
26
|
+
export {};
|
package/dist/client.d.mts
CHANGED
|
@@ -8,7 +8,7 @@ declare const zh: {
|
|
|
8
8
|
readonly baseURL: "端点";
|
|
9
9
|
readonly baseURLHint: "端点根,`/api/web_search` 由 provider 拼;默认 https://ollama.com。";
|
|
10
10
|
readonly maxResults: "默认结果数";
|
|
11
|
-
readonly maxResultsHint: "
|
|
11
|
+
readonly maxResultsHint: "请求没带结果数时用它;默认就是让 Ollama 用自己的默认。";
|
|
12
12
|
};
|
|
13
13
|
type WebSearchFieldLocaleKey = keyof typeof zh;
|
|
14
14
|
//#endregion
|
|
@@ -22,4 +22,5 @@ declare module "@deepseek-ai/dsh-client-ui-slots" {
|
|
|
22
22
|
}
|
|
23
23
|
export declare const inject: string[];
|
|
24
24
|
export declare function apply(ctx: Context): void;
|
|
25
|
-
//#endregion
|
|
25
|
+
//#endregion
|
|
26
|
+
export {};
|
package/dist/client.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/client/locales.ts
|
|
2
|
+
const zh = {
|
|
3
|
+
apiKey: "API key",
|
|
4
|
+
apiKeyHint: "字面值;能走凭证服务时优先用下面的引用名,别把密钥写进配置文件。",
|
|
5
|
+
apiKeyEnv: "凭证引用名",
|
|
6
|
+
apiKeyEnvHint: "每次搜索经凭证服务解析一次;默认 `OLLAMA_API_KEY`。",
|
|
7
|
+
baseURL: "端点",
|
|
8
|
+
baseURLHint: "端点根,`/api/web_search` 由 provider 拼;默认 https://ollama.com。",
|
|
9
|
+
maxResults: "默认结果数",
|
|
10
|
+
maxResultsHint: "请求没带结果数时用它;默认就是让 Ollama 用自己的默认。"
|
|
11
|
+
};
|
|
12
|
+
const en = {
|
|
13
|
+
apiKey: "API key",
|
|
14
|
+
apiKeyHint: "Literal value; prefer the credential reference below and never inline secrets.",
|
|
15
|
+
apiKeyEnv: "Credential reference",
|
|
16
|
+
apiKeyEnvHint: "Resolved through the credentials service per search; defaults to `OLLAMA_API_KEY`.",
|
|
17
|
+
baseURL: "Endpoint",
|
|
18
|
+
baseURLHint: "Endpoint root; the provider appends `/api/web_search`. Defaults to https://ollama.com.",
|
|
19
|
+
maxResults: "Default result count",
|
|
20
|
+
maxResultsHint: "Used when a request carries none; the default keeps Ollama's own default."
|
|
21
|
+
};
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/client/index.ts
|
|
24
|
+
const WEB_SEARCH_NS = "web-search-ollama";
|
|
25
|
+
const NS = "settings.web-search-ollama";
|
|
26
|
+
const FIELDS = [
|
|
27
|
+
"apiKey",
|
|
28
|
+
"apiKeyEnv",
|
|
29
|
+
"baseURL",
|
|
30
|
+
"maxResults"
|
|
31
|
+
];
|
|
32
|
+
const inject = ["locale"];
|
|
33
|
+
function apply(ctx) {
|
|
34
|
+
const t = ctx.locale.bind(NS);
|
|
35
|
+
ctx.effect(() => ctx.locale.register(NS, {
|
|
36
|
+
zh,
|
|
37
|
+
en
|
|
38
|
+
}), "web-search-ollama: field locale");
|
|
39
|
+
ctx.inject(["schemaFormHints"], (scope) => scope.effect(() => {
|
|
40
|
+
const hints = scope.schemaFormHints;
|
|
41
|
+
const offs = FIELDS.map((key) => hints.describe(WEB_SEARCH_NS, [key], () => ({
|
|
42
|
+
label: t(key),
|
|
43
|
+
hint: t(`${key}Hint`)
|
|
44
|
+
})));
|
|
45
|
+
return () => {
|
|
46
|
+
for (const off of offs) off();
|
|
47
|
+
};
|
|
48
|
+
}, "web-search-ollama: field wording"));
|
|
49
|
+
}
|
|
50
|
+
//#endregion
|
|
51
|
+
export { NS, WEB_SEARCH_NS, apply, inject };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let _deepseek_ai_dsh_credentials = require("@deepseek-ai/dsh-credentials");
|
|
25
|
+
let _deepseek_ai_dsh_launch_environment = require("@deepseek-ai/dsh-launch-environment");
|
|
26
|
+
let _deepseek_ai_schemastery = require("@deepseek-ai/schemastery");
|
|
27
|
+
_deepseek_ai_schemastery = __toESM(_deepseek_ai_schemastery, 1);
|
|
28
|
+
let _deepseek_ai_dsh_web = require("@deepseek-ai/dsh-web");
|
|
29
|
+
//#region src/provider.ts
|
|
30
|
+
const OLLAMA_PROVIDER_ID = "ollama";
|
|
31
|
+
const OLLAMA_DEFAULT_BASE_URL = "https://ollama.com";
|
|
32
|
+
const OLLAMA_DEFAULT_MAX_RESULTS = 5;
|
|
33
|
+
const OLLAMA_MAX_RESULTS_LIMIT = 10;
|
|
34
|
+
const USER_AGENT = "morlay-dsh-plugin/0.0.1";
|
|
35
|
+
function mapOllamaResult(result) {
|
|
36
|
+
const url = result.url;
|
|
37
|
+
if (typeof url !== "string" || url.length === 0) return void 0;
|
|
38
|
+
const title = typeof result.title === "string" && result.title.length > 0 ? result.title : void 0;
|
|
39
|
+
const snippet = typeof result.content === "string" && result.content.length > 0 ? result.content : void 0;
|
|
40
|
+
return {
|
|
41
|
+
url,
|
|
42
|
+
...title === void 0 ? {} : { title },
|
|
43
|
+
...snippet === void 0 ? {} : { snippet }
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
function mapOllamaResponse(response) {
|
|
47
|
+
const results = response.results;
|
|
48
|
+
if (results !== void 0 && !Array.isArray(results)) throw new TypeError("Ollama returned a non-array `results` field");
|
|
49
|
+
return {
|
|
50
|
+
sources: (results ?? []).map((result) => mapOllamaResult(result)).filter((source) => source !== void 0),
|
|
51
|
+
truncated: false
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
var OllamaSearchProvider = class {
|
|
55
|
+
options;
|
|
56
|
+
id = OLLAMA_PROVIDER_ID;
|
|
57
|
+
constructor(options) {
|
|
58
|
+
this.options = options;
|
|
59
|
+
}
|
|
60
|
+
available() {
|
|
61
|
+
const { apiKey, resolveApiKey, baseURL, maxResults } = this.options;
|
|
62
|
+
return (apiKey !== void 0 && apiKey.length > 0 || resolveApiKey !== void 0) && URL.canParse(baseURL) && (maxResults === void 0 || isPositiveInteger(maxResults));
|
|
63
|
+
}
|
|
64
|
+
async search(request, signal) {
|
|
65
|
+
const apiKey = await this.apiKey();
|
|
66
|
+
const maxResults = clampMaxResults(request.maxResults ?? this.options.maxResults);
|
|
67
|
+
let response;
|
|
68
|
+
try {
|
|
69
|
+
response = await fetch(`${this.options.baseURL}/api/web_search`, {
|
|
70
|
+
method: "POST",
|
|
71
|
+
redirect: "error",
|
|
72
|
+
headers: {
|
|
73
|
+
authorization: `Bearer ${apiKey}`,
|
|
74
|
+
"content-type": "application/json",
|
|
75
|
+
accept: "application/json",
|
|
76
|
+
"user-agent": USER_AGENT
|
|
77
|
+
},
|
|
78
|
+
body: JSON.stringify({
|
|
79
|
+
query: request.query,
|
|
80
|
+
...maxResults === void 0 ? {} : { max_results: maxResults }
|
|
81
|
+
}),
|
|
82
|
+
...signal === void 0 ? {} : { signal }
|
|
83
|
+
});
|
|
84
|
+
} catch (error) {
|
|
85
|
+
if (isAbortError(error)) throw searchAborted(error);
|
|
86
|
+
throw new _deepseek_ai_dsh_web.WebError(`Ollama search request failed: ${String(error)}`, "WEB_PROVIDER_ERROR", { cause: error });
|
|
87
|
+
}
|
|
88
|
+
if (!response.ok) {
|
|
89
|
+
let message = `Ollama API error (HTTP ${response.status})`;
|
|
90
|
+
try {
|
|
91
|
+
const detail = (await response.json()).error;
|
|
92
|
+
if (typeof detail === "string" && detail.length > 0) message = detail;
|
|
93
|
+
} catch (error) {
|
|
94
|
+
if (isAbortError(error)) throw searchAborted(error);
|
|
95
|
+
}
|
|
96
|
+
throw new _deepseek_ai_dsh_web.WebError(message, "WEB_PROVIDER_ERROR");
|
|
97
|
+
}
|
|
98
|
+
try {
|
|
99
|
+
return mapOllamaResponse(await response.json());
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (isAbortError(error)) throw searchAborted(error);
|
|
102
|
+
throw new _deepseek_ai_dsh_web.WebError(`Ollama returned an unprocessable response body: ${String(error)}`, "WEB_PROVIDER_ERROR", { cause: error });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async apiKey() {
|
|
106
|
+
const literal = this.options.apiKey;
|
|
107
|
+
if (literal !== void 0 && literal.length > 0) return literal;
|
|
108
|
+
let resolved;
|
|
109
|
+
try {
|
|
110
|
+
resolved = await this.options.resolveApiKey?.();
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (isAbortError(error)) throw searchAborted(error);
|
|
113
|
+
throw new _deepseek_ai_dsh_web.WebError(`Ollama search credential resolution failed: ${String(error)}`, "WEB_PROVIDER_ERROR", { cause: error });
|
|
114
|
+
}
|
|
115
|
+
if (resolved !== void 0 && resolved.length > 0) return resolved;
|
|
116
|
+
throw new _deepseek_ai_dsh_web.WebError(`Ollama search has no API key for "${this.options.apiKeyEnv}"; store it through the credentials service (the web Models page writes it), export it in the launching environment, or set a literal "apiKey" in the web-search-ollama config`, "WEB_PROVIDER_CREDENTIAL_MISSING");
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function clampMaxResults(maxResults) {
|
|
120
|
+
if (maxResults === void 0) return void 0;
|
|
121
|
+
return Math.min(maxResults, 10);
|
|
122
|
+
}
|
|
123
|
+
function isPositiveInteger(value) {
|
|
124
|
+
return Number.isInteger(value) && value > 0;
|
|
125
|
+
}
|
|
126
|
+
function isAbortError(error) {
|
|
127
|
+
return error instanceof DOMException && error.name === "AbortError";
|
|
128
|
+
}
|
|
129
|
+
function searchAborted(cause) {
|
|
130
|
+
return new _deepseek_ai_dsh_web.WebError("Ollama search aborted", "WEB_ABORTED", { cause });
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
//#region src/index.ts
|
|
134
|
+
const name = "web-search-ollama";
|
|
135
|
+
const inject = ["web"];
|
|
136
|
+
const DEFAULT_API_KEY_ENV = "OLLAMA_API_KEY";
|
|
137
|
+
const localized = (text) => text;
|
|
138
|
+
const Config = _deepseek_ai_schemastery.default.object({
|
|
139
|
+
apiKey: _deepseek_ai_schemastery.default.string().role("secret").description(localized({
|
|
140
|
+
zh: "Ollama 的 API key 字面值;能用凭证服务时优先用下面的引用名,别把密钥写进配置文件。",
|
|
141
|
+
en: "Literal Ollama API key. Prefer the credential reference below; do not put secrets in a config file."
|
|
142
|
+
})).volatile(),
|
|
143
|
+
apiKeyEnv: _deepseek_ai_schemastery.default.string().role("credential-ref").description(localized({
|
|
144
|
+
zh: "凭证引用名(默认 `OLLAMA_API_KEY`):每次搜索经凭证服务解析一次。",
|
|
145
|
+
en: "Credential reference resolved through the credentials service on every search (default `OLLAMA_API_KEY`)."
|
|
146
|
+
})).volatile(),
|
|
147
|
+
baseURL: _deepseek_ai_schemastery.default.string().description(localized({
|
|
148
|
+
zh: "端点根,`/api/web_search` 由 provider 拼;默认 https://ollama.com。",
|
|
149
|
+
en: "Endpoint root; the provider appends `/api/web_search`. Defaults to https://ollama.com."
|
|
150
|
+
})).volatile(),
|
|
151
|
+
maxResults: _deepseek_ai_schemastery.default.number().step(1).min(1).description(localized({
|
|
152
|
+
zh: "请求没带结果数时用的默认值;省略就是让 Ollama 用自己的默认。",
|
|
153
|
+
en: "Default result count when a request carries none; unset keeps Ollama's own default."
|
|
154
|
+
})).volatile()
|
|
155
|
+
});
|
|
156
|
+
function apply(ctx, config) {
|
|
157
|
+
ctx.web.registerSearchProvider(new OllamaSearchProvider({
|
|
158
|
+
get apiKey() {
|
|
159
|
+
const literal = config.apiKey.get();
|
|
160
|
+
return literal !== void 0 && literal.length > 0 ? literal : void 0;
|
|
161
|
+
},
|
|
162
|
+
resolveApiKey: async () => {
|
|
163
|
+
const reference = (0, _deepseek_ai_dsh_credentials.credentialRef)(config.apiKeyEnv.get() ?? DEFAULT_API_KEY_ENV);
|
|
164
|
+
const credentials = ctx.get("credentials");
|
|
165
|
+
if (credentials !== void 0) return (await credentials.resolve(reference))?.value;
|
|
166
|
+
const ambient = (0, _deepseek_ai_dsh_launch_environment.launchEnvironmentOf)(ctx).get(reference);
|
|
167
|
+
return ambient !== void 0 && ambient.value.length > 0 ? ambient.value : void 0;
|
|
168
|
+
},
|
|
169
|
+
get apiKeyEnv() {
|
|
170
|
+
return config.apiKeyEnv.get() ?? DEFAULT_API_KEY_ENV;
|
|
171
|
+
},
|
|
172
|
+
get baseURL() {
|
|
173
|
+
return config.baseURL.get() ?? "https://ollama.com";
|
|
174
|
+
},
|
|
175
|
+
get maxResults() {
|
|
176
|
+
return config.maxResults.get();
|
|
177
|
+
}
|
|
178
|
+
}));
|
|
179
|
+
}
|
|
180
|
+
//#endregion
|
|
181
|
+
exports.Config = Config;
|
|
182
|
+
exports.OLLAMA_DEFAULT_BASE_URL = OLLAMA_DEFAULT_BASE_URL;
|
|
183
|
+
exports.OLLAMA_DEFAULT_MAX_RESULTS = OLLAMA_DEFAULT_MAX_RESULTS;
|
|
184
|
+
exports.OLLAMA_MAX_RESULTS_LIMIT = OLLAMA_MAX_RESULTS_LIMIT;
|
|
185
|
+
exports.OLLAMA_PROVIDER_ID = OLLAMA_PROVIDER_ID;
|
|
186
|
+
exports.OllamaSearchProvider = OllamaSearchProvider;
|
|
187
|
+
exports.apply = apply;
|
|
188
|
+
exports.inject = inject;
|
|
189
|
+
exports.mapOllamaResponse = mapOllamaResponse;
|
|
190
|
+
exports.mapOllamaResult = mapOllamaResult;
|
|
191
|
+
exports.name = name;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { Volatile } from "@deepseek-ai/cosmokit";
|
|
2
|
+
import { Context } from "@deepseek-ai/cordis";
|
|
1
3
|
import z from "@deepseek-ai/schemastery";
|
|
2
4
|
import { WebSearchProvider, WebSearchRequest, WebSearchResult, WebSearchSource } from "@deepseek-ai/dsh-web";
|
|
3
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
4
|
-
import { Volatile } from "@deepseek-ai/cosmokit";
|
|
5
5
|
//#region src/types.d.ts
|
|
6
6
|
interface OllamaSearchResult {
|
|
7
7
|
title?: string | null;
|
package/dist/rows.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region src/rows.ts
|
|
3
|
+
function webSearchRows() {
|
|
4
|
+
return [{ insert: [{
|
|
5
|
+
id: "web-search-ollama",
|
|
6
|
+
name: "@morlay/dsh-web-search-ollama"
|
|
7
|
+
}] }];
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
exports.webSearchRows = webSearchRows;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morlay/dsh-web-search-ollama",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Ollama-backed search provider for the DeepSeek Harness web seam (ctx.web): one web_search backend calling POST https://ollama.com/api/web_search.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"dsh",
|
|
@@ -21,32 +21,39 @@
|
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
23
|
"exports": {
|
|
24
|
-
".":
|
|
25
|
-
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.mts",
|
|
26
|
+
"default": "./dist/index.mjs"
|
|
27
|
+
},
|
|
28
|
+
"./rows": {
|
|
29
|
+
"types": "./dist/rows.d.mts",
|
|
30
|
+
"default": "./dist/rows.mjs"
|
|
31
|
+
},
|
|
26
32
|
"./package.json": "./package.json",
|
|
27
33
|
"./client": {
|
|
28
|
-
"types": "./dist/client.d.
|
|
29
|
-
"
|
|
34
|
+
"types": "./dist/client.d.mts",
|
|
35
|
+
"import": "./dist/client.mjs",
|
|
36
|
+
"default": "./dist/client.mjs"
|
|
30
37
|
},
|
|
31
38
|
"./locale/*.json": "./locale/*.json"
|
|
32
39
|
},
|
|
33
40
|
"dependencies": {
|
|
34
|
-
"@deepseek-ai/schemastery": "^3.18.
|
|
41
|
+
"@deepseek-ai/schemastery": "^3.18.5-alpha.2"
|
|
35
42
|
},
|
|
36
43
|
"devDependencies": {
|
|
37
|
-
"@deepseek-ai/cosmokit": "1.8.
|
|
38
|
-
"@deepseek-ai/dsh-client-locale": "0.2.
|
|
39
|
-
"@deepseek-ai/dsh-client-ui-slots": "0.2.
|
|
40
|
-
"@morlay/dsh-client-ui-primitives": "0.0.
|
|
44
|
+
"@deepseek-ai/cosmokit": "1.8.6-alpha.2",
|
|
45
|
+
"@deepseek-ai/dsh-client-locale": "0.2.1-alpha.5",
|
|
46
|
+
"@deepseek-ai/dsh-client-ui-slots": "0.2.1-alpha.5",
|
|
47
|
+
"@morlay/dsh-client-ui-primitives": "0.0.9"
|
|
41
48
|
},
|
|
42
49
|
"peerDependencies": {
|
|
43
|
-
"@deepseek-ai/cordis": "^4.0.
|
|
44
|
-
"@deepseek-ai/cosmokit": "^1.8.
|
|
45
|
-
"@deepseek-ai/dsh-client-locale": "^0.2.
|
|
46
|
-
"@deepseek-ai/dsh-client-ui-slots": "^0.2.
|
|
47
|
-
"@deepseek-ai/dsh-credentials": "^0.2.
|
|
48
|
-
"@deepseek-ai/dsh-launch-environment": "^0.2.
|
|
49
|
-
"@deepseek-ai/dsh-web": "^0.2.
|
|
50
|
+
"@deepseek-ai/cordis": "^4.0.5-alpha.2",
|
|
51
|
+
"@deepseek-ai/cosmokit": "^1.8.6-alpha.2",
|
|
52
|
+
"@deepseek-ai/dsh-client-locale": "^0.2.1-alpha.5",
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-slots": "^0.2.1-alpha.5",
|
|
54
|
+
"@deepseek-ai/dsh-credentials": "^0.2.1-alpha.5",
|
|
55
|
+
"@deepseek-ai/dsh-launch-environment": "^0.2.1-alpha.5",
|
|
56
|
+
"@deepseek-ai/dsh-web": "^0.2.1-alpha.5"
|
|
50
57
|
},
|
|
51
58
|
"dsh": {
|
|
52
59
|
"client": {
|
package/src/client/index.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
import type { Context } from "@deepseek-ai/cordis";
|
|
5
5
|
import type {} from "@deepseek-ai/dsh-client-locale/client";
|
|
6
6
|
import type {} from "@deepseek-ai/dsh-client-ui-slots";
|
|
7
|
-
import { apply as installUiPrimitives } from "@morlay/dsh-client-ui-primitives/client";
|
|
8
7
|
import { en, zh, type WebSearchFieldLocaleKey } from "./locales.ts";
|
|
9
8
|
|
|
10
9
|
// 本包 host 行 id:行配置页读的就是这个命名空间。
|
|
@@ -29,7 +28,6 @@ export const inject = ["locale"];
|
|
|
29
28
|
// 给这一行的四个字段补文案。
|
|
30
29
|
export function apply(ctx: Context): void {
|
|
31
30
|
// 基础面随本包 inline(不再是装配行):装上它提供的字典、字段槽与按行配置页;多份副本只装一次。
|
|
32
|
-
installUiPrimitives(ctx);
|
|
33
31
|
const t = ctx.locale.bind(NS);
|
|
34
32
|
ctx.effect(() => ctx.locale.register(NS, { zh, en }), "web-search-ollama: field locale");
|
|
35
33
|
// 提示面由行配置表单提供:等它可用再注册(`ctx.get` 在它还没提供时拿不到,注册会被静静跳过)。
|
package/src/client/locales.ts
CHANGED
|
@@ -8,7 +8,7 @@ export const zh = {
|
|
|
8
8
|
baseURL: "端点",
|
|
9
9
|
baseURLHint: "端点根,`/api/web_search` 由 provider 拼;默认 https://ollama.com。",
|
|
10
10
|
maxResults: "默认结果数",
|
|
11
|
-
maxResultsHint: "
|
|
11
|
+
maxResultsHint: "请求没带结果数时用它;默认就是让 Ollama 用自己的默认。",
|
|
12
12
|
} as const;
|
|
13
13
|
|
|
14
14
|
export const en: Record<keyof typeof zh, string> = {
|
|
@@ -21,7 +21,7 @@ export const en: Record<keyof typeof zh, string> = {
|
|
|
21
21
|
baseURLHint:
|
|
22
22
|
"Endpoint root; the provider appends `/api/web_search`. Defaults to https://ollama.com.",
|
|
23
23
|
maxResults: "Default result count",
|
|
24
|
-
maxResultsHint: "Used when a request carries none;
|
|
24
|
+
maxResultsHint: "Used when a request carries none; the default keeps Ollama's own default.",
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export type WebSearchFieldLocaleKey = keyof typeof zh;
|
package/dist/index.d.cts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Context } from "@deepseek-ai/cordis";
|
|
2
|
-
import { Volatile } from "@deepseek-ai/cosmokit";
|
|
3
|
-
import z from "@deepseek-ai/schemastery";
|
|
4
|
-
import { WebSearchProvider, WebSearchRequest, WebSearchResult, WebSearchSource } from "@deepseek-ai/dsh-web";
|
|
5
|
-
//#region src/types.d.ts
|
|
6
|
-
interface OllamaSearchResult {
|
|
7
|
-
title?: string | null;
|
|
8
|
-
url?: string | null;
|
|
9
|
-
content?: string | null;
|
|
10
|
-
}
|
|
11
|
-
interface OllamaSearchResponse {
|
|
12
|
-
results?: OllamaSearchResult[];
|
|
13
|
-
}
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/provider.d.ts
|
|
16
|
-
export declare const OLLAMA_PROVIDER_ID = "ollama";
|
|
17
|
-
export declare const OLLAMA_DEFAULT_BASE_URL = "https://ollama.com";
|
|
18
|
-
export declare const OLLAMA_DEFAULT_MAX_RESULTS = 5;
|
|
19
|
-
export declare const OLLAMA_MAX_RESULTS_LIMIT = 10;
|
|
20
|
-
interface OllamaSearchProviderOptions {
|
|
21
|
-
apiKey?: string | undefined;
|
|
22
|
-
resolveApiKey?: () => Promise<string | undefined>;
|
|
23
|
-
apiKeyEnv: string;
|
|
24
|
-
baseURL: string;
|
|
25
|
-
maxResults?: number | undefined;
|
|
26
|
-
}
|
|
27
|
-
export declare function mapOllamaResult(result: OllamaSearchResult): WebSearchSource | undefined;
|
|
28
|
-
export declare function mapOllamaResponse(response: OllamaSearchResponse): WebSearchResult;
|
|
29
|
-
export declare class OllamaSearchProvider implements WebSearchProvider {
|
|
30
|
-
private readonly options;
|
|
31
|
-
readonly id = "ollama";
|
|
32
|
-
constructor(options: OllamaSearchProviderOptions);
|
|
33
|
-
available(): boolean;
|
|
34
|
-
search(request: WebSearchRequest, signal?: AbortSignal): Promise<WebSearchResult>;
|
|
35
|
-
private apiKey;
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/index.d.ts
|
|
39
|
-
export declare const name = "web-search-ollama";
|
|
40
|
-
export declare const inject: string[];
|
|
41
|
-
export interface Config {
|
|
42
|
-
apiKey?: string;
|
|
43
|
-
apiKeyEnv?: string;
|
|
44
|
-
baseURL?: string;
|
|
45
|
-
maxResults?: number;
|
|
46
|
-
}
|
|
47
|
-
export interface ResolvedConfig {
|
|
48
|
-
readonly apiKey: Volatile<string | undefined>;
|
|
49
|
-
readonly apiKeyEnv: Volatile<string | undefined>;
|
|
50
|
-
readonly baseURL: Volatile<string | undefined>;
|
|
51
|
-
readonly maxResults: Volatile<number | undefined>;
|
|
52
|
-
}
|
|
53
|
-
export declare const Config: z<Config, ResolvedConfig>;
|
|
54
|
-
export declare function apply(ctx: Context, config: ResolvedConfig): void;
|
|
55
|
-
//#endregion
|
|
56
|
-
export type { OllamaSearchProviderOptions };
|
package/dist/rows.d.cts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
//#region src/rows.d.ts
|
|
2
|
-
export interface PatchRow {
|
|
3
|
-
readonly id?: string;
|
|
4
|
-
readonly insert?: readonly RowEntry[];
|
|
5
|
-
}
|
|
6
|
-
export interface RowEntry {
|
|
7
|
-
readonly id: string;
|
|
8
|
-
readonly name: string;
|
|
9
|
-
readonly config?: Readonly<Record<string, unknown>>;
|
|
10
|
-
}
|
|
11
|
-
export declare function webSearchRows(): readonly PatchRow[];
|
|
12
|
-
//#endregion
|