api changes for gathm ui chat#23
Merged
Merged
Conversation
api/server.py:
- POST /agent/ask now runs the matched tool instead of just returning
which tool it found. Flow: match intent -> extract NL args ->
execute_tool() -> return real output.
- Add _extract_tool_args(): strips common filler words + the tool name
from the query to get bare arguments (e.g. "weather in Tokyo" -> ["Tokyo"]).
- Add _strip_ansi(): removes ANSI escape codes from tool output so the
GUI receives clean text.
- Handle "gathm run <tool> [args]" passthrough so typing CLI commands
in the chat also works.
gui/app.js:
- checkConnectivity() tries /ping then falls back to /api/v1/tools for
servers that pre-date the /ping endpoint -- fixes the false Offline
status when running an older local server.
- formatAgentReply() now handles {status, output} from executed tools;
surfaces errors cleanly; no-match shows a friendly hint list.
- Rewrote file in plain ASCII (no smart quotes / unicode bullets) to
fix the Node.js SyntaxError from prior edits.
https://claude.ai/code/session_01THtMvNNx21QhXYi6PBRFBz
The GUI was talking to the bash keyword-router (orchestrator.sh ask),
which has no language understanding — hence all the brittle regex
arg-extraction. The actual AI agent already exists in pilot/main.py
(LangGraph + Ollama/Gemini) but was only reachable from the terminal TUI.
Expose it over HTTP and let it do the heavy lifting:
- pilot/chat_once.py: single-shot, non-interactive entry to the Pilot
agent. Reads {query, history} JSON on stdin, runs one agent turn,
prints {reply, backend, model} JSON on stdout. All TUI/agent output is
redirected to stderr so stdout stays clean. Catches SystemExit/import
failures and emits a clean error.
- api/server.py: new POST /api/v1/agent/chat. Shells out to chat_once.py
via the Pilot venv's Python (keeping the API server stdlib-only), so
the LLM understands the message, picks/runs tools, and replies in
natural language. Falls back to the keyword router (with chat_error)
when the LLM runtime isn't available.
- gui/app.js: call /agent/chat instead of /agent/ask, keep client-side
conversation history for multi-turn context, and simplify
formatAgentReply to prefer the agent's reply.
Requires an LLM backend (Ollama running, or a Gemini key) plus the pilot
venv. Without them the server degrades to the router automatically.
https://claude.ai/code/session_01THtMvNNx21QhXYi6PBRFBz
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.