Request for review: semantic-commands crate (semantic routing via embeddings)

Repo: 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:

  1. API naming: Command / Input / SemanticCommands—idiomatic?
  2. Executor signature: Arc -> Future<Result> boxed—better pattern?
  3. Returning Box: keep, or switch to enum / trait object?
  4. Embedding caching flow: update missing embeddings lazily vs precompute?
  5. find_similar implementation: any obvious perf / borrow improvements?
  6. Error strategy: still using anyhow::Result—should I introduce a crate Error enum now?
  7. async_trait usage: acceptable here or refactor to generic async fns?

Appreciate any feedback on ergonomics, structure, idiomatic Rust, and pitfalls. Thanks!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.