@molecule/api-ai-local 1.0.4 → 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/package.json +1 -1
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/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",
|