@alisio/plugin-deepseek 0.1.0-alpha.2 → 0.1.0-alpha.6
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/dist/index.js +2 -1
- package/dist/provider.js +44 -5
- package/dist/version.d.ts +8 -0
- package/dist/version.js +28 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { definePlugin } from "@alisio/sdk";
|
|
2
2
|
import { DeepSeekProvider } from "./provider.js";
|
|
3
|
+
import { loadVersion } from "./version.js";
|
|
3
4
|
const DEFAULT_BASE_URL = "https://api.deepseek.com";
|
|
4
5
|
const profileString = (request, key, fallback) => typeof request.profile[key] === "string" ? String(request.profile[key]) : fallback;
|
|
5
6
|
export function createDeepSeekPlugin() {
|
|
@@ -8,7 +9,7 @@ export function createDeepSeekPlugin() {
|
|
|
8
9
|
name: "DeepSeek",
|
|
9
10
|
description: "Dedicated DeepSeek Chat Completions and Responses provider",
|
|
10
11
|
categories: ["model-provider"],
|
|
11
|
-
version:
|
|
12
|
+
version: loadVersion(import.meta.url),
|
|
12
13
|
apiVersion: 1,
|
|
13
14
|
setup(api) {
|
|
14
15
|
api.providers.register({
|
package/dist/provider.js
CHANGED
|
@@ -170,12 +170,23 @@ export class DeepSeekProvider {
|
|
|
170
170
|
if (choice.finish_reason)
|
|
171
171
|
finish = choice.finish_reason;
|
|
172
172
|
}
|
|
173
|
-
if (finish !== "stop" && finish !== "tool_calls")
|
|
173
|
+
if (finish !== "stop" && finish !== "tool_calls" && finish !== "length")
|
|
174
174
|
throw new Error(`Provider response incomplete: ${finish ?? "stream ended"}`);
|
|
175
175
|
const completed = [...calls.entries()].sort(([a], [b]) => a - b).map(([, c]) => c);
|
|
176
176
|
if (completed.some((c) => !c.id || !c.name))
|
|
177
177
|
throw new Error("Incomplete tool call");
|
|
178
|
-
|
|
178
|
+
if (finish === "length" && !text.trim())
|
|
179
|
+
throw new Error("Provider response cut off by max output tokens before any usable content; raise limits.maxOutputTokens");
|
|
180
|
+
yield {
|
|
181
|
+
type: "completed",
|
|
182
|
+
message: {
|
|
183
|
+
role: "assistant",
|
|
184
|
+
text,
|
|
185
|
+
calls: completed,
|
|
186
|
+
...(finish === "length" ? { truncated: true } : {}),
|
|
187
|
+
},
|
|
188
|
+
usage,
|
|
189
|
+
};
|
|
179
190
|
}
|
|
180
191
|
async *responses(request) {
|
|
181
192
|
const input = [];
|
|
@@ -231,10 +242,38 @@ export class DeepSeekProvider {
|
|
|
231
242
|
officialEvent.type === "response.reasoning_summary_text.delta") &&
|
|
232
243
|
typeof officialEvent.delta === "string")
|
|
233
244
|
yield { type: "reasoning_delta", delta: officialEvent.delta };
|
|
234
|
-
if (event.type === "response.failed" ||
|
|
235
|
-
event.type === "response.incomplete" ||
|
|
236
|
-
event.type === "error")
|
|
245
|
+
if (event.type === "response.failed" || event.type === "error")
|
|
237
246
|
throw new Error(`Provider response failed: ${event.type}`);
|
|
247
|
+
if (event.type === "response.incomplete") {
|
|
248
|
+
complete = true;
|
|
249
|
+
const r = event.response;
|
|
250
|
+
const calls = r.output
|
|
251
|
+
.filter((x) => x.type === "function_call")
|
|
252
|
+
.map((x) => ({ id: x.call_id, name: x.name, arguments: x.arguments }));
|
|
253
|
+
const text = r.output
|
|
254
|
+
.filter((x) => x.type === "message")
|
|
255
|
+
.flatMap((x) => x.content)
|
|
256
|
+
.filter((x) => x.type === "output_text")
|
|
257
|
+
.map((x) => x.text)
|
|
258
|
+
.join("");
|
|
259
|
+
if (!text.trim())
|
|
260
|
+
throw new Error("Provider response cut off by max output tokens before any usable content; raise limits.maxOutputTokens");
|
|
261
|
+
if (calls.some((c) => !c.id || !c.name))
|
|
262
|
+
throw new Error("Incomplete tool call");
|
|
263
|
+
yield {
|
|
264
|
+
type: "completed",
|
|
265
|
+
message: { role: "assistant", text, calls, providerData: r.output, truncated: true },
|
|
266
|
+
usage: r.usage
|
|
267
|
+
? {
|
|
268
|
+
input: r.usage.input_tokens,
|
|
269
|
+
output: r.usage.output_tokens,
|
|
270
|
+
...(typeof r.usage.input_tokens_details?.cached_tokens === "number"
|
|
271
|
+
? { cachedInput: r.usage.input_tokens_details.cached_tokens }
|
|
272
|
+
: {}),
|
|
273
|
+
}
|
|
274
|
+
: undefined,
|
|
275
|
+
};
|
|
276
|
+
}
|
|
238
277
|
if (event.type === "response.completed") {
|
|
239
278
|
complete = true;
|
|
240
279
|
const r = event.response;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reads this plugin package's version at runtime so plugin metadata, user-agent defaults and CLI
|
|
3
|
+
* reports stay in sync with the published package without a build-time constant to update.
|
|
4
|
+
* The manifest is resolved relative to the module (`src/version.ts` → `../package.json` in the
|
|
5
|
+
* source tree; `dist/version.js` → `../package.json` of the installed package). Standalone
|
|
6
|
+
* binaries inject the version at build time via ALISIO_PACKAGE_VERSION (scripts/binary-build.ts).
|
|
7
|
+
*/
|
|
8
|
+
export declare function loadVersion(fromHere: string): string;
|
package/dist/version.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { dirname, join } from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
/**
|
|
5
|
+
* Fallback used when neither the build-time injection nor the package manifest is readable
|
|
6
|
+
* (e.g. an unpackaged embed). Keep it a development marker, never a publish literal, so it
|
|
7
|
+
* cannot silently desync from the published package.
|
|
8
|
+
*/
|
|
9
|
+
const FALLBACK = "dev";
|
|
10
|
+
/**
|
|
11
|
+
* Reads this plugin package's version at runtime so plugin metadata, user-agent defaults and CLI
|
|
12
|
+
* reports stay in sync with the published package without a build-time constant to update.
|
|
13
|
+
* The manifest is resolved relative to the module (`src/version.ts` → `../package.json` in the
|
|
14
|
+
* source tree; `dist/version.js` → `../package.json` of the installed package). Standalone
|
|
15
|
+
* binaries inject the version at build time via ALISIO_PACKAGE_VERSION (scripts/binary-build.ts).
|
|
16
|
+
*/
|
|
17
|
+
export function loadVersion(fromHere) {
|
|
18
|
+
if (process.env.ALISIO_PACKAGE_VERSION)
|
|
19
|
+
return process.env.ALISIO_PACKAGE_VERSION;
|
|
20
|
+
try {
|
|
21
|
+
const manifest = join(dirname(fileURLToPath(fromHere)), "..", "package.json");
|
|
22
|
+
const parsed = JSON.parse(readFileSync(manifest, "utf8"));
|
|
23
|
+
return typeof parsed.version === "string" && parsed.version ? parsed.version : FALLBACK;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return FALLBACK;
|
|
27
|
+
}
|
|
28
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alisio/plugin-deepseek",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.6",
|
|
4
4
|
"description": "Built-in DeepSeek model provider for Alisio.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"openai": "7.23.0"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@alisio/sdk": "^0.1.0-alpha.
|
|
27
|
+
"@alisio/sdk": "^0.1.0-alpha.5"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@alisio/sdk": "0.1.0-alpha.
|
|
30
|
+
"@alisio/sdk": "0.1.0-alpha.5"
|
|
31
31
|
},
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public",
|