Android: AI (Chat and AI Fix)
Technical specification for AI Chat and AI Fix in the PestControlOS Android app.
AI Chat
- Providers: Hugging Face (via HF Router) or Groq. App uses Groq if Groq key is set, otherwise Hugging Face key.
- Key storage: Firestore
AI-Chat/AI-API. Fields:KEY(Hugging Face token),key-grog(Groq API key). Only user 001 can update via Settings (Update Hugging Face Key / Update Groq Key). Cloud Functions can enforce admin-only writes to this document. - Behaviour: In-app chat UI; send user message to API; display reply as plain text (no markdown tables/headings). Long replies supported (e.g. max 2048 tokens). No streaming required for initial implementation.
AI Fix
- Visibility: Button visible only when user is logged in (Firebase Auth). Offline users do not see AI Fix.
- Scope: Available in Create Report and Action Form. On tap, dialog asks which fields to update: Create Report: Site Inspection and/or Recommendations; Action Form: Service Report and/or Recommendations. Only selected fields are sent to API and overwritten with polished text.
- Behaviour: Text is made professional, grammatically correct, free of asterisks/filler; a few sentences may be added. Uses same Firestore API keys as AI Chat (KEY or key-grog). If no key set, app prompts that admin must set one in AI Chat settings. Button disabled until content exists in relevant fields.
API usage
- Same Firestore document for keys; same server-side or client-side call to Hugging Face/Groq. Rate limiting and token limits apply per provider. No keys stored in app code; read from Firestore at runtime (with caching if needed).