veryfront 0.1.13 → 0.1.14
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/esm/cli/app/data/slug-words.d.ts.map +1 -1
- package/esm/cli/app/data/slug-words.js +225 -90
- package/esm/cli/app/operations/project-creation.js +4 -3
- package/esm/cli/app/shell.js +1 -1
- package/esm/cli/app/utils.d.ts +5 -4
- package/esm/cli/app/utils.d.ts.map +1 -1
- package/esm/cli/app/utils.js +0 -23
- package/esm/cli/app/views/dashboard.d.ts +1 -1
- package/esm/cli/app/views/dashboard.d.ts.map +1 -1
- package/esm/cli/app/views/dashboard.js +22 -4
- package/esm/cli/auth/callback-server.d.ts.map +1 -1
- package/esm/cli/auth/callback-server.js +3 -2
- package/esm/cli/commands/dev/handler.d.ts.map +1 -1
- package/esm/cli/commands/dev/handler.js +2 -0
- package/esm/cli/commands/init/init-command.d.ts.map +1 -1
- package/esm/cli/commands/init/init-command.js +20 -3
- package/esm/cli/commands/init/interactive-wizard.d.ts +3 -2
- package/esm/cli/commands/init/interactive-wizard.d.ts.map +1 -1
- package/esm/cli/commands/init/interactive-wizard.js +55 -27
- package/esm/cli/mcp/remote-file-tools.d.ts +0 -6
- package/esm/cli/mcp/remote-file-tools.d.ts.map +1 -1
- package/esm/cli/mcp/remote-file-tools.js +37 -15
- package/esm/cli/shared/reserve-slug.d.ts.map +1 -1
- package/esm/cli/shared/reserve-slug.js +8 -3
- package/esm/cli/utils/env-prompt.d.ts.map +1 -1
- package/esm/cli/utils/env-prompt.js +3 -0
- package/esm/deno.d.ts +2 -1
- package/esm/deno.js +8 -4
- package/esm/src/agent/chat-handler.d.ts +4 -3
- package/esm/src/agent/chat-handler.d.ts.map +1 -1
- package/esm/src/agent/chat-handler.js +55 -4
- package/esm/src/agent/react/index.d.ts +1 -1
- package/esm/src/agent/react/index.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/browser-inference/browser-engine.d.ts +18 -0
- package/esm/src/agent/react/use-chat/browser-inference/browser-engine.d.ts.map +1 -0
- package/esm/src/agent/react/use-chat/browser-inference/browser-engine.js +54 -0
- package/esm/src/agent/react/use-chat/browser-inference/types.d.ts +43 -0
- package/esm/src/agent/react/use-chat/browser-inference/types.d.ts.map +1 -0
- package/esm/src/agent/react/use-chat/browser-inference/types.js +4 -0
- package/esm/src/agent/react/use-chat/browser-inference/worker-client.d.ts +23 -0
- package/esm/src/agent/react/use-chat/browser-inference/worker-client.d.ts.map +1 -0
- package/esm/src/agent/react/use-chat/browser-inference/worker-client.js +67 -0
- package/esm/src/agent/react/use-chat/browser-inference/worker-script.d.ts +8 -0
- package/esm/src/agent/react/use-chat/browser-inference/worker-script.d.ts.map +1 -0
- package/esm/src/agent/react/use-chat/browser-inference/worker-script.js +97 -0
- package/esm/src/agent/react/use-chat/index.d.ts +1 -1
- package/esm/src/agent/react/use-chat/index.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/types.d.ts +12 -0
- package/esm/src/agent/react/use-chat/types.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/use-chat.d.ts.map +1 -1
- package/esm/src/agent/react/use-chat/use-chat.js +120 -6
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +59 -7
- package/esm/src/build/production-build/templates.d.ts +2 -2
- package/esm/src/build/production-build/templates.d.ts.map +1 -1
- package/esm/src/build/production-build/templates.js +2 -68
- package/esm/src/chat/index.d.ts +1 -1
- package/esm/src/chat/index.d.ts.map +1 -1
- package/esm/src/errors/veryfront-error.d.ts +3 -0
- package/esm/src/errors/veryfront-error.d.ts.map +1 -1
- package/esm/src/platform/adapters/runtime/deno/adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/runtime/deno/adapter.js +5 -1
- package/esm/src/platform/compat/http/deno-server.d.ts.map +1 -1
- package/esm/src/platform/compat/http/deno-server.js +3 -2
- package/esm/src/provider/index.d.ts +1 -1
- package/esm/src/provider/index.d.ts.map +1 -1
- package/esm/src/provider/index.js +1 -1
- package/esm/src/provider/local/ai-sdk-adapter.d.ts +19 -0
- package/esm/src/provider/local/ai-sdk-adapter.d.ts.map +1 -0
- package/esm/src/provider/local/ai-sdk-adapter.js +164 -0
- package/esm/src/provider/local/env.d.ts +10 -0
- package/esm/src/provider/local/env.d.ts.map +1 -0
- package/esm/src/provider/local/env.js +23 -0
- package/esm/src/provider/local/local-engine.d.ts +61 -0
- package/esm/src/provider/local/local-engine.d.ts.map +1 -0
- package/esm/src/provider/local/local-engine.js +211 -0
- package/esm/src/provider/local/model-catalog.d.ts +30 -0
- package/esm/src/provider/local/model-catalog.d.ts.map +1 -0
- package/esm/src/provider/local/model-catalog.js +58 -0
- package/esm/src/provider/model-registry.d.ts +14 -0
- package/esm/src/provider/model-registry.d.ts.map +1 -1
- package/esm/src/provider/model-registry.js +58 -2
- package/esm/src/proxy/main.js +34 -6
- package/esm/src/proxy/server-resolver.d.ts +23 -0
- package/esm/src/proxy/server-resolver.d.ts.map +1 -0
- package/esm/src/proxy/server-resolver.js +124 -0
- package/esm/src/react/components/ai/chat/components/inference-badge.d.ts +8 -0
- package/esm/src/react/components/ai/chat/components/inference-badge.d.ts.map +1 -0
- package/esm/src/react/components/ai/chat/components/inference-badge.js +36 -0
- package/esm/src/react/components/ai/chat/components/upgrade-cta.d.ts +7 -0
- package/esm/src/react/components/ai/chat/components/upgrade-cta.d.ts.map +1 -0
- package/esm/src/react/components/ai/chat/components/upgrade-cta.js +33 -0
- package/esm/src/react/components/ai/chat/index.d.ts +7 -1
- package/esm/src/react/components/ai/chat/index.d.ts.map +1 -1
- package/esm/src/react/components/ai/chat/index.js +16 -4
- package/package.json +5 -1
- package/src/cli/app/data/slug-words.ts +225 -90
- package/src/cli/app/operations/project-creation.ts +3 -3
- package/src/cli/app/shell.ts +1 -1
- package/src/cli/app/utils.ts +0 -30
- package/src/cli/app/views/dashboard.ts +27 -4
- package/src/cli/auth/callback-server.ts +3 -2
- package/src/cli/commands/dev/handler.ts +2 -0
- package/src/cli/commands/init/init-command.ts +30 -3
- package/src/cli/commands/init/interactive-wizard.ts +62 -34
- package/src/cli/mcp/remote-file-tools.ts +50 -15
- package/src/cli/shared/reserve-slug.ts +9 -2
- package/src/cli/utils/env-prompt.ts +3 -0
- package/src/deno.js +8 -4
- package/src/src/agent/chat-handler.ts +57 -4
- package/src/src/agent/react/index.ts +2 -0
- package/src/src/agent/react/use-chat/browser-inference/browser-engine.ts +81 -0
- package/src/src/agent/react/use-chat/browser-inference/types.ts +52 -0
- package/src/src/agent/react/use-chat/browser-inference/worker-client.ts +89 -0
- package/src/src/agent/react/use-chat/browser-inference/worker-script.ts +98 -0
- package/src/src/agent/react/use-chat/index.ts +2 -0
- package/src/src/agent/react/use-chat/types.ts +20 -0
- package/src/src/agent/react/use-chat/use-chat.ts +148 -8
- package/src/src/agent/runtime/index.ts +72 -6
- package/src/src/build/production-build/templates.ts +2 -68
- package/src/src/chat/index.ts +2 -0
- package/src/src/errors/veryfront-error.ts +2 -1
- package/src/src/platform/adapters/runtime/deno/adapter.ts +5 -1
- package/src/src/platform/compat/http/deno-server.ts +3 -1
- package/src/src/provider/index.ts +1 -0
- package/src/src/provider/local/ai-sdk-adapter.ts +207 -0
- package/src/src/provider/local/env.ts +26 -0
- package/src/src/provider/local/local-engine.ts +288 -0
- package/src/src/provider/local/model-catalog.ts +73 -0
- package/src/src/provider/model-registry.ts +66 -2
- package/src/src/proxy/main.ts +41 -6
- package/src/src/proxy/server-resolver.ts +151 -0
- package/src/src/react/components/ai/chat/components/inference-badge.tsx +48 -0
- package/src/src/react/components/ai/chat/components/upgrade-cta.tsx +56 -0
- package/src/src/react/components/ai/chat/index.tsx +43 -6
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @module ai/agent/runtime
|
|
12
12
|
*/
|
|
13
13
|
import { getTextFromParts, } from "../types.js";
|
|
14
|
-
import { resolveModel } from "../../provider/index.js";
|
|
14
|
+
import { ensureModelReady, resolveModel } from "../../provider/index.js";
|
|
15
15
|
import { executeTool } from "../../tool/index.js";
|
|
16
16
|
import { generateId } from "../../utils/id.js";
|
|
17
17
|
import { detectPlatform, getPlatformCapabilities } from "../../platform/core-platform.js";
|
|
@@ -34,6 +34,23 @@ import { generateMessageId, sendSSE } from "./sse-utils.js";
|
|
|
34
34
|
import { getAvailableTools, isDynamicTool, parseToolArgs } from "./tool-helpers.js";
|
|
35
35
|
import { accumulateUsage, getMaxSteps, normalizeInput } from "./input-utils.js";
|
|
36
36
|
const logger = serverLogger.component("agent");
|
|
37
|
+
/**
|
|
38
|
+
* Detect whether the resolved model is local inference.
|
|
39
|
+
* Handles both explicit "local/*" requests and cloud->local auto-fallback.
|
|
40
|
+
*/
|
|
41
|
+
function isLocalInferenceModel(model, requestedModel) {
|
|
42
|
+
if (requestedModel.startsWith("local/"))
|
|
43
|
+
return true;
|
|
44
|
+
// LanguageModel is a union that includes string, so we need to narrow first
|
|
45
|
+
if (typeof model === "string")
|
|
46
|
+
return model.startsWith("local/");
|
|
47
|
+
if ("provider" in model && model.provider === "local")
|
|
48
|
+
return true;
|
|
49
|
+
if ("modelId" in model && typeof model.modelId === "string" && model.modelId.startsWith("local/")) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
37
54
|
export class AgentRuntime {
|
|
38
55
|
id;
|
|
39
56
|
config;
|
|
@@ -77,6 +94,7 @@ export class AgentRuntime {
|
|
|
77
94
|
*/
|
|
78
95
|
async stream(messages, context, callbacks, modelOverride) {
|
|
79
96
|
const modelString = modelOverride || this.config.model;
|
|
97
|
+
const requestedModel = modelString || this.config.model;
|
|
80
98
|
for (const msg of messages)
|
|
81
99
|
await this.memory.add(msg);
|
|
82
100
|
const memoryMessages = await this.memory.getMessages();
|
|
@@ -84,14 +102,32 @@ export class AgentRuntime {
|
|
|
84
102
|
const encoder = new TextEncoder();
|
|
85
103
|
const toolContext = { agentId: this.id, ...context };
|
|
86
104
|
const textPartId = generateId("text");
|
|
105
|
+
// Resolve model BEFORE creating the ReadableStream — if this throws
|
|
106
|
+
// (e.g., no_ai_available), the error propagates to the caller who can
|
|
107
|
+
// return a proper error response (503) instead of a 200 with an error event.
|
|
108
|
+
const languageModel = resolveModel(requestedModel);
|
|
109
|
+
// Eagerly verify the model runtime is available. For local models this
|
|
110
|
+
// checks that @huggingface/transformers can be imported. Must happen
|
|
111
|
+
// BEFORE creating the ReadableStream so no_ai_available errors propagate
|
|
112
|
+
// to the caller (createChatHandler) who returns a 503 with browser fallback
|
|
113
|
+
// info, instead of being swallowed as an in-band SSE error in a 200 response.
|
|
114
|
+
await ensureModelReady(languageModel);
|
|
87
115
|
return new ReadableStream({
|
|
88
116
|
start: async (controller) => {
|
|
89
117
|
try {
|
|
90
118
|
this.status = "streaming";
|
|
91
119
|
const messageId = generateMessageId();
|
|
92
120
|
sendSSE(controller, encoder, { type: "message-start", messageId });
|
|
121
|
+
sendSSE(controller, encoder, {
|
|
122
|
+
type: "data",
|
|
123
|
+
data: {
|
|
124
|
+
inferenceMode: isLocalInferenceModel(languageModel, requestedModel)
|
|
125
|
+
? "server-local"
|
|
126
|
+
: "cloud",
|
|
127
|
+
},
|
|
128
|
+
});
|
|
93
129
|
sendSSE(controller, encoder, { type: "text-start", id: textPartId });
|
|
94
|
-
await this.executeAgentLoopStreaming(systemPrompt, memoryMessages, controller, encoder, callbacks, textPartId, toolContext, modelString);
|
|
130
|
+
await this.executeAgentLoopStreaming(systemPrompt, memoryMessages, controller, encoder, callbacks, textPartId, toolContext, modelString, languageModel);
|
|
95
131
|
sendSSE(controller, encoder, { type: "text-end", id: textPartId });
|
|
96
132
|
sendSSE(controller, encoder, { type: "message-finish" });
|
|
97
133
|
controller.close();
|
|
@@ -114,14 +150,22 @@ export class AgentRuntime {
|
|
|
114
150
|
return withSpan("agent.execution_loop", async (loopSpan) => {
|
|
115
151
|
const { maxAgentSteps } = getPlatformCapabilities();
|
|
116
152
|
const maxSteps = this.computeMaxSteps(maxAgentSteps);
|
|
117
|
-
const
|
|
153
|
+
const requestedModel = modelString || this.config.model;
|
|
154
|
+
const languageModel = resolveModel(requestedModel);
|
|
118
155
|
const toolCalls = [];
|
|
119
156
|
const currentMessages = [...messages];
|
|
120
157
|
const totalUsage = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
158
|
+
// Local models can't reliably do function calling — skip tools gracefully.
|
|
159
|
+
const isLocal = isLocalInferenceModel(languageModel, requestedModel);
|
|
160
|
+
if (isLocal && this.config.tools) {
|
|
161
|
+
logger.warn(`Agent "${this.id}" has tools configured but is using local model "${requestedModel}". ` +
|
|
162
|
+
"Local models don't support tool calling — tools will be skipped. " +
|
|
163
|
+
"Set OPENAI_API_KEY, ANTHROPIC_API_KEY, or GOOGLE_API_KEY for full tool support.");
|
|
164
|
+
}
|
|
121
165
|
for (let step = 0; step < maxSteps; step++) {
|
|
122
166
|
this.status = "thinking";
|
|
123
167
|
addSpanEvent(loopSpan, "step_start", { step });
|
|
124
|
-
const tools = getAvailableTools(this.config.tools);
|
|
168
|
+
const tools = isLocal ? [] : getAvailableTools(this.config.tools);
|
|
125
169
|
const response = await withSpan("agent.generate_text", async (span) => {
|
|
126
170
|
setSpanAttributes(span, {
|
|
127
171
|
"model.id": modelString || this.config.model,
|
|
@@ -252,16 +296,24 @@ export class AgentRuntime {
|
|
|
252
296
|
* Emits veryfront stream events (message-start/message-finish + step-start/step-end)
|
|
253
297
|
* while consuming AI SDK `streamText()` parts internally.
|
|
254
298
|
*/
|
|
255
|
-
async executeAgentLoopStreaming(systemPrompt, messages, controller, encoder, callbacks, textPartId, toolContext, modelString) {
|
|
299
|
+
async executeAgentLoopStreaming(systemPrompt, messages, controller, encoder, callbacks, textPartId, toolContext, modelString, resolvedModel) {
|
|
256
300
|
const { maxAgentSteps } = getPlatformCapabilities();
|
|
257
301
|
const maxSteps = this.computeMaxSteps(maxAgentSteps);
|
|
258
|
-
const
|
|
302
|
+
const requestedModel = modelString || this.config.model;
|
|
303
|
+
const languageModel = resolvedModel ?? resolveModel(requestedModel);
|
|
259
304
|
const toolCalls = [];
|
|
260
305
|
const currentMessages = [...messages];
|
|
261
306
|
const totalUsage = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
|
|
307
|
+
// Local models can't reliably do function calling — skip tools gracefully.
|
|
308
|
+
const isLocalStreaming = isLocalInferenceModel(languageModel, requestedModel);
|
|
309
|
+
if (isLocalStreaming && this.config.tools) {
|
|
310
|
+
logger.warn(`Agent "${this.id}" has tools configured but is using local model "${requestedModel}". ` +
|
|
311
|
+
"Local models don't support tool calling — tools will be skipped. " +
|
|
312
|
+
"Set OPENAI_API_KEY, ANTHROPIC_API_KEY, or GOOGLE_API_KEY for full tool support.");
|
|
313
|
+
}
|
|
262
314
|
for (let step = 0; step < maxSteps; step++) {
|
|
263
315
|
sendSSE(controller, encoder, { type: "step-start" });
|
|
264
|
-
const tools = getAvailableTools(this.config.tools);
|
|
316
|
+
const tools = isLocalStreaming ? [] : getAvailableTools(this.config.tools);
|
|
265
317
|
const result = streamText({
|
|
266
318
|
model: languageModel,
|
|
267
319
|
system: systemPrompt,
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* Client-side CSS styles for
|
|
7
|
+
* Client-side CSS styles for error display in production builds
|
|
8
8
|
*/
|
|
9
|
-
export declare const CLIENT_STYLES = "
|
|
9
|
+
export declare const CLIENT_STYLES = ".error-container {\n max-width: 600px;\n margin: 2rem auto;\n padding: 2rem;\n background: #fee;\n border: 1px solid #fcc;\n border-radius: 8px;\n color: #c00;\n}";
|
|
10
10
|
/**
|
|
11
11
|
* Pre-bundled client router script for npm builds
|
|
12
12
|
* Placeholder - this is auto-generated during build:npm
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/src/build/production-build/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../../../src/src/build/production-build/templates.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;GAEG;AACH,eAAO,MAAM,aAAa,8KAQxB,CAAC;AAEH;;;GAGG;AACH,eAAO,IAAI,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;AAEpD,eAAO,IAAI,sBAAsB,EAAE,MAAM,GAAG,SAAS,CAAC"}
|
|
@@ -4,39 +4,9 @@
|
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
|
-
* Client-side CSS styles for
|
|
7
|
+
* Client-side CSS styles for error display in production builds
|
|
8
8
|
*/
|
|
9
|
-
export const CLIENT_STYLES =
|
|
10
|
-
margin: 0;
|
|
11
|
-
font-family:
|
|
12
|
-
-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
|
13
|
-
line-height: 1.5;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.loading-container {
|
|
17
|
-
display: flex;
|
|
18
|
-
justify-content: center;
|
|
19
|
-
align-items: center;
|
|
20
|
-
min-height: 100vh;
|
|
21
|
-
background: #f9fafb;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
.loading-spinner {
|
|
25
|
-
width: 40px;
|
|
26
|
-
height: 40px;
|
|
27
|
-
border: 3px solid #e5e7eb;
|
|
28
|
-
border-top-color: #3b82f6;
|
|
29
|
-
border-radius: 50%;
|
|
30
|
-
animation: spin 1s linear infinite;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@keyframes spin {
|
|
34
|
-
to {
|
|
35
|
-
transform: rotate(360deg);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
.error-container {
|
|
9
|
+
export const CLIENT_STYLES = `.error-container {
|
|
40
10
|
max-width: 600px;
|
|
41
11
|
margin: 2rem auto;
|
|
42
12
|
padding: 2rem;
|
|
@@ -44,42 +14,6 @@ export const CLIENT_STYLES = `body {
|
|
|
44
14
|
border: 1px solid #fcc;
|
|
45
15
|
border-radius: 8px;
|
|
46
16
|
color: #c00;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.prose {
|
|
50
|
-
max-width: 65ch;
|
|
51
|
-
margin: 0 auto;
|
|
52
|
-
padding: 2rem;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.prose h1, .prose h2, .prose h3 {
|
|
56
|
-
margin-top: 2em;
|
|
57
|
-
margin-bottom: 1em;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
.prose p {
|
|
61
|
-
margin-bottom: 1.5em;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
.prose code {
|
|
65
|
-
background: #f3f4f6;
|
|
66
|
-
padding: 0.2em 0.4em;
|
|
67
|
-
border-radius: 3px;
|
|
68
|
-
font-size: 0.875em;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
.prose pre {
|
|
72
|
-
background: #1f2937;
|
|
73
|
-
color: #f9fafb;
|
|
74
|
-
padding: 1em;
|
|
75
|
-
border-radius: 8px;
|
|
76
|
-
overflow-x: auto;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.prose pre code {
|
|
80
|
-
background: transparent;
|
|
81
|
-
padding: 0;
|
|
82
|
-
color: inherit;
|
|
83
17
|
}`;
|
|
84
18
|
/**
|
|
85
19
|
* Pre-bundled client router script for npm builds
|
package/esm/src/chat/index.d.ts
CHANGED
|
@@ -55,7 +55,7 @@ export { AIErrorBoundary, useAIErrorHandler, } from "../react/components/ai/erro
|
|
|
55
55
|
export type { AIErrorBoundaryProps } from "../react/components/ai/error-boundary.js";
|
|
56
56
|
export type { AgentTheme, ChatTheme } from "../react/components/ai/theme.js";
|
|
57
57
|
export { useChat } from "../agent/react/use-chat/index.js";
|
|
58
|
-
export type { DynamicToolUIPart, OnToolCallArg, ReasoningUIPart, TextUIPart, ToolOutput, ToolResultUIPart, ToolState, ToolUIPart, UIMessage, UIMessagePart, UseChatOptions, UseChatResult, } from "../agent/react/use-chat/index.js";
|
|
58
|
+
export type { BrowserInferenceStatus, DynamicToolUIPart, InferenceMode, OnToolCallArg, ReasoningUIPart, TextUIPart, ToolOutput, ToolResultUIPart, ToolState, ToolUIPart, UIMessage, UIMessagePart, UseChatOptions, UseChatResult, } from "../agent/react/use-chat/index.js";
|
|
59
59
|
export { useAgent } from "../agent/react/use-agent.js";
|
|
60
60
|
export type { UseAgentOptions, UseAgentResult } from "../agent/react/use-agent.js";
|
|
61
61
|
export { useCompletion } from "../agent/react/use-completion.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/chat/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAYH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,IAAI,EACJ,cAAc,EACd,UAAU,EACV,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,GACd,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,SAAS,EACT,WAAW,EACX,kBAAkB,GACnB,MAAM,gCAAgC,CAAC;AAExC,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,YAAY,EACV,YAAY,EACZ,qBAAqB,GACtB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,0CAA0C,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAIrF,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAM7E,OAAO,EAAE,OAAO,EAAE,MAAM,kC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AE,MAAM,sCAAsC,CAAC;AAE3E,OAAO,EACL,eAAe,EACf,iBAAiB,GAClB,MAAM,0CAA0C,CAAC;AAClD,YAAY,EAAE,oBAAoB,EAAE,MAAM,0CAA0C,CAAC;AAIrF,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AAM7E,OAAO,EAAE,OAAO,EAAE,MAAM,kCAAkC,CAAC;AAC3D,YAAY,EACV,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,SAAS,EACT,UAAU,EACV,SAAS,EACT,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,YAAY,EACV,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,mCAAmC,CAAC"}
|
|
@@ -92,6 +92,9 @@ export type VeryfrontErrorData = {
|
|
|
92
92
|
type: "not_supported";
|
|
93
93
|
message: string;
|
|
94
94
|
feature?: string;
|
|
95
|
+
} | {
|
|
96
|
+
type: "no_ai_available";
|
|
97
|
+
message: string;
|
|
95
98
|
};
|
|
96
99
|
export declare function createError(error: VeryfrontErrorData): VeryfrontErrorData;
|
|
97
100
|
export declare const isBuildError: (error: VeryfrontErrorData) => error is {
|
|
@@ -1 +1 @@
|
|
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ACvB,QAAQ,CAAC,EAAE,wBAA+B;IAC1C,QAAQ,CAAC,GAAG,yBAAgC;IAC5C,QAAQ,CAAC,MAAM,oBAA2B;IAC1C,QAAQ,CAAC,KAAK,mBAA0B;IAExC,QAAQ,CAAC,YAAY;;;;;;;;;;MAUnB;IAEF,OAAO,CAAC,YAAY,CAA2B;IAE/C,KAAK,CACH,OAAO,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,QAAQ,EACnF,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,MAAM,CAAC;IAmDZ,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAGhC;AAED,eAAO,MAAM,WAAW,aAAoB,CAAC"}
|
|
@@ -308,7 +308,11 @@ export class DenoAdapter {
|
|
|
308
308
|
return handler(request);
|
|
309
309
|
}
|
|
310
310
|
: handler;
|
|
311
|
-
|
|
311
|
+
// Access native Deno.serve via `self` to bypass dnt shim transform.
|
|
312
|
+
// dnt rewrites both `Deno.*` and `globalThis.*` to use @deno/shim-deno which lacks .serve.
|
|
313
|
+
// `self` is not shimmed by dnt and equals `globalThis` in Deno.
|
|
314
|
+
const nativeDeno = self["Deno"];
|
|
315
|
+
const server = nativeDeno.serve({
|
|
312
316
|
port,
|
|
313
317
|
hostname,
|
|
314
318
|
signal,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deno-server.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/http/deno-server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGpE,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,eAAe,CAAC,CAAkB;IAEpC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"deno-server.d.ts","sourceRoot":"","sources":["../../../../../src/src/platform/compat/http/deno-server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAGpE,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,eAAe,CAAC,CAAkB;IAEpC,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAaxE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAIvB"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as dntShim from "../../../../_dnt.shims.js";
|
|
2
1
|
import { LOCALHOST } from "../constants.js";
|
|
3
2
|
export class DenoHttpServer {
|
|
4
3
|
abortController;
|
|
@@ -7,7 +6,9 @@ export class DenoHttpServer {
|
|
|
7
6
|
this.abortController = new AbortController();
|
|
8
7
|
const serveSignal = signal ?? this.abortController.signal;
|
|
9
8
|
onListen?.({ hostname, port });
|
|
10
|
-
|
|
9
|
+
// Access native Deno.serve via `self` to bypass dnt shim transform.
|
|
10
|
+
const nativeDeno = self["Deno"];
|
|
11
|
+
await nativeDeno.serve({ port, hostname, signal: serveSignal }, handler);
|
|
11
12
|
}
|
|
12
13
|
close() {
|
|
13
14
|
this.abortController?.abort();
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
import "../../_dnt.polyfills.js";
|
|
19
|
-
export { clearModelProviders, getRegisteredModelProviders, hasModelProvider, registerModelProvider, resolveModel, } from "./model-registry.js";
|
|
19
|
+
export { clearModelProviders, ensureModelReady, getRegisteredModelProviders, hasModelProvider, registerModelProvider, resolveModel, } from "./model-registry.js";
|
|
20
20
|
export type { ModelProviderFactory } from "./model-registry.js";
|
|
21
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/provider/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,mBAAmB,EACnB,2BAA2B,EAC3B,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/src/provider/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,yBAAyB,CAAC;AAGjC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAChB,2BAA2B,EAC3B,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -16,4 +16,4 @@
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
import "../../_dnt.polyfills.js";
|
|
19
|
-
export { clearModelProviders, getRegisteredModelProviders, hasModelProvider, registerModelProvider, resolveModel, } from "./model-registry.js";
|
|
19
|
+
export { clearModelProviders, ensureModelReady, getRegisteredModelProviders, hasModelProvider, registerModelProvider, resolveModel, } from "./model-registry.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK Adapter for Local Models
|
|
3
|
+
*
|
|
4
|
+
* Bridges `@huggingface/transformers` local inference to the AI SDK
|
|
5
|
+
* `LanguageModelV2` interface. This allows `streamText()` and
|
|
6
|
+
* `generateText()` to work with local models seamlessly.
|
|
7
|
+
*
|
|
8
|
+
* @module provider/local
|
|
9
|
+
*/
|
|
10
|
+
import type { LanguageModel } from "ai";
|
|
11
|
+
/**
|
|
12
|
+
* Create a local AI SDK LanguageModel for the given model ID.
|
|
13
|
+
*
|
|
14
|
+
* The returned object implements the LanguageModelV2 interface, making it
|
|
15
|
+
* compatible with all AI SDK functions (`streamText`, `generateText`, etc.)
|
|
16
|
+
* and all VeryFront hooks (`useChat`).
|
|
17
|
+
*/
|
|
18
|
+
export declare function createLocalModel(modelId?: string): LanguageModel;
|
|
19
|
+
//# sourceMappingURL=ai-sdk-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai-sdk-adapter.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/local/ai-sdk-adapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AA+CxC;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,aAAa,CA8IhE"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI SDK Adapter for Local Models
|
|
3
|
+
*
|
|
4
|
+
* Bridges `@huggingface/transformers` local inference to the AI SDK
|
|
5
|
+
* `LanguageModelV2` interface. This allows `streamText()` and
|
|
6
|
+
* `generateText()` to work with local models seamlessly.
|
|
7
|
+
*
|
|
8
|
+
* @module provider/local
|
|
9
|
+
*/
|
|
10
|
+
import { generate, generateStream } from "./local-engine.js";
|
|
11
|
+
import { DEFAULT_LOCAL_MODEL } from "./model-catalog.js";
|
|
12
|
+
import { serverLogger } from "../../utils/index.js";
|
|
13
|
+
import { createError, fromError, toError } from "../../errors/veryfront-error.js";
|
|
14
|
+
import { isLocalAIDisabled } from "./env.js";
|
|
15
|
+
const logger = serverLogger.component("local-llm");
|
|
16
|
+
/**
|
|
17
|
+
* Convert AI SDK LanguageModelV2 prompt format to simple ChatMessage array.
|
|
18
|
+
*
|
|
19
|
+
* The AI SDK prompt is an array of message objects with role and content arrays.
|
|
20
|
+
* We extract text content for the local model.
|
|
21
|
+
*/
|
|
22
|
+
// deno-lint-ignore no-explicit-any
|
|
23
|
+
function convertPrompt(prompt) {
|
|
24
|
+
const messages = [];
|
|
25
|
+
for (const msg of prompt) {
|
|
26
|
+
const role = msg.role;
|
|
27
|
+
// Skip tool messages — local models don't support tool calling
|
|
28
|
+
if (role === "tool")
|
|
29
|
+
continue;
|
|
30
|
+
const mappedRole = role === "system" ? "system" : role === "user" ? "user" : "assistant";
|
|
31
|
+
// Extract text content from content array
|
|
32
|
+
let text = "";
|
|
33
|
+
if (typeof msg.content === "string") {
|
|
34
|
+
text = msg.content;
|
|
35
|
+
}
|
|
36
|
+
else if (Array.isArray(msg.content)) {
|
|
37
|
+
for (const part of msg.content) {
|
|
38
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
39
|
+
text += part.text;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (text) {
|
|
44
|
+
messages.push({ role: mappedRole, content: text });
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return messages;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a local AI SDK LanguageModel for the given model ID.
|
|
51
|
+
*
|
|
52
|
+
* The returned object implements the LanguageModelV2 interface, making it
|
|
53
|
+
* compatible with all AI SDK functions (`streamText`, `generateText`, etc.)
|
|
54
|
+
* and all VeryFront hooks (`useChat`).
|
|
55
|
+
*/
|
|
56
|
+
export function createLocalModel(modelId) {
|
|
57
|
+
const resolvedId = modelId || DEFAULT_LOCAL_MODEL;
|
|
58
|
+
const model = {
|
|
59
|
+
/** Marker so ensureModelReady() can distinguish real local-engine models
|
|
60
|
+
* from mock/custom providers that happen to use provider:"local". */
|
|
61
|
+
_isVfLocalModel: true,
|
|
62
|
+
specificationVersion: "v2",
|
|
63
|
+
provider: "local",
|
|
64
|
+
modelId: `local/${resolvedId}`,
|
|
65
|
+
supportedUrls: {},
|
|
66
|
+
async doGenerate(options) {
|
|
67
|
+
const messages = convertPrompt(options.prompt);
|
|
68
|
+
const genOptions = {
|
|
69
|
+
maxNewTokens: options.maxOutputTokens ?? 512,
|
|
70
|
+
temperature: options.temperature ?? 0.7,
|
|
71
|
+
topP: options.topP,
|
|
72
|
+
topK: options.topK,
|
|
73
|
+
stopSequences: options.stopSequences,
|
|
74
|
+
};
|
|
75
|
+
logger.debug(`[local] doGenerate: ${messages.length} messages → ${resolvedId}`);
|
|
76
|
+
const text = await generate(resolvedId, messages, genOptions);
|
|
77
|
+
return {
|
|
78
|
+
content: [{ type: "text", text }],
|
|
79
|
+
finishReason: "stop",
|
|
80
|
+
usage: {
|
|
81
|
+
inputTokens: undefined,
|
|
82
|
+
outputTokens: undefined,
|
|
83
|
+
totalTokens: undefined,
|
|
84
|
+
},
|
|
85
|
+
warnings: [],
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
async doStream(options) {
|
|
89
|
+
// Eagerly check if local AI is disabled — must throw before creating the
|
|
90
|
+
// ReadableStream, otherwise the 200 response headers are already committed.
|
|
91
|
+
// Note: getTransformers() in local-engine.ts also checks this, but we need
|
|
92
|
+
// the check here too because doStream creates a ReadableStream wrapper and
|
|
93
|
+
// errors inside it would be swallowed as in-band stream errors.
|
|
94
|
+
if (isLocalAIDisabled()) {
|
|
95
|
+
throw toError(createError({
|
|
96
|
+
type: "no_ai_available",
|
|
97
|
+
message: "Local AI disabled via VERYFRONT_DISABLE_LOCAL_AI environment variable.",
|
|
98
|
+
}));
|
|
99
|
+
}
|
|
100
|
+
const messages = convertPrompt(options.prompt);
|
|
101
|
+
const genOptions = {
|
|
102
|
+
maxNewTokens: options.maxOutputTokens ?? 512,
|
|
103
|
+
temperature: options.temperature ?? 0.7,
|
|
104
|
+
topP: options.topP,
|
|
105
|
+
topK: options.topK,
|
|
106
|
+
stopSequences: options.stopSequences,
|
|
107
|
+
};
|
|
108
|
+
logger.debug(`[local] doStream: ${messages.length} messages → ${resolvedId}`);
|
|
109
|
+
const textId = `text-${Date.now()}`;
|
|
110
|
+
const stream = new ReadableStream({
|
|
111
|
+
async start(controller) {
|
|
112
|
+
try {
|
|
113
|
+
// Emit stream-start
|
|
114
|
+
controller.enqueue({ type: "stream-start", warnings: [] });
|
|
115
|
+
// Emit response metadata
|
|
116
|
+
controller.enqueue({
|
|
117
|
+
type: "response-metadata",
|
|
118
|
+
id: `local-${Date.now()}`,
|
|
119
|
+
timestamp: new Date(),
|
|
120
|
+
modelId: `local/${resolvedId}`,
|
|
121
|
+
});
|
|
122
|
+
// Emit text-start
|
|
123
|
+
controller.enqueue({ type: "text-start", id: textId });
|
|
124
|
+
// Stream tokens
|
|
125
|
+
for await (const token of generateStream(resolvedId, messages, genOptions)) {
|
|
126
|
+
controller.enqueue({
|
|
127
|
+
type: "text-delta",
|
|
128
|
+
id: textId,
|
|
129
|
+
delta: token,
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
// Emit text-end
|
|
133
|
+
controller.enqueue({ type: "text-end", id: textId });
|
|
134
|
+
// Emit finish
|
|
135
|
+
controller.enqueue({
|
|
136
|
+
type: "finish",
|
|
137
|
+
finishReason: "stop",
|
|
138
|
+
usage: {
|
|
139
|
+
inputTokens: undefined,
|
|
140
|
+
outputTokens: undefined,
|
|
141
|
+
totalTokens: undefined,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
controller.close();
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
// Let no_ai_available propagate — the chat handler needs it
|
|
148
|
+
// for a proper 503 response instead of a 200 with in-band error.
|
|
149
|
+
const vfError = fromError(error);
|
|
150
|
+
if (vfError?.type === "no_ai_available")
|
|
151
|
+
throw error;
|
|
152
|
+
controller.enqueue({
|
|
153
|
+
type: "error",
|
|
154
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
155
|
+
});
|
|
156
|
+
controller.close();
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
return { stream };
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
return model;
|
|
164
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform environment helpers for local AI provider.
|
|
3
|
+
*
|
|
4
|
+
* Abstracts Deno/Node env access so all local-AI checks go through
|
|
5
|
+
* a single function — no duplicated `(globalThis as any).Deno?.env` patterns.
|
|
6
|
+
*
|
|
7
|
+
* @module provider/local
|
|
8
|
+
*/
|
|
9
|
+
export declare function isLocalAIDisabled(): boolean;
|
|
10
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/local/env.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,wBAAgB,iBAAiB,IAAI,OAAO,CAU3C"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cross-platform environment helpers for local AI provider.
|
|
3
|
+
*
|
|
4
|
+
* Abstracts Deno/Node env access so all local-AI checks go through
|
|
5
|
+
* a single function — no duplicated `(globalThis as any).Deno?.env` patterns.
|
|
6
|
+
*
|
|
7
|
+
* @module provider/local
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Check whether local AI is explicitly disabled via environment variable.
|
|
11
|
+
* Works in Deno, Node, and compiled binaries.
|
|
12
|
+
*/
|
|
13
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
14
|
+
export function isLocalAIDisabled() {
|
|
15
|
+
// deno-lint-ignore no-explicit-any
|
|
16
|
+
const denoVal = dntShim.dntGlobalThis.Deno?.env?.get?.("VERYFRONT_DISABLE_LOCAL_AI");
|
|
17
|
+
if (denoVal === "1")
|
|
18
|
+
return true;
|
|
19
|
+
if (typeof process !== "undefined" && process.env?.VERYFRONT_DISABLE_LOCAL_AI === "1") {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local Model Engine
|
|
3
|
+
*
|
|
4
|
+
* Singleton wrapper around `@huggingface/transformers` for server-side
|
|
5
|
+
* local LLM inference. Provides lazy model loading and streaming text
|
|
6
|
+
* generation via async generators.
|
|
7
|
+
*
|
|
8
|
+
* Uses ONNX Runtime for inference with q4 quantization — NOT q4f16
|
|
9
|
+
* due to a known ONNX bug with f16 LayerNorm on CPU.
|
|
10
|
+
*
|
|
11
|
+
* @module provider/local
|
|
12
|
+
*/
|
|
13
|
+
/** Chat message format expected by Transformers.js */
|
|
14
|
+
export interface ChatMessage {
|
|
15
|
+
role: "system" | "user" | "assistant";
|
|
16
|
+
content: string;
|
|
17
|
+
}
|
|
18
|
+
/** Options for text generation */
|
|
19
|
+
export interface GenerateOptions {
|
|
20
|
+
maxNewTokens?: number;
|
|
21
|
+
temperature?: number;
|
|
22
|
+
topP?: number;
|
|
23
|
+
topK?: number;
|
|
24
|
+
stopSequences?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Eagerly verify that the local AI runtime (@huggingface/transformers + ONNX)
|
|
28
|
+
* is available by loading the default model pipeline.
|
|
29
|
+
*
|
|
30
|
+
* Call this *before* creating the HTTP response stream so that failures surface
|
|
31
|
+
* as a thrown error (→ 503) rather than being swallowed inside a ReadableStream
|
|
32
|
+
* (→ 200 with in-band SSE error).
|
|
33
|
+
*
|
|
34
|
+
* In compiled binaries, `import("@huggingface/transformers")` itself fails
|
|
35
|
+
* because `onnxruntime-node` eagerly `require()`s a native `.node` addon at
|
|
36
|
+
* import time and the addon isn't embedded in the binary. In dev mode (Deno)
|
|
37
|
+
* the native addon exists on disk so the import succeeds, but `pipeline()` can
|
|
38
|
+
* still fail if the ONNX model files are missing. Either way this function
|
|
39
|
+
* surfaces the error before the response stream is created. The pipeline is
|
|
40
|
+
* cached after the first successful call, so subsequent checks are instant.
|
|
41
|
+
*/
|
|
42
|
+
export declare function verifyLocalRuntime(modelId?: string): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Generate text in a streaming fashion using an async generator.
|
|
45
|
+
*
|
|
46
|
+
* Yields individual tokens as they are generated by the model.
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateStream(modelId: string, messages: ChatMessage[], options?: GenerateOptions): AsyncGenerator<string, void, undefined>;
|
|
49
|
+
/**
|
|
50
|
+
* Generate text without streaming (full completion).
|
|
51
|
+
*/
|
|
52
|
+
export declare function generate(modelId: string, messages: ChatMessage[], options?: GenerateOptions): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Preload a model into memory. Useful for warming up on server start.
|
|
55
|
+
*/
|
|
56
|
+
export declare function preloadModel(modelId: string): Promise<void>;
|
|
57
|
+
/**
|
|
58
|
+
* Check if a model is currently loaded in memory.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isModelLoaded(modelId: string): boolean;
|
|
61
|
+
//# sourceMappingURL=local-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-engine.d.ts","sourceRoot":"","sources":["../../../../src/src/provider/local/local-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,sDAAsD;AACtD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,kCAAkC;AAClC,MAAM,WAAW,eAAe;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AA6HD;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGxE;AAED;;;;GAIG;AACH,wBAAuB,cAAc,CACnC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,CAoEzC;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAC5B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,WAAW,EAAE,EACvB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,MAAM,CAAC,CAMjB;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGjE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAGtD"}
|