Request for review: semantic-commands crate (semantic routing via embeddings)
⚓ Rust 📅 2025-11-07 👤 surdeus 👁️ 3Repo: https://github.com/SET001/semantic-commands
Goal:
Route natural language inputs to registered async commands using embeddings + cosine similarity.
Use cases: bots, CLI assistants, flexible command interfaces.
Core pieces:
- Command { name, executor }
- Input: normalized phrase + optional embedding cache
- Traits: Embedder, Cache (OpenAI + Postgres implementations)
- Execution returns Box<dyn Any + Send> (downcast at call site)
Example (conceptual):
sc.execute("what's the date?") -> should run registered async executor for date command
Questions:
- API naming: Command / Input / SemanticCommands—idiomatic?
- Executor signature: Arc -> Future<Result> boxed—better pattern?
- Returning Box: keep, or switch to enum / trait object?
- Embedding caching flow: update missing embeddings lazily vs precompute?
- find_similar implementation: any obvious perf / borrow improvements?
- Error strategy: still using anyhow::Result—should I introduce a crate Error enum now?
- async_trait usage: acceptable here or refactor to generic async fns?
Appreciate any feedback on ergonomics, structure, idiomatic Rust, and pitfalls. Thanks!
1 post - 1 participant
🏷️ Rust_feed