adk-llm-bridge 0.3.2 → 0.3.3
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 +62 -271
- package/dist/constants.d.ts +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/core/base-provider-llm.d.ts +0 -3
- package/dist/core/base-provider-llm.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +9 -8
- package/dist/providers/anthropic/constants.d.ts +2 -0
- package/dist/providers/anthropic/constants.d.ts.map +1 -1
- package/dist/providers/openai/constants.d.ts +2 -0
- package/dist/providers/openai/constants.d.ts.map +1 -1
- package/dist/providers/xai/constants.d.ts +2 -0
- package/dist/providers/xai/constants.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -7,13 +7,12 @@ Use **any LLM** with [Google ADK TypeScript](https://github.com/google/adk-js) i
|
|
|
7
7
|
|
|
8
8
|
## Why?
|
|
9
9
|
|
|
10
|
-
Google ADK TypeScript comes with built-in Gemini support. This
|
|
10
|
+
Google ADK TypeScript comes with built-in Gemini support. This bridge extends it to work with **any model** from providers like Anthropic, OpenAI, Meta, and more—while keeping all ADK features like multi-agent orchestration, tool calling, and streaming.
|
|
11
11
|
|
|
12
12
|
### Key Benefits
|
|
13
13
|
|
|
14
|
-
- **Minimal** — ~10KB bundle (~3KB gzipped), single dependency (`openai`)
|
|
15
14
|
- **Simple** — 3 lines to integrate any model
|
|
16
|
-
- **
|
|
15
|
+
- **Battle-tested** — Built on the official OpenAI and Anthropic SDKs
|
|
17
16
|
- **Compatible** — Works with any OpenAI-compatible API (AI Gateway, OpenRouter, etc.)
|
|
18
17
|
|
|
19
18
|
## Supported Providers
|
|
@@ -27,36 +26,6 @@ Google ADK TypeScript comes with built-in Gemini support. This lightweight bridg
|
|
|
27
26
|
| **[xAI](https://x.ai/)** | Grok models | Direct API access |
|
|
28
27
|
| **Custom (OpenAI-compatible)** | Any model | Ollama, vLLM, Azure OpenAI, LM Studio, etc. |
|
|
29
28
|
|
|
30
|
-
## How It Works
|
|
31
|
-
|
|
32
|
-
```mermaid
|
|
33
|
-
flowchart LR
|
|
34
|
-
subgraph Your App
|
|
35
|
-
A[LlmAgent] --> B[adk-llm-bridge]
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
subgraph adk-llm-bridge
|
|
39
|
-
B --> C[AIGatewayLlm]
|
|
40
|
-
B --> D[OpenRouterLlm]
|
|
41
|
-
B --> E[OpenAILlm]
|
|
42
|
-
B --> F[AnthropicLlm]
|
|
43
|
-
B --> G[XAILlm]
|
|
44
|
-
B --> H[CustomLlm]
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
C --> I[Vercel AI Gateway]
|
|
48
|
-
D --> J[OpenRouter]
|
|
49
|
-
E --> K[OpenAI API]
|
|
50
|
-
F --> L[Anthropic API]
|
|
51
|
-
G --> M[xAI API]
|
|
52
|
-
H --> N[Any OpenAI-compatible API]
|
|
53
|
-
|
|
54
|
-
I --> O[100+ Models]
|
|
55
|
-
J --> O
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
The package converts ADK's internal request format to OpenAI-compatible format, sends it through your chosen gateway, and converts the response back to ADK format.
|
|
59
|
-
|
|
60
29
|
## Installation
|
|
61
30
|
|
|
62
31
|
```bash
|
|
@@ -73,81 +42,55 @@ npm install adk-llm-bridge @google/adk
|
|
|
73
42
|
|
|
74
43
|
## Quick Start
|
|
75
44
|
|
|
76
|
-
Just 3 lines to use Claude, GPT, Gemini, or any model with ADK:
|
|
77
|
-
|
|
78
45
|
```typescript
|
|
79
|
-
import { LlmAgent
|
|
80
|
-
import {
|
|
81
|
-
|
|
82
|
-
LLMRegistry.register(AIGatewayLlm); // 2. Register
|
|
46
|
+
import { LlmAgent } from '@google/adk';
|
|
47
|
+
import { AIGateway } from 'adk-llm-bridge';
|
|
83
48
|
|
|
84
|
-
const agent = new LlmAgent({
|
|
49
|
+
const agent = new LlmAgent({
|
|
85
50
|
name: 'assistant',
|
|
86
|
-
model: 'anthropic/claude-sonnet-4',
|
|
51
|
+
model: AIGateway('anthropic/claude-sonnet-4'),
|
|
87
52
|
instruction: 'You are a helpful assistant.',
|
|
88
53
|
});
|
|
89
54
|
```
|
|
90
55
|
|
|
91
56
|
That's it. All ADK features work: tools, streaming, multi-agent, etc.
|
|
92
57
|
|
|
93
|
-
###
|
|
58
|
+
### Other Providers
|
|
94
59
|
|
|
95
60
|
```typescript
|
|
96
|
-
import {
|
|
97
|
-
import { OpenRouterLlm } from 'adk-llm-bridge';
|
|
61
|
+
import { OpenRouter, OpenAI, Anthropic, XAI, Custom } from 'adk-llm-bridge';
|
|
98
62
|
|
|
99
|
-
|
|
63
|
+
// OpenRouter - 100+ models with routing
|
|
64
|
+
model: OpenRouter('anthropic/claude-sonnet-4')
|
|
100
65
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
model: 'anthropic/claude-sonnet-4',
|
|
104
|
-
instruction: 'You are a helpful assistant.',
|
|
105
|
-
});
|
|
106
|
-
```
|
|
107
|
-
|
|
108
|
-
### With Direct Providers (OpenAI, Anthropic, xAI)
|
|
66
|
+
// OpenAI - Direct API
|
|
67
|
+
model: OpenAI('gpt-4.1')
|
|
109
68
|
|
|
110
|
-
|
|
69
|
+
// Anthropic - Direct API
|
|
70
|
+
model: Anthropic('claude-sonnet-4-5')
|
|
111
71
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
import { OpenAI, Anthropic, XAI } from 'adk-llm-bridge';
|
|
72
|
+
// xAI - Direct API
|
|
73
|
+
model: XAI('grok-3-beta')
|
|
115
74
|
|
|
116
|
-
//
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
model: OpenAI('gpt-4.1'),
|
|
120
|
-
instruction: 'You are a helpful assistant.',
|
|
121
|
-
});
|
|
75
|
+
// Local models (LM Studio, Ollama, etc.)
|
|
76
|
+
model: Custom('your-model', { baseURL: 'http://localhost:1234/v1' })
|
|
77
|
+
```
|
|
122
78
|
|
|
123
|
-
|
|
124
|
-
const claudeAgent = new LlmAgent({
|
|
125
|
-
name: 'assistant',
|
|
126
|
-
model: Anthropic('claude-sonnet-4-5'),
|
|
127
|
-
instruction: 'You are a helpful assistant.',
|
|
128
|
-
});
|
|
79
|
+
See the [examples](./examples) directory for complete implementations.
|
|
129
80
|
|
|
130
|
-
|
|
131
|
-
const grokAgent = new LlmAgent({
|
|
132
|
-
name: 'assistant',
|
|
133
|
-
model: XAI('grok-3'),
|
|
134
|
-
instruction: 'You are a helpful assistant.',
|
|
135
|
-
});
|
|
136
|
-
```
|
|
81
|
+
### Using LLMRegistry (Alternative)
|
|
137
82
|
|
|
138
|
-
|
|
83
|
+
You can also register providers with ADK's LLMRegistry to use string-based model names:
|
|
139
84
|
|
|
140
85
|
```typescript
|
|
141
|
-
import { LlmAgent } from '@google/adk';
|
|
142
|
-
import {
|
|
86
|
+
import { LlmAgent, LLMRegistry } from '@google/adk';
|
|
87
|
+
import { AnthropicLlm } from 'adk-llm-bridge';
|
|
88
|
+
|
|
89
|
+
LLMRegistry.register(AnthropicLlm);
|
|
143
90
|
|
|
144
91
|
const agent = new LlmAgent({
|
|
145
92
|
name: 'assistant',
|
|
146
|
-
model:
|
|
147
|
-
name: 'ollama',
|
|
148
|
-
model: 'llama3',
|
|
149
|
-
baseURL: 'http://localhost:11434/v1',
|
|
150
|
-
}),
|
|
93
|
+
model: 'claude-sonnet-4-5', // String-based model name
|
|
151
94
|
instruction: 'You are a helpful assistant.',
|
|
152
95
|
});
|
|
153
96
|
```
|
|
@@ -178,106 +121,29 @@ XAI_API_KEY=your-xai-key
|
|
|
178
121
|
|
|
179
122
|
### Programmatic Configuration
|
|
180
123
|
|
|
124
|
+
Pass options directly to the factory functions:
|
|
125
|
+
|
|
181
126
|
```typescript
|
|
182
|
-
import {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
registerAnthropic,
|
|
187
|
-
registerXAI,
|
|
188
|
-
} from 'adk-llm-bridge';
|
|
189
|
-
|
|
190
|
-
// AI Gateway
|
|
191
|
-
registerAIGateway({
|
|
127
|
+
import { AIGateway, OpenRouter, Anthropic } from 'adk-llm-bridge';
|
|
128
|
+
|
|
129
|
+
// AI Gateway with custom URL
|
|
130
|
+
model: AIGateway('anthropic/claude-sonnet-4', {
|
|
192
131
|
apiKey: process.env.MY_API_KEY,
|
|
193
132
|
baseURL: 'https://my-gateway.example.com/v1',
|
|
194
|
-
})
|
|
133
|
+
})
|
|
195
134
|
|
|
196
|
-
// OpenRouter
|
|
197
|
-
|
|
135
|
+
// OpenRouter with site info
|
|
136
|
+
model: OpenRouter('anthropic/claude-sonnet-4', {
|
|
198
137
|
apiKey: process.env.OPENROUTER_API_KEY,
|
|
199
138
|
siteUrl: 'https://your-site.com',
|
|
200
139
|
appName: 'Your App',
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
// Direct providers
|
|
204
|
-
registerOpenAI({ apiKey: process.env.OPENAI_API_KEY });
|
|
205
|
-
registerAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
|
|
206
|
-
registerXAI({ apiKey: process.env.XAI_API_KEY });
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### Factory Functions (Per-Agent Config)
|
|
210
|
-
|
|
211
|
-
```typescript
|
|
212
|
-
import { LlmAgent } from '@google/adk';
|
|
213
|
-
import { AIGateway, OpenRouter, OpenAI, Anthropic, XAI, Custom } from 'adk-llm-bridge';
|
|
214
|
-
|
|
215
|
-
// AI Gateway
|
|
216
|
-
const agent1 = new LlmAgent({
|
|
217
|
-
name: 'assistant',
|
|
218
|
-
model: AIGateway('anthropic/claude-sonnet-4', { timeout: 30000 }),
|
|
219
|
-
instruction: 'You are helpful.',
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
// OpenRouter with provider routing
|
|
223
|
-
const agent2 = new LlmAgent({
|
|
224
|
-
name: 'fast-assistant',
|
|
225
|
-
model: OpenRouter('anthropic/claude-sonnet-4', {
|
|
226
|
-
provider: {
|
|
227
|
-
sort: 'latency',
|
|
228
|
-
allow_fallbacks: true,
|
|
229
|
-
},
|
|
230
|
-
}),
|
|
231
|
-
instruction: 'You are helpful.',
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
// Direct providers
|
|
235
|
-
const agent3 = new LlmAgent({
|
|
236
|
-
name: 'openai-assistant',
|
|
237
|
-
model: OpenAI('gpt-4.1'),
|
|
238
|
-
instruction: 'You are helpful.',
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
const agent4 = new LlmAgent({
|
|
242
|
-
name: 'claude-assistant',
|
|
243
|
-
model: Anthropic('claude-sonnet-4-5', { maxTokens: 8192 }),
|
|
244
|
-
instruction: 'You are helpful.',
|
|
245
|
-
});
|
|
140
|
+
})
|
|
246
141
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
})
|
|
252
|
-
|
|
253
|
-
// Custom provider (Ollama, vLLM, etc.)
|
|
254
|
-
const agent6 = new LlmAgent({
|
|
255
|
-
name: 'local-assistant',
|
|
256
|
-
model: Custom('llama3', { baseURL: 'http://localhost:11434/v1' }),
|
|
257
|
-
instruction: 'You are helpful.',
|
|
258
|
-
});
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## OpenRouter Features
|
|
262
|
-
|
|
263
|
-
OpenRouter provides additional features not available in AI Gateway:
|
|
264
|
-
|
|
265
|
-
```typescript
|
|
266
|
-
import { OpenRouter } from 'adk-llm-bridge';
|
|
267
|
-
|
|
268
|
-
const llm = OpenRouter('anthropic/claude-sonnet-4', {
|
|
269
|
-
// Ranking headers (improves your rate limits)
|
|
270
|
-
siteUrl: 'https://your-site.com',
|
|
271
|
-
appName: 'Your App',
|
|
272
|
-
|
|
273
|
-
// Provider routing
|
|
274
|
-
provider: {
|
|
275
|
-
order: ['Anthropic', 'Google'], // Prefer specific providers
|
|
276
|
-
sort: 'latency', // or 'price', 'throughput'
|
|
277
|
-
allow_fallbacks: true, // Fallback if primary fails
|
|
278
|
-
data_collection: 'deny', // Opt-out of data collection
|
|
279
|
-
},
|
|
280
|
-
});
|
|
142
|
+
// Anthropic with custom max tokens
|
|
143
|
+
model: Anthropic('claude-sonnet-4-5', {
|
|
144
|
+
apiKey: process.env.ANTHROPIC_API_KEY,
|
|
145
|
+
maxTokens: 8192,
|
|
146
|
+
})
|
|
281
147
|
```
|
|
282
148
|
|
|
283
149
|
## Model Format
|
|
@@ -322,12 +188,10 @@ Browse all models:
|
|
|
322
188
|
## Tool Calling Example
|
|
323
189
|
|
|
324
190
|
```typescript
|
|
325
|
-
import { FunctionTool, LlmAgent
|
|
326
|
-
import {
|
|
191
|
+
import { FunctionTool, LlmAgent } from '@google/adk';
|
|
192
|
+
import { Anthropic } from 'adk-llm-bridge';
|
|
327
193
|
import { z } from 'zod';
|
|
328
194
|
|
|
329
|
-
LLMRegistry.register(AIGatewayLlm);
|
|
330
|
-
|
|
331
195
|
const getWeather = new FunctionTool({
|
|
332
196
|
name: 'get_weather',
|
|
333
197
|
description: 'Get current weather for a city',
|
|
@@ -341,75 +205,28 @@ const getWeather = new FunctionTool({
|
|
|
341
205
|
|
|
342
206
|
const agent = new LlmAgent({
|
|
343
207
|
name: 'weather-assistant',
|
|
344
|
-
model: '
|
|
208
|
+
model: Anthropic('claude-sonnet-4-5'),
|
|
345
209
|
instruction: 'You help users check the weather.',
|
|
346
210
|
tools: [getWeather],
|
|
347
211
|
});
|
|
348
212
|
```
|
|
349
213
|
|
|
350
|
-
## Using with adk-devtools
|
|
351
|
-
|
|
352
|
-
When using `adk-devtools`, import `LLMRegistry` from `@google/adk` directly:
|
|
353
|
-
|
|
354
|
-
```typescript
|
|
355
|
-
import { LlmAgent, LLMRegistry } from '@google/adk';
|
|
356
|
-
import { AIGatewayLlm, OpenRouterLlm } from 'adk-llm-bridge';
|
|
357
|
-
|
|
358
|
-
// Register the provider you want to use
|
|
359
|
-
LLMRegistry.register(AIGatewayLlm);
|
|
360
|
-
// or
|
|
361
|
-
LLMRegistry.register(OpenRouterLlm);
|
|
362
|
-
|
|
363
|
-
export const rootAgent = new LlmAgent({
|
|
364
|
-
name: 'assistant',
|
|
365
|
-
model: 'anthropic/claude-sonnet-4',
|
|
366
|
-
instruction: 'You are helpful.',
|
|
367
|
-
});
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
Then run:
|
|
371
|
-
```bash
|
|
372
|
-
bunx @google/adk-devtools web
|
|
373
|
-
```
|
|
374
|
-
|
|
375
214
|
## API Reference
|
|
376
215
|
|
|
377
|
-
### Classes
|
|
378
|
-
|
|
379
|
-
| Class | Description |
|
|
380
|
-
|-------|-------------|
|
|
381
|
-
| `AIGatewayLlm` | LLM class for Vercel AI Gateway |
|
|
382
|
-
| `OpenRouterLlm` | LLM class for OpenRouter |
|
|
383
|
-
| `OpenAILlm` | LLM class for OpenAI API (gpt-*, o1-*, o3-*) |
|
|
384
|
-
| `AnthropicLlm` | LLM class for Anthropic API (claude-*) |
|
|
385
|
-
| `XAILlm` | LLM class for xAI API (grok-*) |
|
|
386
|
-
| `CustomLlm` | LLM class for any compatible API |
|
|
387
|
-
|
|
388
216
|
### Factory Functions
|
|
389
217
|
|
|
390
218
|
| Function | Description |
|
|
391
219
|
|----------|-------------|
|
|
392
|
-
| `AIGateway(model, options?)` |
|
|
393
|
-
| `OpenRouter(model, options?)` |
|
|
394
|
-
| `OpenAI(model, options?)` |
|
|
395
|
-
| `Anthropic(model, options?)` |
|
|
396
|
-
| `XAI(model, options?)` |
|
|
397
|
-
| `
|
|
398
|
-
| `Custom(model, options)` | Shorthand for `createCustomLlm` |
|
|
399
|
-
|
|
400
|
-
### Registration Functions
|
|
401
|
-
|
|
402
|
-
| Function | Description |
|
|
403
|
-
|----------|-------------|
|
|
404
|
-
| `registerAIGateway(options?)` | Register AIGatewayLlm with LLMRegistry |
|
|
405
|
-
| `registerOpenRouter(options?)` | Register OpenRouterLlm with LLMRegistry |
|
|
406
|
-
| `registerOpenAI(options?)` | Register OpenAILlm with LLMRegistry |
|
|
407
|
-
| `registerAnthropic(options?)` | Register AnthropicLlm with LLMRegistry |
|
|
408
|
-
| `registerXAI(options?)` | Register XAILlm with LLMRegistry |
|
|
220
|
+
| `AIGateway(model, options?)` | Vercel AI Gateway (100+ models) |
|
|
221
|
+
| `OpenRouter(model, options?)` | OpenRouter (100+ models) |
|
|
222
|
+
| `OpenAI(model, options?)` | OpenAI direct API |
|
|
223
|
+
| `Anthropic(model, options?)` | Anthropic direct API |
|
|
224
|
+
| `XAI(model, options?)` | xAI direct API |
|
|
225
|
+
| `Custom(model, options)` | Any OpenAI-compatible API |
|
|
409
226
|
|
|
410
227
|
### Configuration Options
|
|
411
228
|
|
|
412
|
-
**AIGateway
|
|
229
|
+
**AIGateway:**
|
|
413
230
|
|
|
414
231
|
| Option | Type | Default | Description |
|
|
415
232
|
|--------|------|---------|-------------|
|
|
@@ -418,7 +235,7 @@ bunx @google/adk-devtools web
|
|
|
418
235
|
| `timeout` | `number` | `60000` | Request timeout (ms) |
|
|
419
236
|
| `maxRetries` | `number` | `2` | Max retry attempts |
|
|
420
237
|
|
|
421
|
-
**OpenRouter
|
|
238
|
+
**OpenRouter:
|
|
422
239
|
|
|
423
240
|
| Option | Type | Default | Description |
|
|
424
241
|
|--------|------|---------|-------------|
|
|
@@ -430,7 +247,7 @@ bunx @google/adk-devtools web
|
|
|
430
247
|
| `timeout` | `number` | `60000` | Request timeout (ms) |
|
|
431
248
|
| `maxRetries` | `number` | `2` | Max retry attempts |
|
|
432
249
|
|
|
433
|
-
**OpenAI
|
|
250
|
+
**OpenAI:
|
|
434
251
|
|
|
435
252
|
| Option | Type | Default | Description |
|
|
436
253
|
|--------|------|---------|-------------|
|
|
@@ -440,7 +257,7 @@ bunx @google/adk-devtools web
|
|
|
440
257
|
| `timeout` | `number` | `60000` | Request timeout (ms) |
|
|
441
258
|
| `maxRetries` | `number` | `2` | Max retry attempts |
|
|
442
259
|
|
|
443
|
-
**Anthropic
|
|
260
|
+
**Anthropic:
|
|
444
261
|
|
|
445
262
|
| Option | Type | Default | Description |
|
|
446
263
|
|--------|------|---------|-------------|
|
|
@@ -449,7 +266,7 @@ bunx @google/adk-devtools web
|
|
|
449
266
|
| `timeout` | `number` | `60000` | Request timeout (ms) |
|
|
450
267
|
| `maxRetries` | `number` | `2` | Max retry attempts |
|
|
451
268
|
|
|
452
|
-
**XAI
|
|
269
|
+
**XAI:
|
|
453
270
|
|
|
454
271
|
| Option | Type | Default | Description |
|
|
455
272
|
|--------|------|---------|-------------|
|
|
@@ -457,7 +274,7 @@ bunx @google/adk-devtools web
|
|
|
457
274
|
| `timeout` | `number` | `60000` | Request timeout (ms) |
|
|
458
275
|
| `maxRetries` | `number` | `2` | Max retry attempts |
|
|
459
276
|
|
|
460
|
-
**
|
|
277
|
+
**Custom:
|
|
461
278
|
|
|
462
279
|
| Option | Type | Default | Description |
|
|
463
280
|
|--------|------|---------|-------------|
|
|
@@ -471,48 +288,22 @@ bunx @google/adk-devtools web
|
|
|
471
288
|
| `timeout` | `number` | `60000` | Request timeout (ms) |
|
|
472
289
|
| `maxRetries` | `number` | `2` | Max retry attempts |
|
|
473
290
|
|
|
474
|
-
### Custom Provider Examples
|
|
475
|
-
|
|
476
|
-
**Ollama (local):**
|
|
477
|
-
```typescript
|
|
478
|
-
const llm = createCustomLlm({
|
|
479
|
-
name: 'ollama',
|
|
480
|
-
baseURL: 'http://localhost:11434/v1',
|
|
481
|
-
model: 'llama3',
|
|
482
|
-
});
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
**Azure OpenAI:**
|
|
486
|
-
```typescript
|
|
487
|
-
const llm = createCustomLlm({
|
|
488
|
-
name: 'azure',
|
|
489
|
-
baseURL: 'https://{resource}.openai.azure.com/openai/deployments/{deployment}',
|
|
490
|
-
model: 'gpt-4',
|
|
491
|
-
headers: { 'api-key': process.env.AZURE_API_KEY },
|
|
492
|
-
queryParams: { 'api-version': '2024-02-01' },
|
|
493
|
-
});
|
|
494
|
-
```
|
|
495
|
-
|
|
496
|
-
**vLLM / LM Studio:**
|
|
497
|
-
```typescript
|
|
498
|
-
const llm = createCustomLlm({
|
|
499
|
-
baseURL: 'http://localhost:8000/v1',
|
|
500
|
-
model: 'meta-llama/Llama-3-8b',
|
|
501
|
-
});
|
|
502
|
-
```
|
|
503
|
-
|
|
504
291
|
## Examples
|
|
505
292
|
|
|
506
293
|
See the [examples](./examples) directory:
|
|
507
294
|
|
|
508
295
|
- **[basic-agent-ai-gateway](./examples/basic-agent-ai-gateway)** - Multi-agent HelpDesk with AI Gateway
|
|
509
296
|
- **[basic-agent-openrouter](./examples/basic-agent-openrouter)** - Multi-agent HelpDesk with OpenRouter
|
|
297
|
+
- **[basic-agent-openai](./examples/basic-agent-openai)** - Multi-agent HelpDesk with OpenAI
|
|
298
|
+
- **[basic-agent-anthropic](./examples/basic-agent-anthropic)** - Multi-agent HelpDesk with Anthropic
|
|
299
|
+
- **[basic-agent-xai](./examples/basic-agent-xai)** - Multi-agent HelpDesk with xAI
|
|
300
|
+
- **[basic-agent-lmstudio](./examples/basic-agent-lmstudio)** - Multi-agent HelpDesk with LM Studio
|
|
510
301
|
- **[express-server](./examples/express-server)** - Production HTTP API with sessions, streaming, tools
|
|
511
302
|
|
|
512
303
|
## Requirements
|
|
513
304
|
|
|
514
305
|
- Node.js >= 18.0.0
|
|
515
|
-
- `@google/adk` >= 0.2.
|
|
306
|
+
- `@google/adk` >= 0.2.2
|
|
516
307
|
|
|
517
308
|
## Contributing
|
|
518
309
|
|
package/dist/constants.d.ts
CHANGED
|
@@ -38,6 +38,8 @@ export declare const DEFAULT_MAX_RETRIES = 2;
|
|
|
38
38
|
* Matches any model identifier with the format "provider/model".
|
|
39
39
|
* AI Gateway validates actual model availability at runtime.
|
|
40
40
|
*
|
|
41
|
+
* Note: Do not include ^ or $ anchors - ADK's LLMRegistry adds them automatically.
|
|
42
|
+
*
|
|
41
43
|
* @constant
|
|
42
44
|
* @example
|
|
43
45
|
* ```typescript
|
|
@@ -82,6 +84,8 @@ export declare const OPENROUTER_BASE_URL = "https://openrouter.ai/api/v1";
|
|
|
82
84
|
*
|
|
83
85
|
* Uses the same "provider/model" format as AI Gateway.
|
|
84
86
|
*
|
|
87
|
+
* Note: Do not include ^ or $ anchors - ADK's LLMRegistry adds them automatically.
|
|
88
|
+
*
|
|
85
89
|
* @constant
|
|
86
90
|
* @example
|
|
87
91
|
* ```typescript
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,oCAAoC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAMH;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,oCAAoC,CAAC;AAElE;;;;;GAKG;AACH,eAAO,MAAM,eAAe,QAAS,CAAC;AAEtC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAe,CAAC;AAE9D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,GAAG;IACd,uDAAuD;;IAGvD,kDAAkD;;IAGlD,wEAAwE;;IAGxE,uEAAuE;;CAE/D,CAAC;AAMX;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,iCAAiC,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAe,CAAC;AAEzE;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,cAAc;IACzB,kDAAkD;;IAGlD,4DAA4D;;IAG5D,4DAA4D;;CAEpD,CAAC;AAMX;;;;;;GAMG;AACH,eAAO,MAAM,YAAY;IACvB,6CAA6C;;IAG7C,6CAA6C;;CAErC,CAAC"}
|
|
@@ -14,7 +14,6 @@
|
|
|
14
14
|
import type { BaseLlmConnection, LlmRequest, LlmResponse } from "@google/adk";
|
|
15
15
|
import { BaseLlm } from "@google/adk";
|
|
16
16
|
import type { BaseProviderConfig } from "../types";
|
|
17
|
-
declare const BASE_MODEL_SYMBOL: unique symbol;
|
|
18
17
|
/**
|
|
19
18
|
* Abstract base class for all LLM providers in adk-llm-bridge.
|
|
20
19
|
*
|
|
@@ -46,7 +45,6 @@ declare const BASE_MODEL_SYMBOL: unique symbol;
|
|
|
46
45
|
* @see {@link OpenAICompatibleLlm} for OpenAI-compatible API implementations
|
|
47
46
|
*/
|
|
48
47
|
export declare abstract class BaseProviderLlm extends BaseLlm {
|
|
49
|
-
readonly [BASE_MODEL_SYMBOL]: true;
|
|
50
48
|
/**
|
|
51
49
|
* Provider configuration.
|
|
52
50
|
*
|
|
@@ -109,5 +107,4 @@ export declare abstract class BaseProviderLlm extends BaseLlm {
|
|
|
109
107
|
*/
|
|
110
108
|
protected createErrorResponse(error: unknown, prefix: string): LlmResponse;
|
|
111
109
|
}
|
|
112
|
-
export {};
|
|
113
110
|
//# sourceMappingURL=base-provider-llm.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-provider-llm.d.ts","sourceRoot":"","sources":["../../src/core/base-provider-llm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"base-provider-llm.d.ts","sourceRoot":"","sources":["../../src/core/base-provider-llm.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,8BAAsB,eAAgB,SAAQ,OAAO;IACnD;;;;;;OAMG;IACH,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,kBAAkB,CAAC;IAE9C;;;;OAIG;gBACS,MAAM,EAAE,kBAAkB;IAKtC;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,oBAAoB,CAC3B,UAAU,EAAE,UAAU,EACtB,MAAM,CAAC,EAAE,OAAO,GACf,cAAc,CAAC,WAAW,EAAE,IAAI,CAAC;IAEpC;;;;;;;;;OASG;IACG,OAAO,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAMxD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,WAAW;CAe3E"}
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@
|
|
|
57
57
|
* @see {@link https://github.com/pailat/adk-llm-bridge|GitHub Repository}
|
|
58
58
|
* @see {@link https://google.github.io/adk-docs/|Google ADK Documentation}
|
|
59
59
|
*/
|
|
60
|
+
export { BaseLlm } from "@google/adk";
|
|
60
61
|
export { BaseProviderLlm } from "./core/base-provider-llm";
|
|
61
62
|
export type { OpenAIClientConfig } from "./core/openai-compatible-llm";
|
|
62
63
|
export { OpenAICompatibleLlm } from "./core/openai-compatible-llm";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;AAQH,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAMtC,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,YAAY,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAMnE,OAAO,EACL,SAAS,EACT,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACL,sBAAsB,EACtB,UAAU,EACV,aAAa,EACb,kBAAkB,GACnB,MAAM,wBAAwB,CAAC;AAMhC,OAAO,EACL,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,cAAc,GACf,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAM5E,OAAO,EACL,SAAS,EACT,YAAY,EACZ,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EACL,MAAM,EACN,SAAS,EACT,KAAK,uBAAuB,EAC5B,eAAe,GAChB,MAAM,oBAAoB,CAAC;AAM5B,YAAY,EAEV,eAAe,EAEf,uBAAuB,EACvB,wBAAwB,EAExB,kBAAkB,EAElB,eAAe,EAEf,oBAAoB,EACpB,qBAAqB,EAErB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EACjB,iBAAiB,EAEjB,mBAAmB,EAEnB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,SAAS,CAAC;AAMjB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,yBAAyB,EACzB,YAAY,GACb,MAAM,aAAa,CAAC;AAMrB,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,mBAAmB,EAEnB,SAAS,EAET,iBAAiB,GAClB,MAAM,UAAU,CAAC;AAMlB,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,eAAe,EACf,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC"}
|