@node-llm/core 0.8.0 → 1.1.0
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 +0 -167
- package/dist/aliases.json +126 -0
- package/dist/chat/Chat.d.ts +7 -3
- package/dist/chat/Chat.d.ts.map +1 -1
- package/dist/chat/Chat.js +6 -7
- package/dist/chat/ChatStream.d.ts +25 -0
- package/dist/chat/ChatStream.d.ts.map +1 -0
- package/dist/chat/ChatStream.js +93 -0
- package/dist/config.d.ts +5 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +2 -0
- package/dist/embedding/Embedding.d.ts +1 -1
- package/dist/embedding/Embedding.d.ts.map +1 -1
- package/dist/errors/index.d.ts +22 -0
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +32 -0
- package/dist/index.d.ts +10 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -9
- package/dist/llm.d.ts +4 -3
- package/dist/llm.d.ts.map +1 -1
- package/dist/llm.js +44 -37
- package/dist/model_aliases.d.ts +3 -0
- package/dist/model_aliases.d.ts.map +1 -0
- package/dist/model_aliases.js +20 -0
- package/dist/models/ModelRegistry.d.ts +4 -0
- package/dist/models/ModelRegistry.d.ts.map +1 -1
- package/dist/models/ModelRegistry.js +15 -0
- package/dist/models/models.d.ts +729 -60
- package/dist/models/models.d.ts.map +1 -1
- package/dist/models/models.js +24375 -2312
- package/dist/models/types.d.ts +3 -3
- package/dist/models/types.d.ts.map +1 -1
- package/dist/models/types.js +3 -0
- package/dist/providers/BaseProvider.d.ts +23 -0
- package/dist/providers/BaseProvider.d.ts.map +1 -0
- package/dist/providers/BaseProvider.js +31 -0
- package/dist/providers/Provider.d.ts +17 -1
- package/dist/providers/Provider.d.ts.map +1 -1
- package/dist/providers/anthropic/AnthropicProvider.d.ts +6 -7
- package/dist/providers/anthropic/AnthropicProvider.d.ts.map +1 -1
- package/dist/providers/anthropic/AnthropicProvider.js +16 -13
- package/dist/providers/anthropic/Streaming.d.ts +1 -1
- package/dist/providers/anthropic/Streaming.d.ts.map +1 -1
- package/dist/providers/anthropic/Streaming.js +80 -54
- package/dist/providers/deepseek/Capabilities.js +1 -1
- package/dist/providers/deepseek/DeepSeekProvider.d.ts +5 -1
- package/dist/providers/deepseek/DeepSeekProvider.d.ts.map +1 -1
- package/dist/providers/deepseek/DeepSeekProvider.js +15 -1
- package/dist/providers/deepseek/Streaming.d.ts +1 -1
- package/dist/providers/deepseek/Streaming.d.ts.map +1 -1
- package/dist/providers/deepseek/Streaming.js +80 -48
- package/dist/providers/gemini/Capabilities.d.ts.map +1 -1
- package/dist/providers/gemini/Embeddings.d.ts +1 -1
- package/dist/providers/gemini/Embeddings.d.ts.map +1 -1
- package/dist/providers/gemini/GeminiProvider.d.ts +6 -4
- package/dist/providers/gemini/GeminiProvider.d.ts.map +1 -1
- package/dist/providers/gemini/GeminiProvider.js +14 -4
- package/dist/providers/gemini/Streaming.d.ts +1 -1
- package/dist/providers/gemini/Streaming.d.ts.map +1 -1
- package/dist/providers/gemini/Streaming.js +62 -39
- package/dist/providers/gemini/index.d.ts +1 -1
- package/dist/providers/gemini/index.js +1 -1
- package/dist/providers/ollama/Capabilities.d.ts.map +1 -1
- package/dist/providers/ollama/Capabilities.js +5 -1
- package/dist/providers/ollama/OllamaProvider.d.ts +1 -0
- package/dist/providers/ollama/OllamaProvider.d.ts.map +1 -1
- package/dist/providers/ollama/OllamaProvider.js +3 -0
- package/dist/providers/ollama/index.d.ts +1 -1
- package/dist/providers/ollama/index.js +1 -1
- package/dist/providers/openai/Embedding.d.ts +1 -1
- package/dist/providers/openai/Embedding.d.ts.map +1 -1
- package/dist/providers/openai/OpenAIProvider.d.ts +6 -3
- package/dist/providers/openai/OpenAIProvider.d.ts.map +1 -1
- package/dist/providers/openai/OpenAIProvider.js +15 -1
- package/dist/providers/openai/Streaming.d.ts +1 -1
- package/dist/providers/openai/Streaming.d.ts.map +1 -1
- package/dist/providers/openai/Streaming.js +75 -43
- package/dist/providers/openai/index.d.ts +1 -1
- package/dist/providers/openai/index.js +1 -1
- package/dist/providers/openrouter/Capabilities.d.ts +13 -0
- package/dist/providers/openrouter/Capabilities.d.ts.map +1 -0
- package/dist/providers/openrouter/Capabilities.js +67 -0
- package/dist/providers/openrouter/Models.d.ts +11 -0
- package/dist/providers/openrouter/Models.d.ts.map +1 -0
- package/dist/providers/openrouter/Models.js +88 -0
- package/dist/providers/openrouter/OpenRouterProvider.d.ts +21 -0
- package/dist/providers/openrouter/OpenRouterProvider.d.ts.map +1 -0
- package/dist/providers/openrouter/OpenRouterProvider.js +24 -0
- package/dist/providers/openrouter/index.d.ts +11 -0
- package/dist/providers/openrouter/index.d.ts.map +1 -0
- package/dist/providers/openrouter/index.js +26 -0
- package/dist/providers/registry.d.ts +11 -1
- package/dist/providers/registry.d.ts.map +1 -1
- package/dist/providers/registry.js +15 -1
- package/dist/streaming/Stream.d.ts +29 -0
- package/dist/streaming/Stream.d.ts.map +1 -0
- package/dist/streaming/Stream.js +67 -0
- package/dist/utils/FileLoader.d.ts.map +1 -1
- package/dist/utils/FileLoader.js +34 -3
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +24 -0
- package/package.json +2 -2
- package/dist/chat/Stream.d.ts +0 -21
- package/dist/chat/Stream.d.ts.map +0 -1
- package/dist/chat/Stream.js +0 -73
- package/dist/providers/Embedding.d.ts +0 -20
- package/dist/providers/Embedding.d.ts.map +0 -1
- package/dist/providers/Embedding.js +0 -1
package/README.md
CHANGED
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
<p align="left">
|
|
2
|
-
<img src="../../docs/assets/images/logo.jpg" alt="node-llm logo" width="300" />
|
|
3
|
-
</p>
|
|
4
|
-
|
|
5
|
-
# @node-llm/core
|
|
6
|
-
|
|
7
|
-
[](https://www.npmjs.com/package/@node-llm/core)
|
|
8
|
-
[](https://opensource.org/licenses/MIT)
|
|
9
|
-
[](https://www.typescriptlang.org/)
|
|
10
|
-
|
|
11
|
-
**One unified interface for OpenAI, Anthropic, Gemini, DeepSeek, and local models.**
|
|
12
|
-
|
|
13
|
-
**node-llm** abstracts away the chaos of vendor-specific SDKs. It gives you a clean, streaming-first API with built-in support for Vision, Tools, and Structured Outputs.
|
|
14
|
-
|
|
15
|
-
<br/>
|
|
16
|
-
|
|
17
|
-
<p align="left">
|
|
18
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/openai.svg" height="28" />
|
|
19
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/openai-text.svg" height="22" />
|
|
20
|
-
|
|
21
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/anthropic-text.svg" height="18" />
|
|
22
|
-
|
|
23
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/gemini-color.svg" height="28" />
|
|
24
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/gemini-text.svg" height="20" />
|
|
25
|
-
|
|
26
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/deepseek-color.svg" height="28" />
|
|
27
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/deepseek-text.svg" height="20" />
|
|
28
|
-
|
|
29
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/ollama.svg" height="28" />
|
|
30
|
-
<img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/ollama-text.svg" height="18" />
|
|
31
|
-
</p>
|
|
32
|
-
|
|
33
|
-
<br/>
|
|
34
|
-
|
|
35
|
-
---
|
|
36
|
-
|
|
37
|
-
## ⚡ Quick Example
|
|
38
|
-
|
|
39
|
-
```ts
|
|
40
|
-
import { LLM } from "@node-llm/core";
|
|
41
|
-
|
|
42
|
-
// 1. Configure once
|
|
43
|
-
LLM.configure({ provider: "openai" });
|
|
44
|
-
|
|
45
|
-
// 2. Basic Chat
|
|
46
|
-
const chat = LLM.chat("gpt-4o");
|
|
47
|
-
const response = await chat.ask("Explain Node.js");
|
|
48
|
-
console.log(response.content);
|
|
49
|
-
|
|
50
|
-
// 3. Streaming
|
|
51
|
-
for await (const chunk of chat.stream("Explain Node.js")) {
|
|
52
|
-
process.stdout.write(chunk.content);
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## 🔮 Capabilities
|
|
59
|
-
|
|
60
|
-
### 💬 Unified Chat
|
|
61
|
-
Stop rewriting code for every provider. `node-llm` normalizes inputs and outputs.
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
const chat = LLM.chat(); // Defaults to GPT-4o
|
|
65
|
-
await chat.ask("Hello world");
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### 👁️ Smart Vision & Files
|
|
69
|
-
Pass images, PDFs, or audio files directly. We handle the base64 encoding and MIME types.
|
|
70
|
-
|
|
71
|
-
```ts
|
|
72
|
-
await chat.ask("Analyze this interface", {
|
|
73
|
-
files: ["./screenshot.png", "./specs.pdf"]
|
|
74
|
-
});
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
### 🛠️ Auto-Executing Tools
|
|
78
|
-
Define tools once, and the library manages the execution loop for you.
|
|
79
|
-
|
|
80
|
-
```ts
|
|
81
|
-
const tools = [{
|
|
82
|
-
type: 'function',
|
|
83
|
-
function: { name: 'get_weather', ... },
|
|
84
|
-
handler: async ({ loc }) => `Sunny in ${loc}`
|
|
85
|
-
}];
|
|
86
|
-
|
|
87
|
-
await chat.withTools(tools).ask("Weather in Tokyo?");
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### ✨ Structured Output
|
|
91
|
-
Get type-safe JSON back using **Zod** schemas.
|
|
92
|
-
|
|
93
|
-
```ts
|
|
94
|
-
import { z } from "zod";
|
|
95
|
-
|
|
96
|
-
const Product = z.object({ name: z.string(), price: z.number() });
|
|
97
|
-
const res = await chat.withSchema(Product).ask("Generate a gadget");
|
|
98
|
-
|
|
99
|
-
console.log(res.parsed.name); // Type-safe access
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### 🎨 Image Generation
|
|
103
|
-
```ts
|
|
104
|
-
await LLM.paint("A cyberpunk city in rain");
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### 🎤 Audio Transcription
|
|
108
|
-
```ts
|
|
109
|
-
await LLM.transcribe("meeting-recording.wav");
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
### 🧠 Deep Reasoning
|
|
113
|
-
Access the thought process of models like **DeepSeek R1** or **OpenAI o1/o3** using the `.reasoning` field.
|
|
114
|
-
|
|
115
|
-
```ts
|
|
116
|
-
const chat = LLM.chat("deepseek-reasoner");
|
|
117
|
-
const res = await chat.ask("Solve a complex puzzle");
|
|
118
|
-
|
|
119
|
-
console.log(res.reasoning); // Output the model's inner thought process
|
|
120
|
-
console.log(res.content); // Output the final answer
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## 📋 Supported Providers
|
|
126
|
-
|
|
127
|
-
| Provider | Supported Features |
|
|
128
|
-
| :--- | :--- |
|
|
129
|
-
| <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/openai.svg" height="18"> <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/openai-text.svg" height="18"> | Chat, Streaming, Tools, Vision, Audio, Images, Transcription, **Reasoning** |
|
|
130
|
-
| <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/gemini-color.svg" height="18"> <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/gemini-text.svg" height="14"> | Chat, Streaming, Tools, Vision, Audio, Video, Embeddings |
|
|
131
|
-
| <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/anthropic-text.svg" height="12"> | Chat, Streaming, Tools, Vision, PDF Support, Structured Output |
|
|
132
|
-
| <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/deepseek-color.svg" height="18"> <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/deepseek-text.svg" height="14"> | Chat (V3), **Reasoning (R1)**, Tools, Streaming, Structured Output |
|
|
133
|
-
| <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/ollama.svg" height="18"> <img src="https://registry.npmmirror.com/@lobehub/icons-static-svg/latest/files/icons/ollama-text.svg" height="12"> | **Local Inference**, Chat, Streaming, Tools, Vision, Embeddings |
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## 🚀 Why use this over official SDKs?
|
|
138
|
-
|
|
139
|
-
| Feature | node-llm | Official SDKs |
|
|
140
|
-
| :--- | :--- | :--- |
|
|
141
|
-
| **API Style** | Consistent across all providers | Different for everyone |
|
|
142
|
-
| **Streaming** | Standard `AsyncIterator` | Callbacks/Events/Streams mixed |
|
|
143
|
-
| **Tools** | Automatic Execution Loop | Manual parsing & recursion |
|
|
144
|
-
| **Files** | Path string or URL | Base64 buffers / distinct types |
|
|
145
|
-
| **Retries** | Built-in & Configurable | Varies by SDK |
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## 📚 Documentation & Installation
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
npm install @node-llm/core
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
**[View Full Documentation ↗](https://node-llm.eshaiju.com/)**
|
|
156
|
-
|
|
157
|
-
---
|
|
158
|
-
|
|
159
|
-
## 🫶 Credits
|
|
160
|
-
|
|
161
|
-
Heavily inspired by the elegant design of [RubyLLM](https://rubyllm.com/).
|
|
162
|
-
|
|
163
|
-
---
|
|
164
|
-
|
|
165
|
-
## 📄 License
|
|
166
|
-
|
|
167
|
-
MIT © [node-llm contributors]
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"chatgpt-4o": {
|
|
3
|
+
"openai": "chatgpt-4o-latest",
|
|
4
|
+
"openrouter": "openai/chatgpt-4o-latest"
|
|
5
|
+
},
|
|
6
|
+
"claude-3-5-haiku": {
|
|
7
|
+
"anthropic": "claude-3-5-haiku-20241022",
|
|
8
|
+
"openrouter": "anthropic/claude-3.5-haiku",
|
|
9
|
+
"bedrock": "anthropic.claude-3-5-haiku-20241022-v1:0"
|
|
10
|
+
},
|
|
11
|
+
"claude-3-5-sonnet": {
|
|
12
|
+
"anthropic": "claude-3-5-sonnet-20240620",
|
|
13
|
+
"openrouter": "anthropic/claude-3.5-sonnet",
|
|
14
|
+
"bedrock": "anthropic.claude-3-5-sonnet-20240620-v1:0"
|
|
15
|
+
},
|
|
16
|
+
"claude-3-7-sonnet": {
|
|
17
|
+
"anthropic": "claude-3-7-sonnet-20250219",
|
|
18
|
+
"openrouter": "anthropic/claude-3.7-sonnet",
|
|
19
|
+
"bedrock": "us.anthropic.claude-3-7-sonnet-20250219-v1:0"
|
|
20
|
+
},
|
|
21
|
+
"claude-3-haiku": {
|
|
22
|
+
"anthropic": "claude-3-haiku-20240307",
|
|
23
|
+
"openrouter": "anthropic/claude-3-haiku",
|
|
24
|
+
"bedrock": "anthropic.claude-3-haiku-20240307-v1:0:200k"
|
|
25
|
+
},
|
|
26
|
+
"claude-3-opus": {
|
|
27
|
+
"anthropic": "claude-3-opus-20240229",
|
|
28
|
+
"openrouter": "anthropic/claude-3-opus",
|
|
29
|
+
"bedrock": "anthropic.claude-3-opus-20240229-v1:0:200k"
|
|
30
|
+
},
|
|
31
|
+
"claude-3-sonnet": {
|
|
32
|
+
"bedrock": "anthropic.claude-3-sonnet-20240229-v1:0"
|
|
33
|
+
},
|
|
34
|
+
"deepseek-chat": {
|
|
35
|
+
"deepseek": "deepseek-chat",
|
|
36
|
+
"openrouter": "deepseek/deepseek-chat"
|
|
37
|
+
},
|
|
38
|
+
"gemini-flash": {
|
|
39
|
+
"gemini": "gemini-flash-latest",
|
|
40
|
+
"vertexai": "gemini-flash-latest",
|
|
41
|
+
"openrouter": "google/gemini-flash-latest"
|
|
42
|
+
},
|
|
43
|
+
"gemini-pro": {
|
|
44
|
+
"gemini": "gemini-1.5-pro-001",
|
|
45
|
+
"vertexai": "gemini-1.5-pro-001",
|
|
46
|
+
"openrouter": "google/gemini-1.5-pro-001"
|
|
47
|
+
},
|
|
48
|
+
"gemini-1.5-flash": {
|
|
49
|
+
"gemini": "gemini-1.5-flash-001",
|
|
50
|
+
"vertexai": "gemini-1.5-flash-001",
|
|
51
|
+
"openrouter": "google/gemini-1.5-flash-001"
|
|
52
|
+
},
|
|
53
|
+
"gemini-1.5-pro": {
|
|
54
|
+
"gemini": "gemini-1.5-pro-001",
|
|
55
|
+
"vertexai": "gemini-1.5-pro-001",
|
|
56
|
+
"openrouter": "google/gemini-1.5-pro-001"
|
|
57
|
+
},
|
|
58
|
+
"gemini-2.0-flash": {
|
|
59
|
+
"gemini": "gemini-2.0-flash",
|
|
60
|
+
"vertexai": "gemini-2.0-flash"
|
|
61
|
+
},
|
|
62
|
+
"gemini-2.0-flash-001": {
|
|
63
|
+
"gemini": "gemini-2.0-flash-001",
|
|
64
|
+
"openrouter": "google/gemini-2.0-flash-001",
|
|
65
|
+
"vertexai": "gemini-2.0-flash-001"
|
|
66
|
+
},
|
|
67
|
+
"gpt-3.5-turbo": {
|
|
68
|
+
"openai": "gpt-3.5-turbo",
|
|
69
|
+
"openrouter": "openai/gpt-3.5-turbo"
|
|
70
|
+
},
|
|
71
|
+
"gpt-4": {
|
|
72
|
+
"openai": "gpt-4",
|
|
73
|
+
"openrouter": "openai/gpt-4"
|
|
74
|
+
},
|
|
75
|
+
"gpt-4-turbo": {
|
|
76
|
+
"openai": "gpt-4-turbo",
|
|
77
|
+
"openrouter": "openai/gpt-4-turbo"
|
|
78
|
+
},
|
|
79
|
+
"gpt-4o": {
|
|
80
|
+
"openai": "gpt-4o",
|
|
81
|
+
"openrouter": "openai/gpt-4o"
|
|
82
|
+
},
|
|
83
|
+
"gpt-4o-mini": {
|
|
84
|
+
"openai": "gpt-4o-mini",
|
|
85
|
+
"openrouter": "openai/gpt-4o-mini"
|
|
86
|
+
},
|
|
87
|
+
"llama-3-1-405b": {
|
|
88
|
+
"openrouter": "meta-llama/llama-3.1-405b"
|
|
89
|
+
},
|
|
90
|
+
"llama-3-1-405b-instruct": {
|
|
91
|
+
"openrouter": "meta-llama/llama-3.1-405b-instruct"
|
|
92
|
+
},
|
|
93
|
+
"llama-3-1-70b": {
|
|
94
|
+
"openrouter": "meta-llama/llama-3.1-70b"
|
|
95
|
+
},
|
|
96
|
+
"llama-3-1-70b-instruct": {
|
|
97
|
+
"openrouter": "meta-llama/llama-3.1-70b-instruct"
|
|
98
|
+
},
|
|
99
|
+
"llama-3-1-8b": {
|
|
100
|
+
"openrouter": "meta-llama/llama-3.1-8b"
|
|
101
|
+
},
|
|
102
|
+
"llama-3-1-8b-instruct": {
|
|
103
|
+
"openrouter": "meta-llama/llama-3.1-8b-instruct"
|
|
104
|
+
},
|
|
105
|
+
"llama-3-2-1b-instruct": {
|
|
106
|
+
"openrouter": "meta-llama/llama-3.2-1b-instruct"
|
|
107
|
+
},
|
|
108
|
+
"llama-3-2-3b-instruct": {
|
|
109
|
+
"openrouter": "meta-llama/llama-3.2-3b-instruct"
|
|
110
|
+
},
|
|
111
|
+
"llama-3-3-70b-instruct": {
|
|
112
|
+
"openrouter": "meta-llama/llama-3.3-70b-instruct"
|
|
113
|
+
},
|
|
114
|
+
"mistral-large": {
|
|
115
|
+
"mistral": "mistral-large-latest",
|
|
116
|
+
"openrouter": "mistralai/mistral-large"
|
|
117
|
+
},
|
|
118
|
+
"mistral-medium": {
|
|
119
|
+
"mistral": "mistral-medium-latest",
|
|
120
|
+
"openrouter": "mistralai/mistral-medium"
|
|
121
|
+
},
|
|
122
|
+
"mistral-small": {
|
|
123
|
+
"mistral": "mistral-small-latest",
|
|
124
|
+
"openrouter": "mistralai/mistral-small"
|
|
125
|
+
}
|
|
126
|
+
}
|
package/dist/chat/Chat.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Message } from "./Message.js";
|
|
2
2
|
import { ChatOptions } from "./ChatOptions.js";
|
|
3
|
-
import { Provider, Usage } from "../providers/Provider.js";
|
|
3
|
+
import { Provider, Usage, ChatChunk } from "../providers/Provider.js";
|
|
4
|
+
import { Stream } from "../streaming/Stream.js";
|
|
4
5
|
import { Tool } from "./Tool.js";
|
|
5
6
|
import { Schema } from "../schema/Schema.js";
|
|
6
7
|
import { z } from "zod";
|
|
@@ -18,7 +19,10 @@ export declare class Chat {
|
|
|
18
19
|
private readonly options;
|
|
19
20
|
private messages;
|
|
20
21
|
private executor;
|
|
21
|
-
constructor(provider: Provider, model: string, options?: ChatOptions
|
|
22
|
+
constructor(provider: Provider, model: string, options?: ChatOptions, retryConfig?: {
|
|
23
|
+
attempts: number;
|
|
24
|
+
delayMs: number;
|
|
25
|
+
});
|
|
22
26
|
/**
|
|
23
27
|
* Read-only access to message history
|
|
24
28
|
*/
|
|
@@ -95,6 +99,6 @@ export declare class Chat {
|
|
|
95
99
|
/**
|
|
96
100
|
* Streams the model's response to a user question.
|
|
97
101
|
*/
|
|
98
|
-
stream(content: string):
|
|
102
|
+
stream(content: string): Stream<ChatChunk>;
|
|
99
103
|
}
|
|
100
104
|
//# sourceMappingURL=Chat.d.ts.map
|
package/dist/chat/Chat.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chat.d.ts","sourceRoot":"","sources":["../../src/chat/Chat.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"Chat.d.ts","sourceRoot":"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,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAKlD;;OAEG;IACG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,GAAG,EAAE,EAAE,OAAO,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAgMrF;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;CAI3C"}
|
package/dist/chat/Chat.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FileLoader } from "../utils/FileLoader.js";
|
|
2
2
|
import { Executor } from "../executor/Executor.js";
|
|
3
|
-
import {
|
|
4
|
-
import { Stream } from "./Stream.js";
|
|
3
|
+
import { ChatStream } from "./ChatStream.js";
|
|
5
4
|
import { Schema } from "../schema/Schema.js";
|
|
6
5
|
import { toJsonSchema } from "../schema/to-json-schema.js";
|
|
7
6
|
import { z } from "zod";
|
|
@@ -12,11 +11,11 @@ export class Chat {
|
|
|
12
11
|
options;
|
|
13
12
|
messages = [];
|
|
14
13
|
executor;
|
|
15
|
-
constructor(provider, model, options = {}) {
|
|
14
|
+
constructor(provider, model, options = {}, retryConfig = { attempts: 1, delayMs: 0 }) {
|
|
16
15
|
this.provider = provider;
|
|
17
16
|
this.model = model;
|
|
18
17
|
this.options = options;
|
|
19
|
-
this.executor = new Executor(provider,
|
|
18
|
+
this.executor = new Executor(provider, retryConfig);
|
|
20
19
|
if (options.systemPrompt) {
|
|
21
20
|
this.messages.push({
|
|
22
21
|
role: "system",
|
|
@@ -355,8 +354,8 @@ export class Chat {
|
|
|
355
354
|
/**
|
|
356
355
|
* Streams the model's response to a user question.
|
|
357
356
|
*/
|
|
358
|
-
|
|
359
|
-
const streamer = new
|
|
360
|
-
|
|
357
|
+
stream(content) {
|
|
358
|
+
const streamer = new ChatStream(this.provider, this.model, this.options, this.messages);
|
|
359
|
+
return streamer.create(content);
|
|
361
360
|
}
|
|
362
361
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Message } from "./Message.js";
|
|
2
|
+
import { ChatOptions } from "./ChatOptions.js";
|
|
3
|
+
import { Provider, ChatChunk } from "../providers/Provider.js";
|
|
4
|
+
import { Stream } from "../streaming/Stream.js";
|
|
5
|
+
/**
|
|
6
|
+
* Internal handler for chat streaming logic.
|
|
7
|
+
* Wraps the provider's stream with side effects like history updates and events.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ChatStream {
|
|
10
|
+
private readonly provider;
|
|
11
|
+
private readonly model;
|
|
12
|
+
private readonly options;
|
|
13
|
+
private messages;
|
|
14
|
+
constructor(provider: Provider, model: string, options?: ChatOptions, messages?: Message[]);
|
|
15
|
+
/**
|
|
16
|
+
* Read-only access to message history
|
|
17
|
+
*/
|
|
18
|
+
get history(): readonly Message[];
|
|
19
|
+
/**
|
|
20
|
+
* Creates a high-level Stream object for the chat response.
|
|
21
|
+
* @param content The user's question.
|
|
22
|
+
*/
|
|
23
|
+
create(content: string): Stream<ChatChunk>;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=ChatStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatStream.d.ts","sourceRoot":"","sources":["../../src/chat/ChatStream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAE/D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD;;;GAGG;AACH,qBAAa,UAAU;IAInB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAY;gBAGT,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,WAAgB,EAC1C,QAAQ,CAAC,EAAE,OAAO,EAAE;IAmBtB;;OAEG;IACH,IAAI,OAAO,IAAI,SAAS,OAAO,EAAE,CAEhC;IAED;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC;CAyE3C"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ChatResponseString } from "./ChatResponse.js";
|
|
2
|
+
import { Stream } from "../streaming/Stream.js";
|
|
3
|
+
/**
|
|
4
|
+
* Internal handler for chat streaming logic.
|
|
5
|
+
* Wraps the provider's stream with side effects like history updates and events.
|
|
6
|
+
*/
|
|
7
|
+
export class ChatStream {
|
|
8
|
+
provider;
|
|
9
|
+
model;
|
|
10
|
+
options;
|
|
11
|
+
messages;
|
|
12
|
+
constructor(provider, model, options = {}, messages) {
|
|
13
|
+
this.provider = provider;
|
|
14
|
+
this.model = model;
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.messages = messages ?? [];
|
|
17
|
+
// Only initialize if we're starting a new history
|
|
18
|
+
if (this.messages.length === 0) {
|
|
19
|
+
if (options.systemPrompt) {
|
|
20
|
+
this.messages.push({
|
|
21
|
+
role: "system",
|
|
22
|
+
content: options.systemPrompt,
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
if (options.messages) {
|
|
26
|
+
this.messages.push(...options.messages);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Read-only access to message history
|
|
32
|
+
*/
|
|
33
|
+
get history() {
|
|
34
|
+
return this.messages;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a high-level Stream object for the chat response.
|
|
38
|
+
* @param content The user's question.
|
|
39
|
+
*/
|
|
40
|
+
create(content) {
|
|
41
|
+
const controller = new AbortController();
|
|
42
|
+
// We create a wrapper async generator that handles our side effects
|
|
43
|
+
const sideEffectGenerator = async function* (provider, model, messages, options, abortController) {
|
|
44
|
+
messages.push({ role: "user", content });
|
|
45
|
+
if (!provider.stream) {
|
|
46
|
+
throw new Error("Streaming not supported by provider");
|
|
47
|
+
}
|
|
48
|
+
let full = "";
|
|
49
|
+
let fullReasoning = "";
|
|
50
|
+
let isFirst = true;
|
|
51
|
+
try {
|
|
52
|
+
for await (const chunk of provider.stream({
|
|
53
|
+
model,
|
|
54
|
+
messages,
|
|
55
|
+
temperature: options.temperature,
|
|
56
|
+
max_tokens: options.maxTokens,
|
|
57
|
+
signal: abortController.signal,
|
|
58
|
+
})) {
|
|
59
|
+
if (isFirst) {
|
|
60
|
+
if (options.onNewMessage)
|
|
61
|
+
options.onNewMessage();
|
|
62
|
+
isFirst = false;
|
|
63
|
+
}
|
|
64
|
+
if (chunk.content) {
|
|
65
|
+
full += chunk.content;
|
|
66
|
+
}
|
|
67
|
+
if (chunk.reasoning) {
|
|
68
|
+
fullReasoning += chunk.reasoning;
|
|
69
|
+
}
|
|
70
|
+
yield chunk;
|
|
71
|
+
}
|
|
72
|
+
// Finalize history
|
|
73
|
+
messages.push({
|
|
74
|
+
role: "assistant",
|
|
75
|
+
content: full,
|
|
76
|
+
// @ts-ignore
|
|
77
|
+
reasoning: fullReasoning || undefined
|
|
78
|
+
});
|
|
79
|
+
if (options.onEndMessage) {
|
|
80
|
+
options.onEndMessage(new ChatResponseString(full, { input_tokens: 0, output_tokens: 0, total_tokens: 0 }, model, fullReasoning || undefined));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
85
|
+
// Stream was aborted, we might still want to save what we got?
|
|
86
|
+
// For now just rethrow or handle as needed
|
|
87
|
+
}
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
return new Stream(() => sideEffectGenerator(this.provider, this.model, this.messages, this.options, controller), controller);
|
|
92
|
+
}
|
|
93
|
+
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Global configuration for Node-
|
|
2
|
+
* Global configuration for Node-NodeLLM providers.
|
|
3
3
|
* Values are initialized from environment variables but can be overridden programmatically.
|
|
4
4
|
*/
|
|
5
5
|
export interface NodeLLMConfig {
|
|
@@ -12,7 +12,8 @@ export interface NodeLLMConfig {
|
|
|
12
12
|
deepseekApiKey?: string;
|
|
13
13
|
deepseekApiBase?: string;
|
|
14
14
|
ollamaApiBase?: string;
|
|
15
|
-
|
|
15
|
+
openrouterApiKey?: string;
|
|
16
|
+
openrouterApiBase?: string;
|
|
16
17
|
}
|
|
17
18
|
declare class Configuration implements NodeLLMConfig {
|
|
18
19
|
openaiApiKey?: string;
|
|
@@ -24,7 +25,8 @@ declare class Configuration implements NodeLLMConfig {
|
|
|
24
25
|
deepseekApiKey?: string;
|
|
25
26
|
deepseekApiBase?: string;
|
|
26
27
|
ollamaApiBase?: string;
|
|
27
|
-
|
|
28
|
+
openrouterApiKey?: string;
|
|
29
|
+
openrouterApiBase?: string;
|
|
28
30
|
}
|
|
29
31
|
export declare const config: Configuration;
|
|
30
32
|
export {};
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,cAAM,aAAc,YAAW,aAAa;IACnC,YAAY,CAAC,EAAE,MAAM,CAAsC;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAuC;IAC7D,eAAe,CAAC,EAAE,MAAM,CAAyC;IACjE,gBAAgB,CAAC,EAAE,MAAM,CAA0C;IACnE,YAAY,CAAC,EAAE,MAAM,CAAsC;IAC3D,aAAa,CAAC,EAAE,MAAM,CAAuC;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAwC;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAyC;IACjE,aAAa,CAAC,EAAE,MAAM,CAAsE;IAC5F,gBAAgB,CAAC,EAAE,MAAM,CAA0C;IACnE,iBAAiB,CAAC,EAAE,MAAM,CAA2C;CAC7E;AAED,eAAO,MAAM,MAAM,eAAsB,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -8,5 +8,7 @@ class Configuration {
|
|
|
8
8
|
deepseekApiKey = process.env.DEEPSEEK_API_KEY?.trim();
|
|
9
9
|
deepseekApiBase = process.env.DEEPSEEK_API_BASE?.trim();
|
|
10
10
|
ollamaApiBase = process.env.OLLAMA_API_BASE?.trim() || "http://localhost:11434/v1";
|
|
11
|
+
openrouterApiKey = process.env.OPENROUTER_API_KEY?.trim();
|
|
12
|
+
openrouterApiBase = process.env.OPENROUTER_API_BASE?.trim();
|
|
11
13
|
}
|
|
12
14
|
export const config = new Configuration();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embedding.d.ts","sourceRoot":"","sources":["../../src/embedding/Embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Embedding.d.ts","sourceRoot":"","sources":["../../src/embedding/Embedding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,qBAAa,SAAS;IACpB,SAAgB,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC;IACpC,SAAgB,KAAK,EAAE,MAAM,CAAC;IAC9B,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,QAAQ,EAAE,iBAAiB;IAOvC;;OAEG;IACH,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;IAED;;OAEG;IACH,QAAQ,IAAI,MAAM;CAGnB"}
|
package/dist/errors/index.d.ts
CHANGED
|
@@ -63,4 +63,26 @@ export declare class NotFoundError extends LLMError {
|
|
|
63
63
|
export declare class CapabilityError extends LLMError {
|
|
64
64
|
constructor(message: string);
|
|
65
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Thrown when NodeLLM provider is not configured
|
|
68
|
+
*/
|
|
69
|
+
export declare class ProviderNotConfiguredError extends LLMError {
|
|
70
|
+
constructor();
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Thrown when a provider doesn't support a requested feature
|
|
74
|
+
*/
|
|
75
|
+
export declare class UnsupportedFeatureError extends LLMError {
|
|
76
|
+
readonly provider: string;
|
|
77
|
+
readonly feature: string;
|
|
78
|
+
constructor(provider: string, feature: string);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Thrown when a model doesn't support a requested capability
|
|
82
|
+
*/
|
|
83
|
+
export declare class ModelCapabilityError extends LLMError {
|
|
84
|
+
readonly model: string;
|
|
85
|
+
readonly capability: string;
|
|
86
|
+
constructor(model: string, capability: string);
|
|
87
|
+
}
|
|
66
88
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,QAAS,SAAQ,KAAK;aACY,IAAI,CAAC,EAAE,MAAM;gBAA9C,OAAO,EAAE,MAAM,EAAkB,IAAI,CAAC,EAAE,MAAM,YAAA;CAK3D;AAED;;GAEG;AACH,qBAAa,QAAS,SAAQ,QAAQ;aAGlB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,GAAG;aACT,QAAQ,CAAC,EAAE,MAAM;aACjB,KAAK,CAAC,EAAE,MAAM;gBAJ9B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,GAAG,EACT,QAAQ,CAAC,EAAE,MAAM,YAAA,EACjB,KAAK,CAAC,EAAE,MAAM,YAAA;CAIjC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM;CAI1E;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM;CAI1E;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,QAAQ;gBAC9B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,E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CAIlC;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,QAAQ;aAE9B,KAAK,EAAE,MAAM;aACb,UAAU,EAAE,MAAM;gBADlB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM;CAIrC"}
|
package/dist/errors/index.js
CHANGED
|
@@ -95,3 +95,35 @@ export class CapabilityError extends LLMError {
|
|
|
95
95
|
super(message, "CAPABILITY_ERROR");
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Thrown when NodeLLM provider is not configured
|
|
100
|
+
*/
|
|
101
|
+
export class ProviderNotConfiguredError extends LLMError {
|
|
102
|
+
constructor() {
|
|
103
|
+
super("NodeLLM provider not configured", "PROVIDER_NOT_CONFIGURED");
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Thrown when a provider doesn't support a requested feature
|
|
108
|
+
*/
|
|
109
|
+
export class UnsupportedFeatureError extends LLMError {
|
|
110
|
+
provider;
|
|
111
|
+
feature;
|
|
112
|
+
constructor(provider, feature) {
|
|
113
|
+
super(`${provider} does not support ${feature}`, "UNSUPPORTED_FEATURE");
|
|
114
|
+
this.provider = provider;
|
|
115
|
+
this.feature = feature;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Thrown when a model doesn't support a requested capability
|
|
120
|
+
*/
|
|
121
|
+
export class ModelCapabilityError extends LLMError {
|
|
122
|
+
model;
|
|
123
|
+
capability;
|
|
124
|
+
constructor(model, capability) {
|
|
125
|
+
super(`Model ${model} does not support ${capability}`, "MODEL_CAPABILITY_ERROR");
|
|
126
|
+
this.model = model;
|
|
127
|
+
this.capability = capability;
|
|
128
|
+
}
|
|
129
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
export
|
|
1
|
+
export * from "./chat/Message.js";
|
|
2
|
+
export * from "./chat/Content.js";
|
|
3
|
+
export * from "./chat/Tool.js";
|
|
4
|
+
export * from "./chat/ChatOptions.js";
|
|
5
|
+
export * from "./chat/ChatResponse.js";
|
|
6
|
+
export * from "./chat/Chat.js";
|
|
7
|
+
export * from "./chat/ChatStream.js";
|
|
8
|
+
export * from "./streaming/Stream.js";
|
|
9
9
|
export { z } from "zod";
|
|
10
|
-
export {
|
|
10
|
+
export { NodeLLM, Transcription, Moderation, Embedding } from "./llm.js";
|
|
11
11
|
export { config } from "./config.js";
|
|
12
12
|
export type { NodeLLMConfig } from "./config.js";
|
|
13
13
|
export { providerRegistry } from "./providers/registry.js";
|
|
14
|
-
export {
|
|
15
|
-
export { registerOpenAIProvider } from "./providers/openai/index.js";
|
|
16
|
-
export { registerAnthropicProvider } from "./providers/anthropic/index.js";
|
|
17
|
-
export { registerOllamaProvider, OllamaProvider } from "./providers/ollama/index.js";
|
|
18
|
-
export type { ImageRequest, ImageResponse } from "./providers/Provider.js";
|
|
19
|
-
export * from "./errors/index.js";
|
|
14
|
+
export { Schema } from "./schema/Schema.js";
|
|
20
15
|
//# sourceMappingURL=index.d.ts.map
|