Skip to content

Commit 8af9768

Browse files
Merge pull request #51 from run-llama/clelia/unify-semtools-command
feat: move separate commands to a unified interace
2 parents 11fada6 + 993bc6a commit 8af9768

14 files changed

Lines changed: 591 additions & 541 deletions

‎Cargo.toml‎

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,9 @@ keywords = ["semantic-search", "document-parsing", "cli", "pdf", "search"]
1111
readme = "README.md"
1212

1313
[[bin]]
14-
name = "parse"
15-
path = "src/bin/parse.rs"
16-
required-features = ["parse"]
17-
18-
[[bin]]
19-
name = "search"
20-
path = "src/bin/search.rs"
21-
required-features = ["search"]
22-
23-
[[bin]]
24-
name = "workspace"
25-
path = "src/bin/workspace.rs"
26-
required-features = ["workspace", "search"]
27-
28-
[[bin]]
29-
name = "ask"
30-
path = "src/bin/ask.rs"
31-
required-features = ["ask", "search"]
14+
name = "semtools"
15+
path = "src/bin/semtools.rs"
16+
required-features = ["ask", "search", "workspace", "parse"]
3217

3318
[dependencies]
3419
# Common dependencies

‎README.md‎

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33
> Semantic search and document parsing tools for the command line
44
5-
A collection of high-performance CLI tools for document processing and semantic search, built with Rust for speed and reliability.
5+
A high-performance CLI tool for document processing and semantic search, built with Rust for speed and reliability.
66

