An intelligent multi-interface assistant for Protheus ERP support — powered by Gemini, Ollama and a modular RAG architecture that resolves 70–80% of technical calls automatically.
A modular, layered design inspired by production-grade AI agent frameworks — clean separation between domains, tools, LLMs and interfaces.
rocks_ai/
├── app/ │ ├── main.py # Entry point — orchestrates everything │ ├── core/ │ │ ├── orchestrator.py # The brain — decides what to do │ │ └── ai_planner.py # Generates plans via LLM + RAG │ ├── llm/ │ │ ├── provider.py # Manages which LLM to use + fallback │ │ ├── gemini.py ★ # Gemini + automatic token rotation │ │ └── ollama.py # Local Ollama integration │ ├── intents/ │ │ ├── matcher.py # Classifies text by keywords │ │ ├── registry.py # Aggregates all domains │ │ └── domains/ │ │ ├── ws.py # JobWS / WebSocket domain │ │ ├── rest.py # REST / API domain │ │ ├── rh.py # HR / MeuRH domain │ │ └── tss.py # TSS / NFS-e domain │ ├── tools/ │ │ ├── base_tool.py # Abstract base class │ │ ├── tool_registry.py # Tool registry │ │ └── implementations/ │ │ ├── check_url.py # Verifies URL accessibility │ │ ├── read_logs.py # Reads generic logs │ │ └── tss_tools.py ★ # TSS/NFS-e tools │ ├── knowledge/ │ │ ├── rag_engine.py ⚠ stub — next priority │ │ └── protheus/ # Knowledge base docs │ └── interfaces/ │ ├── cli/cli.py ★ # Rich terminal │ ├── web/app.py # Flask web chat │ └── slack/slack_app.py # Slack slash command ├── docker-compose.yml ★ └── Dockerfile ★
A thorough review of each module — what's working, what's excellent, and what needs attention next.
Boots the system: waits for Ollama, then starts Slack and Web in daemon threads, with CLI in the foreground.
__import__("os") with standard import osThe brain. Receives all user input, decides if it's a provider switch, a known intent or an LLM fallback, then runs the tools.
Connects to Google Gemini with automatic rotation across multiple API tokens, quota detection and configurable timeout.
Manages which LLM is active. Starts with Gemini if API key is available, falls back to Ollama — runtime switching works perfectly.
Scans all domains for keyword matches in user input. Simple and effective for obvious cases, but needs refinement for edge cases.
4 tools for the TSS/NFS-e flow. Excellent regex-based log analysis with context lines, result limits, and next-step suggestions.
Professional interactive terminal with Rich, conversation history, animated splash, and commands like modelo, indexar, hist, limpar.
Slash command bot with HMAC signature verification, async thread responses and personalized first-contact greetings.
Currently a stub that always returns empty. ChromaDB is already running in Docker — activating this is the single highest-impact next step.
CLI, Web and Slack running simultaneously — analysts choose the interface that fits their workflow.
→ Rich-powered terminal with full command history, syntax highlighting and animated splash screen
AppServer.ini section [HTTP] and verify the user has WEBSERVICE access.→ Flask-powered web chat with /health endpoint — accessible from any browser on the network
/tss/configuracao/certificado
→ Slash command /rocks with HMAC security, async threads and personalized analyst greetings
Current documents powering the RAG engine — and what needs to be added to hit full coverage.
| File | Content | Status |
|---|---|---|
| ERRO_JOBWS_001.md | JobWS timeout / connection error | ✓ Good |
| ERRO_REST_401.md | REST 401 Unauthorized | ✓ Good |
| APPSERVER_INI.md | AppServer.ini reference | ✓ Good |
| MEURH_TROUBLESHOOT.md | MeuRH app issues | ✓ Good |
| CHECKLIST_SUBIDA.md | Environment startup checklist | ✓ Good |
| tss_flow.md | TSS support flow | ✓ Good |
| jobws_errors.md | Duplicate / redundant | ⚠ Review |
| rest_license_errors.md | Duplicate / redundant | ⚠ Review |
The highest-impact changes to implement right now, ranked by value delivered.
Change the last return in gemini.py to raise an exception (GEMINI_ALL_TOKENS_EXHAUSTED), letting provider.py trigger Ollama automatically — no analyst action needed.
Each message is currently isolated. Pass the full conversation history in the prompt so the LLM can maintain context across a support session — critical for multi-step troubleshooting.
Tools currently hardcode localhost:8080. Read the real Protheus IP from environment variables so the system works in any deployment without code changes.
ChromaDB is already running in the Docker stack. Activating the real rag_engine.py will immediately make the assistant context-aware — the single biggest impact item in the entire backlog.
Migrate from slash commands to the Events API so analysts can use @rocks naturally in any channel and attach log files directly — removing friction and increasing adoption.
From a solid v1 foundation to a fully autonomous support agent.
"The project is at a level far above what is expected at this stage. The architecture — separating domains, intents, tools and providers — is exactly the pattern used in professional AI agent systems."