@workglow/ai-provider 0.0.97 → 0.0.99
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/HFT_JobRunFns-ajak33q5.js +60 -0
- package/dist/HFT_JobRunFns-ajak33q5.js.map +9 -0
- package/dist/anthropic/index.js +11 -92
- package/dist/anthropic/index.js.map +4 -7
- package/dist/google-gemini/index.js +11 -103
- package/dist/google-gemini/index.js.map +4 -7
- package/dist/hf-transformers/common/HFT_JobRunFns.d.ts.map +1 -1
- package/dist/hf-transformers/index.js +46 -1080
- package/dist/hf-transformers/index.js.map +4 -9
- package/dist/index-2pvfsjyx.js +857 -0
- package/dist/index-2pvfsjyx.js.map +10 -0
- package/dist/index-34rcjm0y.js +78 -0
- package/dist/index-34rcjm0y.js.map +12 -0
- package/dist/index-9w5hs4zc.js +73 -0
- package/dist/index-9w5hs4zc.js.map +12 -0
- package/dist/index-jd3bbc2x.js +11 -0
- package/dist/index-jd3bbc2x.js.map +9 -0
- package/dist/index-kctzvn3c.js +75 -0
- package/dist/index-kctzvn3c.js.map +12 -0
- package/dist/index-m0r2hvfz.js +57 -0
- package/dist/index-m0r2hvfz.js.map +10 -0
- package/dist/index-rmbnv0rw.js +169 -0
- package/dist/index-rmbnv0rw.js.map +11 -0
- package/dist/index-tn88s0ke.js +71 -0
- package/dist/index-tn88s0ke.js.map +12 -0
- package/dist/index-wnmajxg6.js +86 -0
- package/dist/index-wnmajxg6.js.map +12 -0
- package/dist/index-xyavfrb8.js +97 -0
- package/dist/index-xyavfrb8.js.map +12 -0
- package/dist/index.browser-jd3bbc2x.js +11 -0
- package/dist/index.browser-jd3bbc2x.js.map +9 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +80 -1369
- package/dist/index.js.map +3 -20
- package/dist/provider-hf-inference/HFI_Worker.d.ts +7 -0
- package/dist/provider-hf-inference/HFI_Worker.d.ts.map +1 -0
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts +40 -0
- package/dist/provider-hf-inference/HfInferenceProvider.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_Constants.d.ts +7 -0
- package/dist/provider-hf-inference/common/HFI_Constants.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts +17 -0
- package/dist/provider-hf-inference/common/HFI_JobRunFns.d.ts.map +1 -0
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts +146 -0
- package/dist/provider-hf-inference/common/HFI_ModelSchema.d.ts.map +1 -0
- package/dist/provider-hf-inference/index.d.ts +11 -0
- package/dist/provider-hf-inference/index.d.ts.map +1 -0
- package/dist/provider-hf-inference/index.js +209 -0
- package/dist/provider-hf-inference/index.js.map +11 -0
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts +38 -0
- package/dist/provider-llamacpp/LlamaCppProvider.d.ts.map +1 -0
- package/dist/provider-llamacpp/LlamaCpp_Worker.d.ts +7 -0
- package/dist/provider-llamacpp/LlamaCpp_Worker.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_Constants.d.ts +8 -0
- package/dist/provider-llamacpp/common/LlamaCpp_Constants.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts +20 -0
- package/dist/provider-llamacpp/common/LlamaCpp_JobRunFns.d.ts.map +1 -0
- package/dist/provider-llamacpp/common/LlamaCpp_ModelSchema.d.ts +209 -0
- package/dist/provider-llamacpp/common/LlamaCpp_ModelSchema.d.ts.map +1 -0
- package/dist/provider-llamacpp/index.d.ts +11 -0
- package/dist/provider-llamacpp/index.d.ts.map +1 -0
- package/dist/provider-llamacpp/index.js +365 -0
- package/dist/provider-llamacpp/index.js.map +11 -0
- package/dist/provider-ollama/index.browser.js +4 -8
- package/dist/provider-ollama/index.browser.js.map +2 -2
- package/dist/provider-ollama/index.js +12 -88
- package/dist/provider-ollama/index.js.map +4 -7
- package/dist/provider-openai/index.js +11 -95
- package/dist/provider-openai/index.js.map +4 -7
- package/dist/tf-mediapipe/index.js +4 -8
- package/dist/tf-mediapipe/index.js.map +2 -2
- package/package.json +39 -18
- package/dist/ggml/server.d.ts +0 -2
- package/dist/ggml/server.d.ts.map +0 -1
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import {
|
|
2
|
+
HF_INFERENCE,
|
|
3
|
+
HfInferenceModelConfigSchema,
|
|
4
|
+
HfInferenceModelRecordSchema,
|
|
5
|
+
HfInferenceModelSchema,
|
|
6
|
+
HfInferenceProvider
|
|
7
|
+
} from "../index-9w5hs4zc.js";
|
|
8
|
+
import {
|
|
9
|
+
__require
|
|
10
|
+
} from "../index-jd3bbc2x.js";
|
|
11
|
+
// src/provider-hf-inference/common/HFI_JobRunFns.ts
|
|
12
|
+
var _sdk;
|
|
13
|
+
async function loadHfInferenceSDK() {
|
|
14
|
+
if (!_sdk) {
|
|
15
|
+
try {
|
|
16
|
+
_sdk = await import("@huggingface/inference");
|
|
17
|
+
} catch {
|
|
18
|
+
throw new Error("@huggingface/inference is required for Hugging Face Inference tasks. Install it with: bun add @huggingface/inference");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return _sdk;
|
|
22
|
+
}
|
|
23
|
+
async function getClient(model) {
|
|
24
|
+
const sdk = await loadHfInferenceSDK();
|
|
25
|
+
const apiKey = model?.provider_config?.api_key || (typeof process !== "undefined" ? process.env?.HF_TOKEN : undefined);
|
|
26
|
+
if (!apiKey) {
|
|
27
|
+
throw new Error("Missing Hugging Face API key: set provider_config.api_key or the HF_TOKEN environment variable.");
|
|
28
|
+
}
|
|
29
|
+
return new sdk.InferenceClient(apiKey);
|
|
30
|
+
}
|
|
31
|
+
function getModelName(model) {
|
|
32
|
+
const name = model?.provider_config?.model_name;
|
|
33
|
+
if (!name) {
|
|
34
|
+
throw new Error("Missing model name in provider_config.model_name.");
|
|
35
|
+
}
|
|
36
|
+
return name;
|
|
37
|
+
}
|
|
38
|
+
function getProvider(model) {
|
|
39
|
+
return model?.provider_config?.provider;
|
|
40
|
+
}
|
|
41
|
+
var HFI_TextGeneration = async (input, model, update_progress, signal) => {
|
|
42
|
+
update_progress(0, "Starting HF Inference text generation");
|
|
43
|
+
const client = await getClient(model);
|
|
44
|
+
const modelName = getModelName(model);
|
|
45
|
+
const provider = getProvider(model);
|
|
46
|
+
const response = await client.chatCompletion({
|
|
47
|
+
model: modelName,
|
|
48
|
+
messages: [{ role: "user", content: input.prompt }],
|
|
49
|
+
max_tokens: input.maxTokens,
|
|
50
|
+
temperature: input.temperature,
|
|
51
|
+
top_p: input.topP,
|
|
52
|
+
frequency_penalty: input.frequencyPenalty,
|
|
53
|
+
provider
|
|
54
|
+
}, { signal });
|
|
55
|
+
update_progress(100, "Completed HF Inference text generation");
|
|
56
|
+
return { text: response.choices[0]?.message?.content ?? "" };
|
|
57
|
+
};
|
|
58
|
+
var HFI_TextEmbedding = async (input, model, update_progress, signal) => {
|
|
59
|
+
update_progress(0, "Starting HF Inference text embedding");
|
|
60
|
+
const client = await getClient(model);
|
|
61
|
+
const modelName = getModelName(model);
|
|
62
|
+
if (Array.isArray(input.text)) {
|
|
63
|
+
const embeddings = await Promise.all(input.text.map((text) => client.featureExtraction({
|
|
64
|
+
model: modelName,
|
|
65
|
+
inputs: text
|
|
66
|
+
}, { signal })));
|
|
67
|
+
update_progress(100, "Completed HF Inference text embedding");
|
|
68
|
+
return {
|
|
69
|
+
vector: embeddings.map((embedding2) => new Float32Array(embedding2))
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const embedding = await client.featureExtraction({
|
|
73
|
+
model: modelName,
|
|
74
|
+
inputs: input.text
|
|
75
|
+
}, { signal });
|
|
76
|
+
update_progress(100, "Completed HF Inference text embedding");
|
|
77
|
+
return { vector: new Float32Array(embedding) };
|
|
78
|
+
};
|
|
79
|
+
var HFI_TextRewriter = async (input, model, update_progress, signal) => {
|
|
80
|
+
update_progress(0, "Starting HF Inference text rewriting");
|
|
81
|
+
const client = await getClient(model);
|
|
82
|
+
const modelName = getModelName(model);
|
|
83
|
+
const provider = getProvider(model);
|
|
84
|
+
const response = await client.chatCompletion({
|
|
85
|
+
model: modelName,
|
|
86
|
+
messages: [
|
|
87
|
+
{ role: "system", content: input.prompt },
|
|
88
|
+
{ role: "user", content: input.text }
|
|
89
|
+
],
|
|
90
|
+
provider
|
|
91
|
+
}, { signal });
|
|
92
|
+
update_progress(100, "Completed HF Inference text rewriting");
|
|
93
|
+
return { text: response.choices[0]?.message?.content ?? "" };
|
|
94
|
+
};
|
|
95
|
+
var HFI_TextSummary = async (input, model, update_progress, signal) => {
|
|
96
|
+
update_progress(0, "Starting HF Inference text summarization");
|
|
97
|
+
const client = await getClient(model);
|
|
98
|
+
const modelName = getModelName(model);
|
|
99
|
+
const provider = getProvider(model);
|
|
100
|
+
const response = await client.chatCompletion({
|
|
101
|
+
model: modelName,
|
|
102
|
+
messages: [
|
|
103
|
+
{ role: "system", content: "Summarize the following text concisely." },
|
|
104
|
+
{ role: "user", content: input.text }
|
|
105
|
+
],
|
|
106
|
+
provider
|
|
107
|
+
}, { signal });
|
|
108
|
+
update_progress(100, "Completed HF Inference text summarization");
|
|
109
|
+
return { text: response.choices[0]?.message?.content ?? "" };
|
|
110
|
+
};
|
|
111
|
+
var HFI_TextGeneration_Stream = async function* (input, model, signal) {
|
|
112
|
+
const client = await getClient(model);
|
|
113
|
+
const modelName = getModelName(model);
|
|
114
|
+
const provider = getProvider(model);
|
|
115
|
+
const stream = client.chatCompletionStream({
|
|
116
|
+
model: modelName,
|
|
117
|
+
messages: [{ role: "user", content: input.prompt }],
|
|
118
|
+
max_tokens: input.maxTokens,
|
|
119
|
+
temperature: input.temperature,
|
|
120
|
+
top_p: input.topP,
|
|
121
|
+
frequency_penalty: input.frequencyPenalty,
|
|
122
|
+
provider
|
|
123
|
+
}, { signal });
|
|
124
|
+
for await (const chunk of stream) {
|
|
125
|
+
const delta = chunk.choices[0]?.delta?.content ?? "";
|
|
126
|
+
if (delta) {
|
|
127
|
+
yield { type: "text-delta", port: "text", textDelta: delta };
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
yield { type: "finish", data: {} };
|
|
131
|
+
};
|
|
132
|
+
var HFI_TextRewriter_Stream = async function* (input, model, signal) {
|
|
133
|
+
const client = await getClient(model);
|
|
134
|
+
const modelName = getModelName(model);
|
|
135
|
+
const provider = getProvider(model);
|
|
136
|
+
const stream = client.chatCompletionStream({
|
|
137
|
+
model: modelName,
|
|
138
|
+
messages: [
|
|
139
|
+
{ role: "system", content: input.prompt },
|
|
140
|
+
{ role: "user", content: input.text }
|
|
141
|
+
],
|
|
142
|
+
provider
|
|
143
|
+
}, { signal });
|
|
144
|
+
for await (const chunk of stream) {
|
|
145
|
+
const delta = chunk.choices[0]?.delta?.content ?? "";
|
|
146
|
+
if (delta) {
|
|
147
|
+
yield { type: "text-delta", port: "text", textDelta: delta };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
yield { type: "finish", data: {} };
|
|
151
|
+
};
|
|
152
|
+
var HFI_TextSummary_Stream = async function* (input, model, signal) {
|
|
153
|
+
const client = await getClient(model);
|
|
154
|
+
const modelName = getModelName(model);
|
|
155
|
+
const provider = getProvider(model);
|
|
156
|
+
const stream = client.chatCompletionStream({
|
|
157
|
+
model: modelName,
|
|
158
|
+
messages: [
|
|
159
|
+
{ role: "system", content: "Summarize the following text concisely." },
|
|
160
|
+
{ role: "user", content: input.text }
|
|
161
|
+
],
|
|
162
|
+
provider
|
|
163
|
+
}, { signal });
|
|
164
|
+
for await (const chunk of stream) {
|
|
165
|
+
const delta = chunk.choices[0]?.delta?.content ?? "";
|
|
166
|
+
if (delta) {
|
|
167
|
+
yield { type: "text-delta", port: "text", textDelta: delta };
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
yield { type: "finish", data: {} };
|
|
171
|
+
};
|
|
172
|
+
var HFI_TASKS = {
|
|
173
|
+
TextGenerationTask: HFI_TextGeneration,
|
|
174
|
+
TextEmbeddingTask: HFI_TextEmbedding,
|
|
175
|
+
TextRewriterTask: HFI_TextRewriter,
|
|
176
|
+
TextSummaryTask: HFI_TextSummary
|
|
177
|
+
};
|
|
178
|
+
var HFI_STREAM_TASKS = {
|
|
179
|
+
TextGenerationTask: HFI_TextGeneration_Stream,
|
|
180
|
+
TextRewriterTask: HFI_TextRewriter_Stream,
|
|
181
|
+
TextSummaryTask: HFI_TextSummary_Stream
|
|
182
|
+
};
|
|
183
|
+
// src/provider-hf-inference/HFI_Worker.ts
|
|
184
|
+
import { globalServiceRegistry, parentPort, WORKER_SERVER } from "@workglow/util";
|
|
185
|
+
function HFI_WORKER_JOBRUN_REGISTER() {
|
|
186
|
+
const workerServer = globalServiceRegistry.get(WORKER_SERVER);
|
|
187
|
+
new HfInferenceProvider(HFI_TASKS, HFI_STREAM_TASKS).registerOnWorkerServer(workerServer);
|
|
188
|
+
parentPort.postMessage({ type: "ready" });
|
|
189
|
+
console.log("HFI_WORKER_JOBRUN registered");
|
|
190
|
+
}
|
|
191
|
+
export {
|
|
192
|
+
HfInferenceProvider,
|
|
193
|
+
HfInferenceModelSchema,
|
|
194
|
+
HfInferenceModelRecordSchema,
|
|
195
|
+
HfInferenceModelConfigSchema,
|
|
196
|
+
HF_INFERENCE,
|
|
197
|
+
HFI_WORKER_JOBRUN_REGISTER,
|
|
198
|
+
HFI_TextSummary_Stream,
|
|
199
|
+
HFI_TextSummary,
|
|
200
|
+
HFI_TextRewriter_Stream,
|
|
201
|
+
HFI_TextRewriter,
|
|
202
|
+
HFI_TextGeneration_Stream,
|
|
203
|
+
HFI_TextGeneration,
|
|
204
|
+
HFI_TextEmbedding,
|
|
205
|
+
HFI_TASKS,
|
|
206
|
+
HFI_STREAM_TASKS
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
//# debugId=3C4381563BACDED064756E2164756E21
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/provider-hf-inference/common/HFI_JobRunFns.ts", "../src/provider-hf-inference/HFI_Worker.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type { InferenceProviderOrPolicy } from \"@huggingface/inference\";\nimport type {\n AiProviderRunFn,\n AiProviderStreamFn,\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n} from \"@workglow/ai\";\nimport type { StreamEvent } from \"@workglow/task-graph\";\nimport type { HfInferenceModelConfig } from \"./HFI_ModelSchema\";\n\nlet _sdk: typeof import(\"@huggingface/inference\") | undefined;\nasync function loadHfInferenceSDK() {\n if (!_sdk) {\n try {\n _sdk = await import(\"@huggingface/inference\");\n } catch {\n throw new Error(\n \"@huggingface/inference is required for Hugging Face Inference tasks. Install it with: bun add @huggingface/inference\"\n );\n }\n }\n return _sdk;\n}\n\nasync function getClient(model: HfInferenceModelConfig | undefined) {\n const sdk = await loadHfInferenceSDK();\n const apiKey =\n model?.provider_config?.api_key ||\n (typeof process !== \"undefined\" ? process.env?.HF_TOKEN : undefined);\n if (!apiKey) {\n throw new Error(\n \"Missing Hugging Face API key: set provider_config.api_key or the HF_TOKEN environment variable.\"\n );\n }\n return new sdk.InferenceClient(apiKey);\n}\n\nfunction getModelName(model: HfInferenceModelConfig | undefined): string {\n const name = model?.provider_config?.model_name;\n if (!name) {\n throw new Error(\"Missing model name in provider_config.model_name.\");\n }\n return name;\n}\n\nfunction getProvider(\n model: HfInferenceModelConfig | undefined\n): InferenceProviderOrPolicy | undefined {\n return model?.provider_config?.provider as InferenceProviderOrPolicy | undefined;\n}\n\nexport const HFI_TextGeneration: AiProviderRunFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text generation\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: input.maxTokens,\n temperature: input.temperature,\n top_p: input.topP,\n frequency_penalty: input.frequencyPenalty,\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text generation\");\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\nexport const HFI_TextEmbedding: AiProviderRunFn<\n TextEmbeddingTaskInput,\n TextEmbeddingTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text embedding\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n\n if (Array.isArray(input.text)) {\n const embeddings = await Promise.all(\n input.text.map((text) =>\n client.featureExtraction(\n {\n model: modelName,\n inputs: text,\n },\n { signal }\n )\n )\n );\n\n update_progress(100, \"Completed HF Inference text embedding\");\n return {\n vector: embeddings.map((embedding) => new Float32Array(embedding as unknown as number[])),\n };\n }\n\n const embedding = await client.featureExtraction(\n {\n model: modelName,\n inputs: input.text,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text embedding\");\n return { vector: new Float32Array(embedding as unknown as number[]) };\n};\n\nexport const HFI_TextRewriter: AiProviderRunFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text rewriting\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text rewriting\");\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\nexport const HFI_TextSummary: AiProviderRunFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfInferenceModelConfig\n> = async (input, model, update_progress, signal) => {\n update_progress(0, \"Starting HF Inference text summarization\");\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const response = await client.chatCompletion(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n update_progress(100, \"Completed HF Inference text summarization\");\n return { text: response.choices[0]?.message?.content ?? \"\" };\n};\n\n// ========================================================================\n// Streaming implementations (append mode)\n// ========================================================================\n\nexport const HFI_TextGeneration_Stream: AiProviderStreamFn<\n TextGenerationTaskInput,\n TextGenerationTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextGenerationTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [{ role: \"user\", content: input.prompt }],\n max_tokens: input.maxTokens,\n temperature: input.temperature,\n top_p: input.topP,\n frequency_penalty: input.frequencyPenalty,\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextGenerationTaskOutput };\n};\n\nexport const HFI_TextRewriter_Stream: AiProviderStreamFn<\n TextRewriterTaskInput,\n TextRewriterTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextRewriterTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: input.prompt },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextRewriterTaskOutput };\n};\n\nexport const HFI_TextSummary_Stream: AiProviderStreamFn<\n TextSummaryTaskInput,\n TextSummaryTaskOutput,\n HfInferenceModelConfig\n> = async function* (input, model, signal): AsyncIterable<StreamEvent<TextSummaryTaskOutput>> {\n const client = await getClient(model);\n const modelName = getModelName(model);\n const provider = getProvider(model);\n\n const stream = client.chatCompletionStream(\n {\n model: modelName,\n messages: [\n { role: \"system\", content: \"Summarize the following text concisely.\" },\n { role: \"user\", content: input.text },\n ],\n provider,\n },\n { signal }\n );\n\n for await (const chunk of stream) {\n const delta = chunk.choices[0]?.delta?.content ?? \"\";\n if (delta) {\n yield { type: \"text-delta\", port: \"text\", textDelta: delta };\n }\n }\n yield { type: \"finish\", data: {} as TextSummaryTaskOutput };\n};\n\n// ========================================================================\n// Task registries\n// ========================================================================\n\nexport const HFI_TASKS: Record<string, AiProviderRunFn<any, any, HfInferenceModelConfig>> = {\n TextGenerationTask: HFI_TextGeneration,\n TextEmbeddingTask: HFI_TextEmbedding,\n TextRewriterTask: HFI_TextRewriter,\n TextSummaryTask: HFI_TextSummary,\n};\n\nexport const HFI_STREAM_TASKS: Record<\n string,\n AiProviderStreamFn<any, any, HfInferenceModelConfig>\n> = {\n TextGenerationTask: HFI_TextGeneration_Stream,\n TextRewriterTask: HFI_TextRewriter_Stream,\n TextSummaryTask: HFI_TextSummary_Stream,\n};\n",
|
|
6
|
+
"/**\n * @license\n * Copyright 2025 Steven Roussey <sroussey@gmail.com>\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport { globalServiceRegistry, parentPort, WORKER_SERVER } from \"@workglow/util\";\nimport { HFI_STREAM_TASKS, HFI_TASKS } from \"./common/HFI_JobRunFns\";\nimport { HfInferenceProvider } from \"./HfInferenceProvider\";\n\nexport function HFI_WORKER_JOBRUN_REGISTER() {\n const workerServer = globalServiceRegistry.get(WORKER_SERVER);\n new HfInferenceProvider(HFI_TASKS, HFI_STREAM_TASKS).registerOnWorkerServer(workerServer);\n parentPort.postMessage({ type: \"ready\" });\n console.log(\"HFI_WORKER_JOBRUN registered\");\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";;;;;;;;;;;AAsBA,IAAI;AACJ,eAAe,kBAAkB,GAAG;AAAA,EAClC,IAAI,CAAC,MAAM;AAAA,IACT,IAAI;AAAA,MACF,OAAO,MAAa;AAAA,MACpB,MAAM;AAAA,MACN,MAAM,IAAI,MACR,sHACF;AAAA;AAAA,EAEJ;AAAA,EACA,OAAO;AAAA;AAGT,eAAe,SAAS,CAAC,OAA2C;AAAA,EAClE,MAAM,MAAM,MAAM,mBAAmB;AAAA,EACrC,MAAM,SACJ,OAAO,iBAAiB,YACvB,OAAO,YAAY,cAAc,QAAQ,KAAK,WAAW;AAAA,EAC5D,IAAI,CAAC,QAAQ;AAAA,IACX,MAAM,IAAI,MACR,iGACF;AAAA,EACF;AAAA,EACA,OAAO,IAAI,IAAI,gBAAgB,MAAM;AAAA;AAGvC,SAAS,YAAY,CAAC,OAAmD;AAAA,EACvE,MAAM,OAAO,OAAO,iBAAiB;AAAA,EACrC,IAAI,CAAC,MAAM;AAAA,IACT,MAAM,IAAI,MAAM,mDAAmD;AAAA,EACrE;AAAA,EACA,OAAO;AAAA;AAGT,SAAS,WAAW,CAClB,OACuC;AAAA,EACvC,OAAO,OAAO,iBAAiB;AAAA;AAG1B,IAAM,qBAIT,OAAO,OAAO,OAAO,iBAAiB,WAAW;AAAA,EACnD,gBAAgB,GAAG,uCAAuC;AAAA,EAC1D,MAAM,SAAS,MAAM,UAAU,KAAK;AAAA,EACpC,MAAM,YAAY,aAAa,KAAK;AAAA,EACpC,MAAM,WAAW,YAAY,KAAK;AAAA,EAElC,MAAM,WAAW,MAAM,OAAO,eAC5B;AAAA,IACE,OAAO;AAAA,IACP,UAAU,CAAC,EAAE,MAAM,QAAQ,SAAS,MAAM,OAAO,CAAC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C;AAAA,MACrE,EAAE,MAAM,QAAQ,SAAS,MAAM,KAAK;AAAA,IACtC;AAAA,IACA;AAAA,EACF,GACA,EAAE,OAAO,CACX;AAAA,EAEA,iBAAiB,SAAS,QAAQ;AAAA,IAChC,MAAM,QAAQ,MAAM,QAAQ,IAAI,OAAO,WAAW;AAAA,IAClD,IAAI,OAAO;AAAA,MACT,MAAM,EAAE,MAAM,cAAc,MAAM,QAAQ,WAAW,MAAM;AAAA,IAC7D;AAAA,EACF;AAAA,EACA,MAAM,EAAE,MAAM,UAAU,MAAM,CAAC,EAA2B;AAAA;AAOrD,IAAM,YAA+E;AAAA,EAC1F,oBAAoB;AAAA,EACpB,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,iBAAiB;AACnB;AAEO,IAAM,mBAGT;AAAA,EACF,oBAAoB;AAAA,EACpB,kBAAkB;AAAA,EAClB,iBAAiB;AACnB;;ACjSA;AAIO,SAAS,0BAA0B,GAAG;AAAA,EAC3C,MAAM,eAAe,sBAAsB,IAAI,aAAa;AAAA,EAC5D,IAAI,oBAAoB,WAAW,gBAAgB,EAAE,uBAAuB,YAAY;AAAA,EACxF,WAAW,YAAY,EAAE,MAAM,QAAQ,CAAC;AAAA,EACxC,QAAQ,IAAI,8BAA8B;AAAA;",
|
|
9
|
+
"debugId": "3C4381563BACDED064756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { AiProvider, type AiProviderRunFn, type AiProviderStreamFn } from "@workglow/ai";
|
|
7
|
+
import type { LlamaCppModelConfig } from "./common/LlamaCpp_ModelSchema";
|
|
8
|
+
/**
|
|
9
|
+
* AI provider for running GGUF models locally via node-llama-cpp.
|
|
10
|
+
*
|
|
11
|
+
* Supports model downloading, unloading, text generation, text embedding,
|
|
12
|
+
* text rewriting, and text summarization using llama.cpp under the hood.
|
|
13
|
+
*
|
|
14
|
+
* This provider is server-side only (Node.js/Bun) — it requires native binaries
|
|
15
|
+
* and cannot run in the browser.
|
|
16
|
+
*
|
|
17
|
+
* Models are cached in memory after the first load. Use UnloadModelTask to
|
|
18
|
+
* release memory when a model is no longer needed.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Inline mode:
|
|
23
|
+
* import { LLAMACPP_TASKS, LLAMACPP_STREAM_TASKS } from "@workglow/ai-provider/llamacpp";
|
|
24
|
+
* await new LlamaCppProvider(LLAMACPP_TASKS, LLAMACPP_STREAM_TASKS).register({ mode: "inline" });
|
|
25
|
+
*
|
|
26
|
+
* // Worker mode (main thread) -- lightweight, no SDK import:
|
|
27
|
+
* await new LlamaCppProvider().register({
|
|
28
|
+
* mode: "worker",
|
|
29
|
+
* worker: new Worker(new URL("./worker_llamacpp.ts", import.meta.url), { type: "module" }),
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class LlamaCppProvider extends AiProvider<LlamaCppModelConfig> {
|
|
34
|
+
readonly name = "LOCAL_LLAMACPP";
|
|
35
|
+
readonly taskTypes: readonly ["DownloadModelTask", "UnloadModelTask", "TextGenerationTask", "TextEmbeddingTask", "TextRewriterTask", "TextSummaryTask"];
|
|
36
|
+
constructor(tasks?: Record<string, AiProviderRunFn<any, any, LlamaCppModelConfig>>, streamTasks?: Record<string, AiProviderStreamFn<any, any, LlamaCppModelConfig>>);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=LlamaCppProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LlamaCppProvider.d.ts","sourceRoot":"","sources":["../../src/provider-llamacpp/LlamaCppProvider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAEzF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,gBAAiB,SAAQ,UAAU,CAAC,mBAAmB,CAAC;IACnE,QAAQ,CAAC,IAAI,oBAAkB;IAE/B,QAAQ,CAAC,SAAS,sIAOP;gBAGT,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAAC,EACtE,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAAC;CAIlF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LlamaCpp_Worker.d.ts","sourceRoot":"","sources":["../../src/provider-llamacpp/LlamaCpp_Worker.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH,wBAAgB,+BAA+B,SAK9C"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export declare const LOCAL_LLAMACPP = "LOCAL_LLAMACPP";
|
|
7
|
+
export declare const LLAMACPP_DEFAULT_MODELS_DIR = "./models";
|
|
8
|
+
//# sourceMappingURL=LlamaCpp_Constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LlamaCpp_Constants.d.ts","sourceRoot":"","sources":["../../../src/provider-llamacpp/common/LlamaCpp_Constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,cAAc,mBAAmB,CAAC;AAC/C,eAAO,MAAM,2BAA2B,aAAa,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AiProviderRunFn, AiProviderStreamFn, DownloadModelTaskRunInput, DownloadModelTaskRunOutput, TextEmbeddingTaskInput, TextEmbeddingTaskOutput, TextGenerationTaskInput, TextGenerationTaskOutput, TextRewriterTaskInput, TextRewriterTaskOutput, TextSummaryTaskInput, TextSummaryTaskOutput, UnloadModelTaskRunInput, UnloadModelTaskRunOutput } from "@workglow/ai";
|
|
7
|
+
import type { LlamaCppModelConfig } from "./LlamaCpp_ModelSchema";
|
|
8
|
+
export declare const LlamaCpp_Download: AiProviderRunFn<DownloadModelTaskRunInput, DownloadModelTaskRunOutput, LlamaCppModelConfig>;
|
|
9
|
+
export declare const LlamaCpp_Unload: AiProviderRunFn<UnloadModelTaskRunInput, UnloadModelTaskRunOutput, LlamaCppModelConfig>;
|
|
10
|
+
export declare const LlamaCpp_TextGeneration: AiProviderRunFn<TextGenerationTaskInput, TextGenerationTaskOutput, LlamaCppModelConfig>;
|
|
11
|
+
export declare const LlamaCpp_TextGeneration_Stream: AiProviderStreamFn<TextGenerationTaskInput, TextGenerationTaskOutput, LlamaCppModelConfig>;
|
|
12
|
+
export declare const LlamaCpp_TextEmbedding: AiProviderRunFn<TextEmbeddingTaskInput, TextEmbeddingTaskOutput, LlamaCppModelConfig>;
|
|
13
|
+
export declare const LlamaCpp_TextRewriter: AiProviderRunFn<TextRewriterTaskInput, TextRewriterTaskOutput, LlamaCppModelConfig>;
|
|
14
|
+
export declare const LlamaCpp_TextRewriter_Stream: AiProviderStreamFn<TextRewriterTaskInput, TextRewriterTaskOutput, LlamaCppModelConfig>;
|
|
15
|
+
export declare const LlamaCpp_TextSummary: AiProviderRunFn<TextSummaryTaskInput, TextSummaryTaskOutput, LlamaCppModelConfig>;
|
|
16
|
+
export declare const LlamaCpp_TextSummary_Stream: AiProviderStreamFn<TextSummaryTaskInput, TextSummaryTaskOutput, LlamaCppModelConfig>;
|
|
17
|
+
export declare function disposeLlamaCppResources(): Promise<void>;
|
|
18
|
+
export declare const LLAMACPP_TASKS: Record<string, AiProviderRunFn<any, any, LlamaCppModelConfig>>;
|
|
19
|
+
export declare const LLAMACPP_STREAM_TASKS: Record<string, AiProviderStreamFn<any, any, LlamaCppModelConfig>>;
|
|
20
|
+
//# sourceMappingURL=LlamaCpp_JobRunFns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LlamaCpp_JobRunFns.d.ts","sourceRoot":"","sources":["../../../src/provider-llamacpp/common/LlamaCpp_JobRunFns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAClB,yBAAyB,EACzB,0BAA0B,EAC1B,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,cAAc,CAAC;AAGtB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AA2KlE,eAAO,MAAM,iBAAiB,EAAE,eAAe,CAC7C,yBAAyB,EACzB,0BAA0B,EAC1B,mBAAmB,CAoCpB,CAAC;AAMF,eAAO,MAAM,eAAe,EAAE,eAAe,CAC3C,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,CAiCpB,CAAC;AAMF,eAAO,MAAM,uBAAuB,EAAE,eAAe,CACnD,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,CAwBpB,CAAC;AAMF,eAAO,MAAM,8BAA8B,EAAE,kBAAkB,CAC7D,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,CAsBpB,CAAC;AAMF,eAAO,MAAM,sBAAsB,EAAE,eAAe,CAClD,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,CAoBpB,CAAC;AAMF,eAAO,MAAM,qBAAqB,EAAE,eAAe,CACjD,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,CAmBpB,CAAC;AAMF,eAAO,MAAM,4BAA4B,EAAE,kBAAkB,CAC3D,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,CAgBpB,CAAC;AAMF,eAAO,MAAM,oBAAoB,EAAE,eAAe,CAChD,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,CAsBpB,CAAC;AAMF,eAAO,MAAM,2BAA2B,EAAE,kBAAkB,CAC1D,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,CAmBpB,CAAC;AAMF,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkB9D;AAMD,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAOzF,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,MAAM,CACxC,MAAM,EACN,kBAAkB,CAAC,GAAG,EAAE,GAAG,EAAE,mBAAmB,CAAC,CAKlD,CAAC"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { FromSchema } from "@workglow/util";
|
|
7
|
+
export declare const LlamaCppModelSchema: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly provider: {
|
|
11
|
+
readonly const: "LOCAL_LLAMACPP";
|
|
12
|
+
readonly description: "Discriminator: local node-llama-cpp (GGUF) model.";
|
|
13
|
+
};
|
|
14
|
+
readonly provider_config: {
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
readonly description: "node-llama-cpp specific configuration.";
|
|
17
|
+
readonly properties: {
|
|
18
|
+
readonly model_path: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: "Filesystem path to the .gguf model file.";
|
|
21
|
+
};
|
|
22
|
+
readonly model_url: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "URI or URL to download the model from (e.g. 'hf:user/repo:quant' or an https URL). Used by DownloadModelTask.";
|
|
25
|
+
};
|
|
26
|
+
readonly models_dir: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly description: "Directory to download models into.";
|
|
29
|
+
readonly default: "./models";
|
|
30
|
+
};
|
|
31
|
+
readonly gpu_layers: {
|
|
32
|
+
readonly type: "integer";
|
|
33
|
+
readonly description: "Number of model layers to offload to GPU. Use -1 for auto-detection.";
|
|
34
|
+
readonly minimum: -1;
|
|
35
|
+
};
|
|
36
|
+
readonly context_size: {
|
|
37
|
+
readonly type: "integer";
|
|
38
|
+
readonly description: "Context window size in tokens.";
|
|
39
|
+
readonly minimum: 1;
|
|
40
|
+
};
|
|
41
|
+
readonly flash_attention: {
|
|
42
|
+
readonly type: "boolean";
|
|
43
|
+
readonly description: "Enable flash attention for improved performance where supported.";
|
|
44
|
+
readonly default: true;
|
|
45
|
+
};
|
|
46
|
+
readonly embedding: {
|
|
47
|
+
readonly type: "boolean";
|
|
48
|
+
readonly description: "Whether this model is used for text embedding (vs text generation).";
|
|
49
|
+
readonly default: false;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
readonly required: readonly ["model_path"];
|
|
53
|
+
readonly additionalProperties: false;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
readonly required: readonly ["provider", "provider_config"];
|
|
57
|
+
readonly additionalProperties: true;
|
|
58
|
+
};
|
|
59
|
+
export declare const LlamaCppModelRecordSchema: {
|
|
60
|
+
readonly type: "object";
|
|
61
|
+
readonly properties: {
|
|
62
|
+
readonly provider: {
|
|
63
|
+
readonly const: "LOCAL_LLAMACPP";
|
|
64
|
+
readonly description: "Discriminator: local node-llama-cpp (GGUF) model.";
|
|
65
|
+
};
|
|
66
|
+
readonly provider_config: {
|
|
67
|
+
readonly type: "object";
|
|
68
|
+
readonly description: "node-llama-cpp specific configuration.";
|
|
69
|
+
readonly properties: {
|
|
70
|
+
readonly model_path: {
|
|
71
|
+
readonly type: "string";
|
|
72
|
+
readonly description: "Filesystem path to the .gguf model file.";
|
|
73
|
+
};
|
|
74
|
+
readonly model_url: {
|
|
75
|
+
readonly type: "string";
|
|
76
|
+
readonly description: "URI or URL to download the model from (e.g. 'hf:user/repo:quant' or an https URL). Used by DownloadModelTask.";
|
|
77
|
+
};
|
|
78
|
+
readonly models_dir: {
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
readonly description: "Directory to download models into.";
|
|
81
|
+
readonly default: "./models";
|
|
82
|
+
};
|
|
83
|
+
readonly gpu_layers: {
|
|
84
|
+
readonly type: "integer";
|
|
85
|
+
readonly description: "Number of model layers to offload to GPU. Use -1 for auto-detection.";
|
|
86
|
+
readonly minimum: -1;
|
|
87
|
+
};
|
|
88
|
+
readonly context_size: {
|
|
89
|
+
readonly type: "integer";
|
|
90
|
+
readonly description: "Context window size in tokens.";
|
|
91
|
+
readonly minimum: 1;
|
|
92
|
+
};
|
|
93
|
+
readonly flash_attention: {
|
|
94
|
+
readonly type: "boolean";
|
|
95
|
+
readonly description: "Enable flash attention for improved performance where supported.";
|
|
96
|
+
readonly default: true;
|
|
97
|
+
};
|
|
98
|
+
readonly embedding: {
|
|
99
|
+
readonly type: "boolean";
|
|
100
|
+
readonly description: "Whether this model is used for text embedding (vs text generation).";
|
|
101
|
+
readonly default: false;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
readonly required: readonly ["model_path"];
|
|
105
|
+
readonly additionalProperties: false;
|
|
106
|
+
};
|
|
107
|
+
readonly model_id: {
|
|
108
|
+
readonly type: "string";
|
|
109
|
+
};
|
|
110
|
+
readonly tasks: {
|
|
111
|
+
readonly type: "array";
|
|
112
|
+
readonly items: {
|
|
113
|
+
readonly type: "string";
|
|
114
|
+
};
|
|
115
|
+
readonly "x-ui-editor": "multiselect";
|
|
116
|
+
};
|
|
117
|
+
readonly title: {
|
|
118
|
+
readonly type: "string";
|
|
119
|
+
};
|
|
120
|
+
readonly description: {
|
|
121
|
+
readonly type: "string";
|
|
122
|
+
readonly "x-ui-editor": "textarea";
|
|
123
|
+
};
|
|
124
|
+
readonly metadata: {
|
|
125
|
+
readonly type: "object";
|
|
126
|
+
readonly default: {};
|
|
127
|
+
readonly "x-ui-hidden": true;
|
|
128
|
+
};
|
|
129
|
+
};
|
|
130
|
+
readonly required: readonly ["model_id", "tasks", "provider", "title", "description", "provider_config", "metadata", "provider", "provider_config"];
|
|
131
|
+
readonly additionalProperties: false;
|
|
132
|
+
};
|
|
133
|
+
export type LlamaCppModelRecord = FromSchema<typeof LlamaCppModelRecordSchema>;
|
|
134
|
+
export declare const LlamaCppModelConfigSchema: {
|
|
135
|
+
readonly type: "object";
|
|
136
|
+
readonly properties: {
|
|
137
|
+
readonly provider: {
|
|
138
|
+
readonly const: "LOCAL_LLAMACPP";
|
|
139
|
+
readonly description: "Discriminator: local node-llama-cpp (GGUF) model.";
|
|
140
|
+
};
|
|
141
|
+
readonly provider_config: {
|
|
142
|
+
readonly type: "object";
|
|
143
|
+
readonly description: "node-llama-cpp specific configuration.";
|
|
144
|
+
readonly properties: {
|
|
145
|
+
readonly model_path: {
|
|
146
|
+
readonly type: "string";
|
|
147
|
+
readonly description: "Filesystem path to the .gguf model file.";
|
|
148
|
+
};
|
|
149
|
+
readonly model_url: {
|
|
150
|
+
readonly type: "string";
|
|
151
|
+
readonly description: "URI or URL to download the model from (e.g. 'hf:user/repo:quant' or an https URL). Used by DownloadModelTask.";
|
|
152
|
+
};
|
|
153
|
+
readonly models_dir: {
|
|
154
|
+
readonly type: "string";
|
|
155
|
+
readonly description: "Directory to download models into.";
|
|
156
|
+
readonly default: "./models";
|
|
157
|
+
};
|
|
158
|
+
readonly gpu_layers: {
|
|
159
|
+
readonly type: "integer";
|
|
160
|
+
readonly description: "Number of model layers to offload to GPU. Use -1 for auto-detection.";
|
|
161
|
+
readonly minimum: -1;
|
|
162
|
+
};
|
|
163
|
+
readonly context_size: {
|
|
164
|
+
readonly type: "integer";
|
|
165
|
+
readonly description: "Context window size in tokens.";
|
|
166
|
+
readonly minimum: 1;
|
|
167
|
+
};
|
|
168
|
+
readonly flash_attention: {
|
|
169
|
+
readonly type: "boolean";
|
|
170
|
+
readonly description: "Enable flash attention for improved performance where supported.";
|
|
171
|
+
readonly default: true;
|
|
172
|
+
};
|
|
173
|
+
readonly embedding: {
|
|
174
|
+
readonly type: "boolean";
|
|
175
|
+
readonly description: "Whether this model is used for text embedding (vs text generation).";
|
|
176
|
+
readonly default: false;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
readonly required: readonly ["model_path"];
|
|
180
|
+
readonly additionalProperties: false;
|
|
181
|
+
};
|
|
182
|
+
readonly model_id: {
|
|
183
|
+
readonly type: "string";
|
|
184
|
+
};
|
|
185
|
+
readonly tasks: {
|
|
186
|
+
readonly type: "array";
|
|
187
|
+
readonly items: {
|
|
188
|
+
readonly type: "string";
|
|
189
|
+
};
|
|
190
|
+
readonly "x-ui-editor": "multiselect";
|
|
191
|
+
};
|
|
192
|
+
readonly title: {
|
|
193
|
+
readonly type: "string";
|
|
194
|
+
};
|
|
195
|
+
readonly description: {
|
|
196
|
+
readonly type: "string";
|
|
197
|
+
readonly "x-ui-editor": "textarea";
|
|
198
|
+
};
|
|
199
|
+
readonly metadata: {
|
|
200
|
+
readonly type: "object";
|
|
201
|
+
readonly default: {};
|
|
202
|
+
readonly "x-ui-hidden": true;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
readonly required: readonly ["provider", "provider_config", "provider", "provider_config"];
|
|
206
|
+
readonly additionalProperties: false;
|
|
207
|
+
};
|
|
208
|
+
export type LlamaCppModelConfig = FromSchema<typeof LlamaCppModelConfigSchema>;
|
|
209
|
+
//# sourceMappingURL=LlamaCpp_ModelSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LlamaCpp_ModelSchema.d.ts","sourceRoot":"","sources":["../../../src/provider-llamacpp/common/LlamaCpp_ModelSchema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAwB,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGlE,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDS,CAAC;AAE1C,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQG,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE/E,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAQG,CAAC;AAE1C,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2025 Steven Roussey <sroussey@gmail.com>
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
export * from "./common/LlamaCpp_Constants";
|
|
7
|
+
export * from "./common/LlamaCpp_JobRunFns";
|
|
8
|
+
export * from "./common/LlamaCpp_ModelSchema";
|
|
9
|
+
export * from "./LlamaCpp_Worker";
|
|
10
|
+
export * from "./LlamaCppProvider";
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider-llamacpp/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,6BAA6B,CAAC;AAC5C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}
|