7-
- **`parse`** - Parse documents (PDF, DOCX, etc.) using, by default, the LlamaParse API into markdown format
8-
- **`search`** - Local semantic keyword search using multilingual embeddings with cosine similarity matching and per-line context matching
9-
- **`ask`** - AI agent with search and read tools for answering questions over document collections (defaults to OpenAI, but see the [config section](#configuration) to learn more about connecting to any OpenAI-Compatible API)
10-
- **`workspace`** - Workspace management for accelerating search over large collections
7+
- **`semtools parse`** - Parse documents (PDF, DOCX, etc.) using, by default, the LlamaParse API into markdown format
8+
- **`semtools search`** - Local semantic keyword search using multilingual embeddings with cosine similarity matching and per-line context matching
9+
- **`semtools ask`** - AI agent with search and read tools for answering questions over document collections (defaults to OpenAI, but see the [config section](#configuration) to learn more about connecting to any OpenAI-Compatible API)
10+
- **`semtools workspace`** - Workspace management for accelerating search over large collections
1111

1212
**NOTE:** By default, `parse` uses LlamaParse as a backend. Get your API key today for free at [https://cloud.llamaindex.ai](https://cloud.llamaindex.ai). `search` and `workspace` remain local-only. `ask` requires an OpenAI API key.
1313

@@ -25,7 +25,8 @@ A collection of high-performance CLI tools for document processing and semantic
2525

2626
Prerequisites:
2727

28-
- For the `parse` tool: LlamaIndex Cloud API key
28+
- For the `parse` subcommand: LlamaIndex Cloud API key
29+
- For the `ask` subcommand: OpenAI API key
2930

3031
Install:
3132

@@ -53,49 +54,49 @@ Basic Usage:
5354

5455
```bash
5556
# Parse some files
56-
parse my_dir/*.pdf
57+
semtools parse my_dir/*.pdf
5758

5859
# Search some (text-based) files
59-
search "some keywords" *.txt --max-distance 0.3 --n-lines 5
60+
semtools search "some keywords" *.txt --max-distance 0.3 --n-lines 5
6061

6162
# Ask questions about your documents using an AI agent
62-
ask "What are the main findings?" papers/*.txt
63+
semtools ask "What are the main findings?" papers/*.txt
6364

6465
# Combine parsing and search
65-
parse my_docs/*.pdf | xargs search "API endpoints"
66+
semtools parse my_docs/*.pdf | xargs search "API endpoints"
6667

6768
# Ask a question to a set of files
68-
ask "Some question?" *.txt
69+
semtools ask "Some question?" *.txt
6970

7071
# Combine parsing with the ask agent
71-
parse research_papers/*.pdf | xargs ask "Summarize the key methodologies"
72+
semtools parse research_papers/*.pdf | xargs ask "Summarize the key methodologies"
7273

7374
# Ask based on stdin content
74-
cat README.md | ask "How do I install SemTools?"
75+
cat README.md | semtools ask "How do I install SemTools?"
7576
```
7677

7778
Advanced Usage:
7879

7980
```bash
8081
# Combine with grep for exact-match pre-filtering and distance thresholding
81-
parse *.pdf | xargs cat | grep -i "error" | search "network error" --max-distance 0.3
82+
semtools parse *.pdf | xargs cat | grep -i "error" | semtools search "network error" --max-distance 0.3
8283

8384
# Pipeline with content search (note the 'xargs' on search to search files instead of stdin)
84-
find . -name "*.md" | xargs parse | xargs search "installation"
85+
find . -name "*.md" | xargs semtools parse | xargs semtools search "installation"
8586

8687
# Combine with grep for filtering (grep could be before or after parse/search!)
87-
parse docs/*.pdf | xargs search "API" | grep -A5 "authentication"
88+
semtools parse docs/*.pdf | xargs semtools search "API" | grep -A5 "authentication"
8889

8990
# Save search results from stdin search
90-
parse report.pdf | xargs cat | search "summary" > results.txt
91+
semtools parse report.pdf | xargs cat | semtools search "summary" > results.txt
9192
```
9293

9394
Using Workspaces:
9495

9596
```bash
9697
# Create or select a workspace
9798
# Workspaces are stored in ~/.semtools/workspaces/
98-
workspace use my-workspace
99+
semtools workspace use my-workspace
99100
> Workspace 'my-workspace' configured.
100101
> To activate it, run:
101102
> export SEMTOOLS_WORKSPACE=my-workspace
@@ -107,17 +108,17 @@ export SEMTOOLS_WORKSPACE=my-workspace
107108

108109
# All search commands will now use the workspace for caching embeddings
109110
# The initial command is used to initialize the workspace
110-
search "some keywords" ./some_large_dir/*.txt --n-lines 5 --top-k 10
111+
semtools search "some keywords" ./some_large_dir/*.txt --n-lines 5 --top-k 10
111112

112113
# If documents change, they are automatically re-embedded and cached
113114
echo "some new content" > ./some_large_dir/some_file.txt
114-
search "some keywords" ./some_large_dir/*.txt --n-lines 5 --top-k 10
115+
semtools search "some keywords" ./some_large_dir/*.txt --n-lines 5 --top-k 10
115116

116117
# If documents are removed, you can run prune to clean up stale files
117-
workspace prune
118+
semtools workspace prune
118119

119120
# You can see the stats of a workspace at any time
120-
workspace status
121+
semtools workspace status
121122
> Active workspace: arxiv
122123
> Root: /Users/loganmarkewich/.semtools/workspaces/arxiv
123124
> Documents: 3000
@@ -127,10 +128,10 @@ workspace status
127128
## CLI Help
128129

129130
```bash
130-
$ parse --help
131+
$ semtools parse --help
131132
A CLI tool for parsing documents using various backends
132133

133-
Usage: parse [OPTIONS] <FILES>...
134+
Usage: semtools parse [OPTIONS] <FILES>...
134135

135136
Arguments:
136137
<FILES>... Files to parse
@@ -140,33 +141,32 @@ Options:
140141
-b, --backend <BACKEND> The backend type to use for parsing. Defaults to `llama-parse` [default: llama-parse]
141142
-v, --verbose Verbose output while parsing
142143
-h, --help Print help
143-
-V, --version Print version
144144
```
145145
146146
```bash
147-
$ search --help
147+
$ semtools search --help
148148
A CLI tool for fast semantic keyword search
149149

150-
Usage: search [OPTIONS] <QUERY> [FILES]...
150+
Usage: semtools search [OPTIONS] <QUERY> [FILES]...
151151

152152
Arguments:
153153
<QUERY> Query to search for (positional argument)
154-
[FILES]... Files or directories to search
154+
[FILES]... Files to search, optional if using stdin
155155

156156
Options:
157157
-n, --n-lines <N_LINES> How many lines before/after to return as context [default: 3]
158158
--top-k <TOP_K> The top-k files or texts to return (ignored if max_distance is set) [default: 3]
159159
-m, --max-distance <MAX_DISTANCE> Return all results with distance below this threshold (0.0+)
160160
-i, --ignore-case Perform case-insensitive search (default is false)
161+
-j, --json Output results in JSON format
161162
-h, --help Print help
162-
-V, --version Print version
163163
```
164164
165165
```bash
166-
$ workspace --help
166+
$ semtools workspace --help
167167
Manage semtools workspaces
168168

169-
Usage: workspace <COMMAND>
169+
Usage: semtools workspace [OPTIONS] <COMMAND>
170170

171171
Commands:
172172
use Use or create a workspace (prints export command to run)
@@ -175,15 +175,15 @@ Commands:
175175
help Print this message or the help of the given subcommand(s)
176176

177177
Options:
178-
-h, --help Print help
179-
-V, --version Print version
178+
-j, --json Output results in JSON format
179+
-h, --help Print help
180180
```
181181
182182
```bash
183-
$ ask --help
184-
A CLI tool for fast semantic keyword search
183+
$ semtools ask --help
184+
A CLI tool for document-based question-answering
185185

186-
Usage: ask [OPTIONS] <QUERY> [FILES]...
186+
Usage: semtools ask [OPTIONS] <QUERY> [FILES]...
187187

188188
Arguments:
189189
<QUERY> Query to prompt the agent with
@@ -194,8 +194,9 @@ Options:
194194
--api-key <API_KEY> OpenAI API key (overrides config file and env var)
195195
--base-url <BASE_URL> OpenAI base URL (overrides config file)
196196
-m, --model <MODEL> Model to use for the agent (overrides config file)
197+
--api-mode <API_MODE> API mode to use: 'chat' or 'responses' (overrides config file)
198+
-j, --json Output results in JSON or text format
197199
-h, --help Print help
198-
-V, --version Print version
199200
```
200201
201202
## Configuration
@@ -260,11 +261,11 @@ Configuration values are resolved in the following priority order (highest to lo
260261
261262
This allows you to set common defaults in the config file while overriding them on a per-command basis when needed.
262263
263-
### Tool-Specific Configuration
264+
### Subcommand-Specific Configuration
264265
265-
#### Parse Tool
266+
#### Parse Subcommand
266267
267-
The `parse` tool requires a LlamaParse API key. Get your free API key at [https://cloud.llamaindex.ai](https://cloud.llamaindex.ai).
268+
The `parse` subcommand requires a LlamaParse API key. Get your free API key at [https://cloud.llamaindex.ai](https://cloud.llamaindex.ai).
268269
269270
Configuration options:
270271
- `api_key`: Your LlamaParse API key
@@ -273,9 +274,9 @@ Configuration options:
273274
- `parse_kwargs`: Additional parsing parameters
274275
- `check_interval`, `max_timeout`, `max_retries`, `retry_delay_ms`, `backoff_multiplier`: Retry and timeout settings
275276
276-
#### Ask Tool
277+
#### Ask Subcommand
277278
278-
The `ask` tool requires an OpenAI API key for the agent's LLM.
279+
The `ask` subcommand requires an OpenAI API key for the agent's LLM.
279280
280281
Configuration options:
281282
- `api_key`: Your OpenAI API key
@@ -285,7 +286,7 @@ Configuration options:
285286
286287
You can also override these per-command:
287288
```bash
288-
ask "What is this about?" docs/*.txt --model gpt-4o --api-key sk-...
289+
semtools ask "What is this about?" docs/*.txt --model gpt-4o --api-key sk-...
289290
```
290291
291292
## Agent Use Case Examples

0 commit comments

Comments
 (0)