@agentskit/adapters 0.4.0 → 0.5.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 +65 -0
- package/dist/index.cjs +557 -32
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +189 -2
- package/dist/index.d.ts +189 -2
- package/dist/index.js +544 -33
- package/dist/index.js.map +1 -1
- package/package.json +23 -5
package/README.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# @agentskit/adapters
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+
|
|
5
|
+
Connect to any LLM provider — and swap between them — without touching your app code.
|
|
6
|
+
|
|
7
|
+
## Why
|
|
8
|
+
|
|
9
|
+
- **Vendor independence** — switch from OpenAI to Anthropic to a local Ollama model by changing one line; your hooks, runtime, and tools stay untouched
|
|
10
|
+
- **10+ providers included** — Anthropic, OpenAI, Gemini, Ollama, DeepSeek, Grok, Kimi, LangChain, Vercel AI SDK, and any raw `ReadableStream`
|
|
11
|
+
- **Embedder functions built in** — the same adapter pattern covers text embeddings, so you can reuse provider config for both chat and RAG
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @agentskit/adapters
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick example
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
import { anthropic, openai, ollama } from '@agentskit/adapters'
|
|
23
|
+
import { createRuntime } from '@agentskit/runtime'
|
|
24
|
+
|
|
25
|
+
// Switch provider by swapping one import
|
|
26
|
+
const adapter = anthropic({ apiKey: process.env.ANTHROPIC_API_KEY, model: 'claude-sonnet-4-6' })
|
|
27
|
+
// const adapter = openai({ apiKey: process.env.OPENAI_API_KEY, model: 'gpt-4o' })
|
|
28
|
+
// const adapter = ollama({ model: 'llama3.1' })
|
|
29
|
+
|
|
30
|
+
const runtime = createRuntime({ adapter })
|
|
31
|
+
const result = await runtime.run('Summarize the latest AI news')
|
|
32
|
+
console.log(result.content)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Embeddings (for RAG)
|
|
36
|
+
|
|
37
|
+
Use the same package for vector embeddings — wire `openaiEmbedder`, `geminiEmbedder`, or `ollamaEmbedder` into [`@agentskit/rag`](https://www.npmjs.com/package/@agentskit/rag):
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
import { openaiEmbedder } from '@agentskit/adapters'
|
|
41
|
+
import { createRAG } from '@agentskit/rag'
|
|
42
|
+
import { fileVectorMemory } from '@agentskit/memory'
|
|
43
|
+
|
|
44
|
+
const rag = createRAG({
|
|
45
|
+
embed: openaiEmbedder({ apiKey: process.env.OPENAI_API_KEY! }),
|
|
46
|
+
store: fileVectorMemory({ path: './vectors' }),
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Next steps
|
|
51
|
+
|
|
52
|
+
- Pair adapters with [`@agentskit/runtime`](https://www.npmjs.com/package/@agentskit/runtime), [`@agentskit/react`](https://www.npmjs.com/package/@agentskit/react), or [`@agentskit/ink`](https://www.npmjs.com/package/@agentskit/ink) — the adapter instance is the only provider-specific piece
|
|
53
|
+
|
|
54
|
+
## Ecosystem
|
|
55
|
+
|
|
56
|
+
| Package | Role |
|
|
57
|
+
|---------|------|
|
|
58
|
+
| [@agentskit/core](https://www.npmjs.com/package/@agentskit/core) | `Adapter`, `EmbedFn`, types |
|
|
59
|
+
| [@agentskit/runtime](https://www.npmjs.com/package/@agentskit/runtime) | Headless `createRuntime` |
|
|
60
|
+
| [@agentskit/rag](https://www.npmjs.com/package/@agentskit/rag) | `createRAG` + embedders |
|
|
61
|
+
| [@agentskit/memory](https://www.npmjs.com/package/@agentskit/memory) | Vector + chat memory backends |
|
|
62
|
+
|
|
63
|
+
## Docs
|
|
64
|
+
|
|
65
|
+
[Full documentation](https://emersonbraun.github.io/agentskit/)
|