voyageai-cli 1.3.0 → 1.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/CHANGELOG.md +2 -0
- package/NOTICE +23 -0
- package/README.md +84 -0
- package/demo.gif +0 -0
- package/demo.tape +39 -0
- package/package.json +1 -1
- package/scripts/record-demo.sh +63 -0
- package/src/cli.js +19 -2
- package/src/commands/completions.js +463 -0
- package/src/commands/demo.js +3 -0
- package/src/commands/explain.js +170 -0
- package/src/commands/ingest.js +414 -0
- package/src/commands/models.js +61 -13
- package/src/commands/ping.js +5 -4
- package/src/commands/similarity.js +175 -0
- package/src/lib/api.js +48 -2
- package/src/lib/banner.js +1 -0
- package/src/lib/catalog.js +10 -10
- package/src/lib/config.js +1 -0
- package/src/lib/explanations.js +480 -0
- package/src/lib/math.js +20 -0
- package/test/commands/completions.test.js +166 -0
- package/test/commands/explain.test.js +207 -0
- package/test/commands/ingest.test.js +248 -0
- package/test/commands/ping.test.js +24 -11
- package/test/commands/similarity.test.js +79 -0
- package/test/fixtures/sample.csv +6 -0
- package/test/fixtures/sample.json +7 -0
- package/test/fixtures/sample.jsonl +5 -0
- package/test/fixtures/sample.txt +5 -0
- package/test/lib/api.test.js +12 -3
- package/test/lib/explanations.test.js +134 -0
- package/test/lib/math.test.js +43 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,8 @@ Format based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
9
|
### Added
|
|
10
|
+
- `vai ingest` — Bulk import from JSONL/JSON/CSV/text with batching, progress bar, and dry-run
|
|
11
|
+
- `vai similarity` — Compute cosine similarity between texts without MongoDB
|
|
10
12
|
- `vai demo` — Interactive guided walkthrough of all features
|
|
11
13
|
- ASCII banner when running `vai` with no arguments
|
|
12
14
|
- CONTRIBUTING.md for open-source contributors
|
package/NOTICE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
voyageai-cli — Community CLI for Voyage AI and MongoDB Atlas Vector Search
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Michael Lynn
|
|
4
|
+
|
|
5
|
+
DISCLAIMER:
|
|
6
|
+
This software is an independent, community-built tool. It is NOT an official
|
|
7
|
+
product of MongoDB, Inc. or Voyage AI (a MongoDB company). It is not supported,
|
|
8
|
+
endorsed, or maintained by either organization.
|
|
9
|
+
|
|
10
|
+
This tool interacts with:
|
|
11
|
+
- The MongoDB Atlas Embedding and Reranking API (https://ai.mongodb.com/v1/)
|
|
12
|
+
- MongoDB Atlas Vector Search (https://www.mongodb.com/docs/atlas/atlas-vector-search/)
|
|
13
|
+
|
|
14
|
+
For official documentation, support, and products:
|
|
15
|
+
- MongoDB: https://www.mongodb.com
|
|
16
|
+
- Voyage AI: https://www.mongodb.com/docs/voyageai/
|
|
17
|
+
- MongoDB Support: https://support.mongodb.com
|
|
18
|
+
|
|
19
|
+
"MongoDB", "MongoDB Atlas", and "Voyage AI" are trademarks of MongoDB, Inc.
|
|
20
|
+
All trademarks belong to their respective owners.
|
|
21
|
+
|
|
22
|
+
This software is provided "as is" without warranty of any kind. See LICENSE
|
|
23
|
+
for the full MIT License terms.
|
package/README.md
CHANGED
|
@@ -4,8 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
CLI for [Voyage AI](https://www.mongodb.com/docs/voyageai/) embeddings, reranking, and [MongoDB Atlas Vector Search](https://www.mongodb.com/docs/atlas/atlas-vector-search/). Pure Node.js — no Python required.
|
|
6
6
|
|
|
7
|
+
<!-- TODO: Add demo GIF -->
|
|
8
|
+
<!--  -->
|
|
9
|
+
|
|
7
10
|
Generate embeddings, rerank search results, store vectors in Atlas, and run semantic search — all from the command line.
|
|
8
11
|
|
|
12
|
+
> **⚠️ Disclaimer:** This is an independent, community-built tool. It is **not** an official product of MongoDB, Inc. or Voyage AI. It is not supported, endorsed, or maintained by either company. For official documentation, support, and products, visit:
|
|
13
|
+
> - **MongoDB:** [mongodb.com](https://www.mongodb.com) | [MongoDB Atlas](https://www.mongodb.com/atlas) | [Support](https://support.mongodb.com)
|
|
14
|
+
> - **Voyage AI:** [MongoDB Voyage AI Docs](https://www.mongodb.com/docs/voyageai/)
|
|
15
|
+
>
|
|
16
|
+
> Use at your own risk. No warranty is provided. See [LICENSE](LICENSE) for details.
|
|
17
|
+
|
|
9
18
|
## Install
|
|
10
19
|
|
|
11
20
|
```bash
|
|
@@ -60,6 +69,19 @@ vai rerank --query "best database" --documents-file candidates.json --top-k 3
|
|
|
60
69
|
vai rerank --query "query" --documents "doc1" "doc2" --model rerank-2.5-lite
|
|
61
70
|
```
|
|
62
71
|
|
|
72
|
+
### `vai similarity` — Compare text similarity
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
# Compare two texts
|
|
76
|
+
vai similarity "MongoDB is a document database" "MongoDB Atlas is a cloud database"
|
|
77
|
+
|
|
78
|
+
# Compare one text against many
|
|
79
|
+
vai similarity "database performance" --against "MongoDB is fast" "PostgreSQL is relational"
|
|
80
|
+
|
|
81
|
+
# From files
|
|
82
|
+
vai similarity --file1 doc1.txt --file2 doc2.txt
|
|
83
|
+
```
|
|
84
|
+
|
|
63
85
|
### `vai store` — Embed and insert into MongoDB Atlas
|
|
64
86
|
|
|
65
87
|
Requires `MONGODB_URI` environment variable.
|
|
@@ -79,6 +101,29 @@ vai store --db myapp --collection docs --field embedding \
|
|
|
79
101
|
--file documents.jsonl
|
|
80
102
|
```
|
|
81
103
|
|
|
104
|
+
### `vai ingest` — Bulk import with progress
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# JSONL (one JSON object per line with a "text" field)
|
|
108
|
+
vai ingest --file corpus.jsonl --db myapp --collection docs --field embedding
|
|
109
|
+
|
|
110
|
+
# JSON array
|
|
111
|
+
vai ingest --file documents.json --db myapp --collection docs --field embedding
|
|
112
|
+
|
|
113
|
+
# CSV (specify text column)
|
|
114
|
+
vai ingest --file data.csv --db myapp --collection docs --field embedding --text-column content
|
|
115
|
+
|
|
116
|
+
# Plain text (one document per line)
|
|
117
|
+
vai ingest --file lines.txt --db myapp --collection docs --field embedding
|
|
118
|
+
|
|
119
|
+
# Options
|
|
120
|
+
vai ingest --file corpus.jsonl --db myapp --collection docs --field embedding \
|
|
121
|
+
--model voyage-4 --batch-size 100 --input-type document
|
|
122
|
+
|
|
123
|
+
# Preview without embedding
|
|
124
|
+
vai ingest --file corpus.jsonl --db myapp --collection docs --field embedding --dry-run
|
|
125
|
+
```
|
|
126
|
+
|
|
82
127
|
### `vai search` — Vector similarity search
|
|
83
128
|
|
|
84
129
|
Requires `MONGODB_URI` environment variable.
|
|
@@ -206,6 +251,41 @@ vai config get
|
|
|
206
251
|
- Use `echo "key" | vai config set api-key --stdin` or `vai config set api-key --stdin < keyfile` to avoid shell history exposure
|
|
207
252
|
- The config file stores credentials in plaintext (similar to `~/.aws/credentials` and `~/.npmrc`) — protect your home directory accordingly
|
|
208
253
|
|
|
254
|
+
## Shell Completions
|
|
255
|
+
|
|
256
|
+
`vai` supports tab completion for bash and zsh.
|
|
257
|
+
|
|
258
|
+
### Bash
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
# Add to ~/.bashrc (or ~/.bash_profile on macOS)
|
|
262
|
+
vai completions bash >> ~/.bashrc
|
|
263
|
+
source ~/.bashrc
|
|
264
|
+
|
|
265
|
+
# Or install system-wide (Linux)
|
|
266
|
+
vai completions bash > /etc/bash_completion.d/vai
|
|
267
|
+
|
|
268
|
+
# Or with Homebrew (macOS)
|
|
269
|
+
vai completions bash > $(brew --prefix)/etc/bash_completion.d/vai
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### Zsh
|
|
273
|
+
|
|
274
|
+
```bash
|
|
275
|
+
# Create completions directory
|
|
276
|
+
mkdir -p ~/.zsh/completions
|
|
277
|
+
|
|
278
|
+
# Add to fpath in ~/.zshrc (if not already there)
|
|
279
|
+
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
|
|
280
|
+
echo 'autoload -Uz compinit && compinit' >> ~/.zshrc
|
|
281
|
+
|
|
282
|
+
# Generate the completion file
|
|
283
|
+
vai completions zsh > ~/.zsh/completions/_vai
|
|
284
|
+
source ~/.zshrc
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
Completions cover all 14 commands, subcommands, flags, model names, and explain topics.
|
|
288
|
+
|
|
209
289
|
## Global Flags
|
|
210
290
|
|
|
211
291
|
All commands support:
|
|
@@ -237,6 +317,10 @@ Free tier: 200M tokens for most models. All Voyage 4 series models share the sam
|
|
|
237
317
|
- A [MongoDB Atlas](https://www.mongodb.com/atlas) account (free tier works)
|
|
238
318
|
- A [Voyage AI model API key](https://www.mongodb.com/docs/voyageai/management/api-keys/) (created in Atlas)
|
|
239
319
|
|
|
320
|
+
## Disclaimer
|
|
321
|
+
|
|
322
|
+
This is a community tool and is not affiliated with, endorsed by, or supported by MongoDB, Inc. or Voyage AI. All trademarks belong to their respective owners. For official support, visit [mongodb.com](https://www.mongodb.com).
|
|
323
|
+
|
|
240
324
|
## License
|
|
241
325
|
|
|
242
326
|
MIT
|
package/demo.gif
ADDED
|
Binary file
|
package/demo.tape
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# VHS demo tape for voyageai-cli
|
|
2
|
+
# Run: vhs demo.tape
|
|
3
|
+
# Requires: VOYAGE_API_KEY set in environment
|
|
4
|
+
|
|
5
|
+
Output demo.gif
|
|
6
|
+
|
|
7
|
+
Set FontSize 16
|
|
8
|
+
Set Width 900
|
|
9
|
+
Set Height 600
|
|
10
|
+
Set Theme "Catppuccin Mocha"
|
|
11
|
+
Set Padding 20
|
|
12
|
+
|
|
13
|
+
# Show version
|
|
14
|
+
Type "vai --version"
|
|
15
|
+
Enter
|
|
16
|
+
Sleep 1.5s
|
|
17
|
+
|
|
18
|
+
# List embedding models
|
|
19
|
+
Type "vai models --type embedding"
|
|
20
|
+
Enter
|
|
21
|
+
Sleep 3s
|
|
22
|
+
|
|
23
|
+
# Generate an embedding
|
|
24
|
+
Type 'vai embed "What is MongoDB Atlas?"'
|
|
25
|
+
Enter
|
|
26
|
+
Sleep 4s
|
|
27
|
+
|
|
28
|
+
# Explain embeddings (first few lines)
|
|
29
|
+
Type "vai explain embeddings"
|
|
30
|
+
Enter
|
|
31
|
+
Sleep 4s
|
|
32
|
+
|
|
33
|
+
# Compare similarity
|
|
34
|
+
Type 'vai similarity "MongoDB is great" "MongoDB Atlas is amazing"'
|
|
35
|
+
Enter
|
|
36
|
+
Sleep 4s
|
|
37
|
+
|
|
38
|
+
# Pause at end to show results
|
|
39
|
+
Sleep 2s
|
package/package.json
CHANGED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Record a demo GIF for voyageai-cli
|
|
3
|
+
# Requires: VOYAGE_API_KEY environment variable
|
|
4
|
+
#
|
|
5
|
+
# Usage:
|
|
6
|
+
# ./scripts/record-demo.sh # Uses vhs (preferred)
|
|
7
|
+
# ./scripts/record-demo.sh asciinema # Uses asciinema instead
|
|
8
|
+
#
|
|
9
|
+
# Output:
|
|
10
|
+
# demo.gif (vhs) or demo.cast (asciinema)
|
|
11
|
+
|
|
12
|
+
set -euo pipefail
|
|
13
|
+
cd "$(dirname "$0")/.."
|
|
14
|
+
|
|
15
|
+
METHOD="${1:-vhs}"
|
|
16
|
+
|
|
17
|
+
if [ "$METHOD" = "vhs" ]; then
|
|
18
|
+
if ! command -v vhs &>/dev/null; then
|
|
19
|
+
echo "❌ vhs not found. Install: brew install charmbracelet/tap/vhs"
|
|
20
|
+
echo " Or run: ./scripts/record-demo.sh asciinema"
|
|
21
|
+
exit 1
|
|
22
|
+
fi
|
|
23
|
+
|
|
24
|
+
if [ -z "${VOYAGE_API_KEY:-}" ]; then
|
|
25
|
+
echo "⚠️ VOYAGE_API_KEY not set. Commands that call the API will fail."
|
|
26
|
+
echo " Set it: export VOYAGE_API_KEY=your-key"
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
echo "🎬 Recording demo with vhs..."
|
|
31
|
+
vhs demo.tape
|
|
32
|
+
echo "✅ Demo GIF saved to demo.gif"
|
|
33
|
+
|
|
34
|
+
elif [ "$METHOD" = "asciinema" ]; then
|
|
35
|
+
if ! command -v asciinema &>/dev/null; then
|
|
36
|
+
echo "❌ asciinema not found. Install: brew install asciinema"
|
|
37
|
+
exit 1
|
|
38
|
+
fi
|
|
39
|
+
|
|
40
|
+
CAST_FILE="demo.cast"
|
|
41
|
+
echo "🎬 Recording demo with asciinema..."
|
|
42
|
+
echo " Run the following commands, then press Ctrl-D when done:"
|
|
43
|
+
echo ""
|
|
44
|
+
echo " vai --version"
|
|
45
|
+
echo " vai models --type embedding"
|
|
46
|
+
echo ' vai embed "What is MongoDB Atlas?"'
|
|
47
|
+
echo " vai explain embeddings"
|
|
48
|
+
echo ' vai similarity "MongoDB is great" "MongoDB Atlas is amazing"'
|
|
49
|
+
echo ""
|
|
50
|
+
|
|
51
|
+
asciinema rec "$CAST_FILE"
|
|
52
|
+
echo "✅ Recording saved to $CAST_FILE"
|
|
53
|
+
echo ""
|
|
54
|
+
echo "Convert to GIF with agg or svg-term-cli:"
|
|
55
|
+
echo " agg $CAST_FILE demo.gif"
|
|
56
|
+
echo " # or"
|
|
57
|
+
echo " npx svg-term-cli --in $CAST_FILE --out demo.svg --window"
|
|
58
|
+
|
|
59
|
+
else
|
|
60
|
+
echo "Unknown method: $METHOD"
|
|
61
|
+
echo "Usage: $0 [vhs|asciinema]"
|
|
62
|
+
exit 1
|
|
63
|
+
fi
|
package/src/cli.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
require('dotenv').config({ quiet: true });
|
|
5
5
|
|
|
6
6
|
const { program } = require('commander');
|
|
7
|
+
const pc = require('picocolors');
|
|
7
8
|
const { registerEmbed } = require('./commands/embed');
|
|
8
9
|
const { registerRerank } = require('./commands/rerank');
|
|
9
10
|
const { registerStore } = require('./commands/store');
|
|
@@ -13,12 +14,18 @@ const { registerModels } = require('./commands/models');
|
|
|
13
14
|
const { registerPing } = require('./commands/ping');
|
|
14
15
|
const { registerConfig } = require('./commands/config');
|
|
15
16
|
const { registerDemo } = require('./commands/demo');
|
|
16
|
-
const {
|
|
17
|
+
const { registerExplain } = require('./commands/explain');
|
|
18
|
+
const { registerSimilarity } = require('./commands/similarity');
|
|
19
|
+
const { registerIngest } = require('./commands/ingest');
|
|
20
|
+
const { registerCompletions } = require('./commands/completions');
|
|
21
|
+
const { showBanner, showQuickStart, getVersion } = require('./lib/banner');
|
|
22
|
+
|
|
23
|
+
const version = getVersion();
|
|
17
24
|
|
|
18
25
|
program
|
|
19
26
|
.name('vai')
|
|
20
27
|
.description('Voyage AI embeddings, reranking, and Atlas Vector Search CLI')
|
|
21
|
-
.version('
|
|
28
|
+
.version(`vai/${version} (community tool — not an official MongoDB or Voyage AI product)`, '-V, --version', 'output the version number');
|
|
22
29
|
|
|
23
30
|
registerEmbed(program);
|
|
24
31
|
registerRerank(program);
|
|
@@ -29,6 +36,16 @@ registerModels(program);
|
|
|
29
36
|
registerPing(program);
|
|
30
37
|
registerConfig(program);
|
|
31
38
|
registerDemo(program);
|
|
39
|
+
registerExplain(program);
|
|
40
|
+
registerSimilarity(program);
|
|
41
|
+
registerIngest(program);
|
|
42
|
+
registerCompletions(program);
|
|
43
|
+
|
|
44
|
+
// Append disclaimer to all help output
|
|
45
|
+
program.addHelpText('after', `
|
|
46
|
+
${pc.dim('Community tool — not an official MongoDB or Voyage AI product.')}
|
|
47
|
+
${pc.dim('Docs: https://www.mongodb.com/docs/voyageai/')}
|
|
48
|
+
`);
|
|
32
49
|
|
|
33
50
|
// If no args (just `vai`), show banner + quick start + help
|
|
34
51
|
if (process.argv.length <= 2) {
|