@molecule/api-ai-local 1.0.3 → 1.0.5
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 +21 -1
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +19 -0
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +5 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-10-01T18:20:47.510Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-ai-local
|
|
@@ -18,6 +18,26 @@ Streams chat completions from any local inference server that speaks the
|
|
|
18
18
|
OpenAI `chat/completions` protocol (Ollama, LM Studio, llama.cpp, vLLM),
|
|
19
19
|
keyless by default.
|
|
20
20
|
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// npm install @molecule/api-ai-local --workspace=api
|
|
25
|
+
import { setProvider, requireProvider } from '@molecule/api-ai'
|
|
26
|
+
import { provider } from '@molecule/api-ai-local'
|
|
27
|
+
|
|
28
|
+
// Named registration — several AI providers can be bonded side by side
|
|
29
|
+
// (getProviderByName('local') targets this one); the FIRST one
|
|
30
|
+
// registered also answers requireProvider() (see @molecule/api-ai).
|
|
31
|
+
setProvider('local', provider) // keyless: LOCAL_AI_BASE_URL (Ollama http://localhost:11434/v1 by default), LOCAL_AI_MODEL (llama3.1)
|
|
32
|
+
|
|
33
|
+
let reply = ''
|
|
34
|
+
for await (const event of requireProvider().chat({
|
|
35
|
+
messages: [{ role: 'user', content: 'Hello!' }],
|
|
36
|
+
})) {
|
|
37
|
+
if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
21
41
|
## Type
|
|
22
42
|
|
|
23
43
|
`provider`
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,25 @@
|
|
|
5
5
|
* OpenAI `chat/completions` protocol (Ollama, LM Studio, llama.cpp, vLLM),
|
|
6
6
|
* keyless by default.
|
|
7
7
|
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // npm install @molecule/api-ai-local --workspace=api
|
|
11
|
+
* import { setProvider, requireProvider } from '@molecule/api-ai'
|
|
12
|
+
* import { provider } from '@molecule/api-ai-local'
|
|
13
|
+
*
|
|
14
|
+
* // Named registration — several AI providers can be bonded side by side
|
|
15
|
+
* // (getProviderByName('local') targets this one); the FIRST one
|
|
16
|
+
* // registered also answers requireProvider() (see @molecule/api-ai).
|
|
17
|
+
* setProvider('local', provider) // keyless: LOCAL_AI_BASE_URL (Ollama http://localhost:11434/v1 by default), LOCAL_AI_MODEL (llama3.1)
|
|
18
|
+
*
|
|
19
|
+
* let reply = ''
|
|
20
|
+
* for await (const event of requireProvider().chat({
|
|
21
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
22
|
+
* })) {
|
|
23
|
+
* if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
8
27
|
* @remarks
|
|
9
28
|
* **Error message disambiguation**: a plain 400 that ISN'T a context-length error (bad param,
|
|
10
29
|
* malformed tool schema) gets its own non-retryable message distinct from the generic
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,cAAc,oBAAoB,CAAA;AAClC,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AAC/D,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAE1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAMlD,4EAA4E;AAC5E,eAAO,MAAM,QAAQ,EAAE,UAUrB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,25 @@
|
|
|
5
5
|
* OpenAI `chat/completions` protocol (Ollama, LM Studio, llama.cpp, vLLM),
|
|
6
6
|
* keyless by default.
|
|
7
7
|
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* // npm install @molecule/api-ai-local --workspace=api
|
|
11
|
+
* import { setProvider, requireProvider } from '@molecule/api-ai'
|
|
12
|
+
* import { provider } from '@molecule/api-ai-local'
|
|
13
|
+
*
|
|
14
|
+
* // Named registration — several AI providers can be bonded side by side
|
|
15
|
+
* // (getProviderByName('local') targets this one); the FIRST one
|
|
16
|
+
* // registered also answers requireProvider() (see @molecule/api-ai).
|
|
17
|
+
* setProvider('local', provider) // keyless: LOCAL_AI_BASE_URL (Ollama http://localhost:11434/v1 by default), LOCAL_AI_MODEL (llama3.1)
|
|
18
|
+
*
|
|
19
|
+
* let reply = ''
|
|
20
|
+
* for await (const event of requireProvider().chat({
|
|
21
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
22
|
+
* })) {
|
|
23
|
+
* if (event.type === 'text') reply += event.content // or forward the chunk to the client (SSE)
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
8
27
|
* @remarks
|
|
9
28
|
* **Error message disambiguation**: a plain 400 that ISN'T a context-length error (bad param,
|
|
10
29
|
* malformed tool schema) gets its own non-retryable message distinct from the generic
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EACV,UAAU,EAGV,SAAS,EAET,UAAU,EAEX,MAAM,kBAAkB,CAAA;AAGzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAqB7C;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;IAChD,QAAQ,CAAC,IAAI,WAAU;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,WAAW,CAAC,CAAqB;gBAE7B,MAAM,GAAE,WAAgB;IAepC;;;;;OAKG;IACI,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC;IAoLzD;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,cAAc;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,cAAc,CAAA;AAErB,OAAO,KAAK,EACV,UAAU,EAGV,SAAS,EAET,UAAU,EAEX,MAAM,kBAAkB,CAAA;AAGzB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAqB7C;;;;GAIG;AACH,qBAAa,eAAgB,YAAW,UAAU;IAChD,QAAQ,CAAC,IAAI,WAAU;IACvB,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,YAAY,CAAQ;IAC5B,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,WAAW,CAAC,CAAqB;gBAE7B,MAAM,GAAE,WAAgB;IAepC;;;;;OAKG;IACI,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,aAAa,CAAC,SAAS,CAAC;IAoLzD;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,cAAc;IA+DtB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IA6BnB,uEAAuE;IACvE,OAAO,CAAC,WAAW;IAWnB;;;;;OAKG;IACH,OAAO,CAAE,yBAAyB;IA8ClC;;;;;OAKG;YACY,sBAAsB;IA2ErC;;;;;;OAMG;IACH,OAAO,CAAE,eAAe;IA+DxB;;;;;;;;;;OAUG;IACH,OAAO,CAAE,qBAAqB;CAqC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,CAE/D"}
|
package/dist/provider.js
CHANGED
|
@@ -275,6 +275,11 @@ export class LocalAIProvider {
|
|
|
275
275
|
if (toolResults.length > 0) {
|
|
276
276
|
for (const tr of toolResults)
|
|
277
277
|
out.push(tr);
|
|
278
|
+
// Non-tool parts of the SAME message (an image riding a tool result — the
|
|
279
|
+
// screenshot tool) must not be dropped: Chat Completions accepts a user
|
|
280
|
+
// message after the tool messages, so emit them instead of losing them.
|
|
281
|
+
if (parts.length > 0)
|
|
282
|
+
out.push({ role: m.role, content: parts });
|
|
278
283
|
}
|
|
279
284
|
else if (toolCalls.length > 0) {
|
|
280
285
|
out.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-ai-local",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "AIProvider bond for any OpenAI-compatible local inference server (Ollama, LM Studio, llama.cpp, vLLM) — configurable base URL, keyless by default, streamed via raw fetch.",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/api-ai-local",
|
|
6
6
|
"type": "module",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"directory": "packages/api/bonds/ai/local"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@molecule/api-ai": "1.
|
|
36
|
+
"@molecule/api-ai": "1.3.0",
|
|
37
37
|
"@molecule/api-bond": "1.0.2",
|
|
38
38
|
"@molecule/api-secrets": "1.0.2",
|
|
39
39
|
"@types/node": "26.1.2",
|