You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(rest): /api/v1/consult endpoint for Consultant-mode Q&A
Closes the cartridge-side compose hack with a native LLM-backed
endpoint. The cartridge tool consultant_qa (boj-server commit
0cba9a4) was always intended to route preferentially to /api/consult
when echidna gained one — that path now exists.
src/rust/llm.rs:
- New `ConsultResponse { answer, model, latency_ms }` struct.
- New `LlmAdvisor::consult(question, context)` async method. Sends
operation=consult to BoJ's echidna-llm cartridge invoke endpoint,
with model=preferred_model + max_tokens + temperature from
LlmConfig + response_format=markdown. Bails Err when BoJ is
unreachable so callers can fall back.
src/interfaces/rest/models.rs:
- New ConsultRequest { question, context: Option<String> } and
ConsultResponse { answer, model: Option<String>, latency_ms: u64 }
with ToSchema for OpenAPI.
src/interfaces/rest/main.rs:
- AppState gains llm_advisor: Arc<Mutex<LlmAdvisor>>. Mutex because
check_health takes &mut self.
- Route registered: POST /api/v1/consult → handlers::consult.
- Restructured the unresolved `use crate::ffi_wrapper;` to a proper
`mod ffi_wrapper;` declaration alongside the existing handlers /
models module declarations.
src/interfaces/rest/handlers.rs:
- New `pub async fn consult(State, Json<ConsultRequest>)` handler:
empty-question → 400, BoJ unreachable → 503, BoJ error → 502,
success → 200 with ConsultResponse JSON. Lazily health-checks the
advisor on first call.
Verification:
- cargo check --lib clean ✓
- The wider echidna-rest workspace member has ~37 pre-existing
errors in OTHER handlers (FfiProverBackend trait gap on the new
search_theorems/config/set_config methods, ProverKind variant
mismatches across local enum vs core enum, TacticResult import
drift). These predate this commit and are tracked separately.
When the rest crate's other handlers are fixed, /api/v1/consult
activates with no further changes — the endpoint definition is
complete and lib-builds clean.
Cartridge dispatcher path (already in place):
echidnabot Consultant @echidnabot mention
→ handle_consultant_mention (echidnabot/src/api/webhooks.rs)
→ query_boj_q_and_a (echidnabot/src/llm.rs commit 4a7871c)
→ POST {boj}/cartridge/echidna-llm-mcp/invoke {tool: consultant_qa}
→ cartridge composes /api/search + /api/tactics/suggest TODAY,
will prefer /api/v1/consult when echidna's rest crate ships.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments