vecbox 0.1.0 → 0.2.1
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 +100 -46
- package/dist/index.cjs +164 -204
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +26 -36
- package/dist/index.d.ts +26 -36
- package/dist/index.js +171 -205
- package/dist/index.js.map +1 -1
- package/dist/llama_embedding-EC3MWSUZ.node +0 -0
- package/native/README.md +67 -0
- package/native/binding.gyp +65 -0
- package/native/index.js +39 -0
- package/native/llama_embedding.cpp +179 -0
- package/native/llama_embedding_simple.cpp +111 -0
- package/native/package-lock.json +1277 -0
- package/native/package.json +26 -0
- package/package.json +7 -6
- package/src/factory/EmbeddingFactory.ts +0 -4
- package/src/images/vecbox.png +0 -0
- package/src/providers/gemini.ts +2 -2
- package/src/providers/llamacpp.ts +84 -6
- package/src/types/index.ts +0 -2
- package/src/images/embed-kit.png +0 -0
- package/src/providers/claude.ts +0 -78
- package/src/providers/deepseek.ts +0 -115
- package/src/types/deepseek.d.ts +0 -15
- package/src/types/index.d.ts +0 -43
- package/src/types/transformers.d.ts +0 -7
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/vecbox)
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
|
|
7
|
-
## Why
|
|
7
|
+
## Why vecbox?
|
|
8
8
|
|
|
9
9
|
**One API, multiple providers.** Switch between OpenAI, Gemini, or run locally with Llama.cpp without changing code.
|
|
10
10
|
```typescript
|
|
@@ -15,17 +15,22 @@ console.log(result.embedding); // [0.1, 0.2, ...]
|
|
|
15
15
|
|
|
16
16
|
## Installation
|
|
17
17
|
```bash
|
|
18
|
-
|
|
18
|
+
npm install vecbox
|
|
19
|
+
pnpm add vecbox
|
|
19
20
|
```
|
|
20
21
|
|
|
22
|
+
**Zero setup required!** Everything is included - no need to download Llama.cpp or compile anything.
|
|
23
|
+
|
|
21
24
|
## Quick Start
|
|
22
25
|
|
|
23
26
|
### Auto-detect (Recommended)
|
|
24
27
|
```typescript
|
|
25
28
|
import { autoEmbed } from 'vecbox';
|
|
26
29
|
|
|
30
|
+
// Just works - automatically picks the best available provider
|
|
27
31
|
const result = await autoEmbed({ text: 'Your text' });
|
|
28
|
-
|
|
32
|
+
console.log(result.embedding); // [0.1, 0.2, ...]
|
|
33
|
+
console.log(result.provider); // 'llamacpp' | 'openai' | 'gemini' | 'mistral'
|
|
29
34
|
```
|
|
30
35
|
|
|
31
36
|
### Specific Provider
|
|
@@ -38,6 +43,35 @@ const result = await embed(
|
|
|
38
43
|
);
|
|
39
44
|
```
|
|
40
45
|
|
|
46
|
+
### File Input
|
|
47
|
+
```typescript
|
|
48
|
+
import { embed } from 'vecbox';
|
|
49
|
+
|
|
50
|
+
// Embed text from files
|
|
51
|
+
const result = await embed(
|
|
52
|
+
{ provider: 'gemini', apiKey: process.env.GEMINI_API_KEY },
|
|
53
|
+
{ filePath: './document.txt' }
|
|
54
|
+
);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Batch Processing
|
|
58
|
+
```typescript
|
|
59
|
+
import { embed } from 'vecbox';
|
|
60
|
+
|
|
61
|
+
const inputs = [
|
|
62
|
+
{ text: 'First text' },
|
|
63
|
+
{ text: 'Second text' },
|
|
64
|
+
{ text: 'Third text' }
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
const result = await embed(
|
|
68
|
+
{ provider: 'mistral', apiKey: process.env.MISTRAL_API_KEY },
|
|
69
|
+
inputs
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
console.log(result.embeddings.length); // 3
|
|
73
|
+
```
|
|
74
|
+
|
|
41
75
|
## Providers
|
|
42
76
|
|
|
43
77
|
<details>
|
|
@@ -98,23 +132,6 @@ wget https://huggingface.co/nomic-ai/nomic-embed-text-v1.5-GGUF/resolve/main/nom
|
|
|
98
132
|
|
|
99
133
|
</details>
|
|
100
134
|
|
|
101
|
-
<details>
|
|
102
|
-
<summary><b>Anthropic Claude</b></summary>
|
|
103
|
-
```typescript
|
|
104
|
-
await embed(
|
|
105
|
-
{
|
|
106
|
-
provider: 'claude',
|
|
107
|
-
model: 'claude-3-sonnet-20240229',
|
|
108
|
-
apiKey: process.env.ANTHROPIC_API_KEY
|
|
109
|
-
},
|
|
110
|
-
{ text: 'Your text' }
|
|
111
|
-
);
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
**Setup:** Get API key at [console.anthropic.com](https://console.anthropic.com)
|
|
115
|
-
|
|
116
|
-
</details>
|
|
117
|
-
|
|
118
135
|
<details>
|
|
119
136
|
<summary><b>Mistral</b></summary>
|
|
120
137
|
```typescript
|
|
@@ -132,22 +149,30 @@ await embed(
|
|
|
132
149
|
|
|
133
150
|
</details>
|
|
134
151
|
|
|
135
|
-
|
|
136
|
-
<summary><b>DeepSeek</b></summary>
|
|
137
|
-
```typescript
|
|
138
|
-
await embed(
|
|
139
|
-
{
|
|
140
|
-
provider: 'deepseek',
|
|
141
|
-
model: 'deepseek-chat',
|
|
142
|
-
apiKey: process.env.DEEPSEEK_API_KEY
|
|
143
|
-
},
|
|
144
|
-
{ text: 'Your text' }
|
|
145
|
-
);
|
|
146
|
-
```
|
|
152
|
+
## 🚀 Features
|
|
147
153
|
|
|
148
|
-
|
|
154
|
+
- **🎯 One API, Multiple Providers** - Switch between OpenAI, Gemini, Mistral, or local Llama.cpp
|
|
155
|
+
- **🤖 Auto-Detection** - Automatically picks the best available provider
|
|
156
|
+
- **⚡ Native Performance** - Llama.cpp integration with N-API (10x faster than HTTP)
|
|
157
|
+
- **🔄 Smart Fallbacks** - Never fails, always has a backup provider
|
|
158
|
+
- **📁 File Support** - Embed text from files directly
|
|
159
|
+
- **📦 Batch Processing** - Process multiple texts efficiently
|
|
160
|
+
- **🛡️ Type Safe** - Full TypeScript support
|
|
161
|
+
- **🌍 Zero Dependencies** - No external downloads or setup required
|
|
149
162
|
|
|
150
|
-
|
|
163
|
+
## 🏆 Why Vecbox?
|
|
164
|
+
|
|
165
|
+
**vs Other Libraries:**
|
|
166
|
+
- ✅ **Native Llama.cpp** - Others use HTTP, we use direct C++ integration
|
|
167
|
+
- ✅ **Auto-Detection** - Others require manual provider selection
|
|
168
|
+
- ✅ **Zero Setup** - Others need external downloads and configuration
|
|
169
|
+
- ✅ **Multiple Providers** - Others are limited to one provider
|
|
170
|
+
- ✅ **Smart Fallbacks** - Others fail when a provider is unavailable
|
|
171
|
+
|
|
172
|
+
**Performance:**
|
|
173
|
+
- **Llama.cpp Native**: ~50ms per embedding
|
|
174
|
+
- **Cloud Providers**: ~100-300ms per embedding
|
|
175
|
+
- **HTTP Llama.cpp**: ~500ms+ per embedding
|
|
151
176
|
|
|
152
177
|
## Common Use Cases
|
|
153
178
|
|
|
@@ -244,9 +269,7 @@ Auto-detects best provider in priority order:
|
|
|
244
269
|
1. **Llama.cpp** (Local & Free)
|
|
245
270
|
2. **OpenAI** (if API key available)
|
|
246
271
|
3. **Gemini** (if API key available)
|
|
247
|
-
4. **
|
|
248
|
-
5. **Mistral** (if API key available)
|
|
249
|
-
6. **DeepSeek** (if API key available)
|
|
272
|
+
4. **Mistral** (if API key available)
|
|
250
273
|
|
|
251
274
|
```typescript
|
|
252
275
|
await autoEmbed({ text: string } | { filePath: string })
|
|
@@ -283,7 +306,7 @@ Returns available providers.
|
|
|
283
306
|
import { getSupportedProviders } from 'embedbox';
|
|
284
307
|
|
|
285
308
|
const providers = getSupportedProviders();
|
|
286
|
-
// → ['openai', 'gemini', '
|
|
309
|
+
// → ['openai', 'gemini', 'mistral', 'llamacpp']
|
|
287
310
|
```
|
|
288
311
|
|
|
289
312
|
### `createProvider(config)`
|
|
@@ -311,7 +334,6 @@ OPENAI_API_KEY=sk-...
|
|
|
311
334
|
GOOGLE_GENERATIVE_AI_API_KEY=...
|
|
312
335
|
ANTHROPIC_API_KEY=sk-ant-...
|
|
313
336
|
MISTRAL_API_KEY=...
|
|
314
|
-
DEEPSEEK_API_KEY=...
|
|
315
337
|
```
|
|
316
338
|
|
|
317
339
|
## Error Handling
|
|
@@ -362,16 +384,48 @@ const input: EmbedInput = {
|
|
|
362
384
|
const result: EmbedResult = await embed(config, input);
|
|
363
385
|
```
|
|
364
386
|
|
|
365
|
-
##
|
|
387
|
+
## 📚 Documentation
|
|
388
|
+
|
|
389
|
+
- **[API Reference](./API.md)** - Complete API documentation
|
|
390
|
+
- **[Contributing Guide](./CONTRIBUTING.md)** - How to contribute to Vecbox
|
|
391
|
+
- **[Troubleshooting](./TROUBLESHOOTING.md)** - Common issues and solutions
|
|
392
|
+
- **[Examples](./examples/)** - Code examples and tutorials
|
|
393
|
+
|
|
394
|
+
## 🤝 Contributing
|
|
395
|
+
|
|
396
|
+
We welcome contributions! See our [Contributing Guide](./CONTRIBUTING.md) for:
|
|
397
|
+
- Adding new providers
|
|
398
|
+
- Improving performance
|
|
399
|
+
- Bug fixes and features
|
|
400
|
+
- Documentation improvements
|
|
366
401
|
|
|
367
|
-
|
|
402
|
+
## 🐛 Troubleshooting
|
|
368
403
|
|
|
369
|
-
|
|
404
|
+
Having issues? Check our [Troubleshooting Guide](./TROUBLESHOOTING.md) for:
|
|
405
|
+
- Installation problems
|
|
406
|
+
- Runtime errors
|
|
407
|
+
- Performance issues
|
|
408
|
+
- Common solutions
|
|
370
409
|
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
- [
|
|
410
|
+
## 📄 License
|
|
411
|
+
|
|
412
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
413
|
+
|
|
414
|
+
## 🙏 Acknowledgments
|
|
415
|
+
|
|
416
|
+
- [Llama.cpp](https://github.com/ggml-org/llama.cpp) - Core embedding engine
|
|
417
|
+
- [OpenAI](https://openai.com/) - Embedding API
|
|
418
|
+
- [Google Gemini](https://ai.google.dev/) - Embedding API
|
|
419
|
+
- [Mistral AI](https://mistral.ai/) - Embedding API
|
|
420
|
+
|
|
421
|
+
## 📞 Support
|
|
422
|
+
|
|
423
|
+
- **GitHub Issues**: [Report bugs](https://github.com/box-safe/vecbox/issues)
|
|
424
|
+
- **GitHub Discussions**: [Ask questions](https://github.com/box-safe/vecbox/discussions)
|
|
425
|
+
- **Documentation**: [API Reference](./API.md)
|
|
374
426
|
|
|
375
427
|
---
|
|
376
428
|
|
|
377
|
-
|
|
429
|
+
**⭐ Star us on GitHub!** [github.com/box-safe/vecbox](https://github.com/box-safe/vecbox)
|
|
430
|
+
|
|
431
|
+
**Made with ❤️ by the Vecbox Team**
|