@ljoukov/llm 3.0.0 → 3.0.2
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 +20 -5
- package/dist/index.cjs +748 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +747 -26
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Unified TypeScript wrapper over:
|
|
|
9
9
|
|
|
10
10
|
- **OpenAI Responses API** (`openai`)
|
|
11
11
|
- **Google Gemini via Vertex AI** (`@google/genai`)
|
|
12
|
-
- **Fireworks chat-completions models** (`kimi-k2.5`, `glm-5`, `minimax-m2.1`)
|
|
12
|
+
- **Fireworks chat-completions models** (`kimi-k2.5`, `glm-5`, `minimax-m2.1`, `gpt-oss-120b`)
|
|
13
13
|
- **ChatGPT subscription models** via `chatgpt-*` model ids (reuses Codex auth store, or a token provider)
|
|
14
14
|
|
|
15
15
|
Designed around a single streaming API that yields:
|
|
@@ -34,6 +34,8 @@ See Node.js docs on environment variables and dotenv files: https://nodejs.org/a
|
|
|
34
34
|
### OpenAI
|
|
35
35
|
|
|
36
36
|
- `OPENAI_API_KEY`
|
|
37
|
+
- `OPENAI_RESPONSES_WEBSOCKET_MODE` (`auto` | `off` | `only`, default: `auto`)
|
|
38
|
+
- `OPENAI_BASE_URL` (optional; defaults to `https://api.openai.com/v1`)
|
|
37
39
|
|
|
38
40
|
### Gemini (Vertex AI)
|
|
39
41
|
|
|
@@ -86,12 +88,25 @@ refresh-token rotation and serves short-lived access tokens.
|
|
|
86
88
|
- `CHATGPT_AUTH_TOKEN_PROVIDER_URL` (example: `https://chatgpt-auth.<your-domain>`)
|
|
87
89
|
- `CHATGPT_AUTH_API_KEY` (shared secret; sent as `Authorization: Bearer ...` and `x-chatgpt-auth: ...`)
|
|
88
90
|
- `CHATGPT_AUTH_TOKEN_PROVIDER_STORE` (`kv` or `d1`, defaults to `kv`)
|
|
91
|
+
- `CHATGPT_RESPONSES_WEBSOCKET_MODE` (`auto` | `off` | `only`, default: `auto`)
|
|
89
92
|
|
|
90
93
|
This repo includes a Cloudflare Workers token provider implementation in `workers/chatgpt-auth/`.
|
|
91
94
|
|
|
92
95
|
If `CHATGPT_AUTH_TOKEN_PROVIDER_URL` + `CHATGPT_AUTH_API_KEY` are set, `chatgpt-*` models will fetch tokens from the
|
|
93
96
|
token provider and will not read the local Codex auth store.
|
|
94
97
|
|
|
98
|
+
### Responses transport
|
|
99
|
+
|
|
100
|
+
For OpenAI and `chatgpt-*` model paths, this library now tries **Responses WebSocket transport first** and falls back
|
|
101
|
+
to HTTP/SSE automatically when needed.
|
|
102
|
+
|
|
103
|
+
- `auto` (default): try WebSocket first, then fall back to SSE
|
|
104
|
+
- `off`: use SSE only
|
|
105
|
+
- `only`: require WebSocket (no fallback)
|
|
106
|
+
|
|
107
|
+
When fallback is triggered by an unsupported WebSocket upgrade response (for example `426`), the library keeps using
|
|
108
|
+
SSE for the rest of the process to avoid repeated failing upgrade attempts.
|
|
109
|
+
|
|
95
110
|
## Usage
|
|
96
111
|
|
|
97
112
|
`v2` uses OpenAI-style request fields:
|
|
@@ -263,7 +278,7 @@ console.log(result.text);
|
|
|
263
278
|
|
|
264
279
|
### Fireworks
|
|
265
280
|
|
|
266
|
-
Use Fireworks model ids directly (for example `kimi-k2.5`, `glm-5`, `minimax-m2.1`):
|
|
281
|
+
Use Fireworks model ids directly (for example `kimi-k2.5`, `glm-5`, `minimax-m2.1`, `gpt-oss-120b`):
|
|
267
282
|
|
|
268
283
|
```ts
|
|
269
284
|
import { generateText } from "@ljoukov/llm";
|
|
@@ -457,7 +472,7 @@ const fs = createInMemoryAgentFilesystem({
|
|
|
457
472
|
});
|
|
458
473
|
|
|
459
474
|
const result = await runAgentLoop({
|
|
460
|
-
model: "chatgpt-gpt-5.3-codex
|
|
475
|
+
model: "chatgpt-gpt-5.3-codex",
|
|
461
476
|
input: "Change value from 1 to 2 using filesystem tools.",
|
|
462
477
|
filesystemTool: {
|
|
463
478
|
profile: "auto",
|
|
@@ -481,13 +496,13 @@ import {
|
|
|
481
496
|
} from "@ljoukov/llm";
|
|
482
497
|
|
|
483
498
|
const fs = createInMemoryAgentFilesystem({ "/repo/a.ts": "export const n = 1;\n" });
|
|
484
|
-
const tools = createFilesystemToolSetForModel("chatgpt-gpt-5.3-codex
|
|
499
|
+
const tools = createFilesystemToolSetForModel("chatgpt-gpt-5.3-codex", {
|
|
485
500
|
cwd: "/repo",
|
|
486
501
|
fs,
|
|
487
502
|
});
|
|
488
503
|
|
|
489
504
|
const result = await runToolLoop({
|
|
490
|
-
model: "chatgpt-gpt-5.3-codex
|
|
505
|
+
model: "chatgpt-gpt-5.3-codex",
|
|
491
506
|
input: "Update n to 2.",
|
|
492
507
|
tools,
|
|
493
508
|
});
|