{"id":50675169,"url":"https://github.com/ziuus/dept-chatbot","last_synced_at":"2026-06-08T15:02:30.441Z","repository":{"id":340319808,"uuid":"1164647476","full_name":"ziuus/dept-chatbot","owner":"ziuus","description":null,"archived":false,"fork":false,"pushed_at":"2026-02-24T08:40:16.000Z","size":14921,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-24T14:43:39.386Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ziuus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-23T10:24:45.000Z","updated_at":"2026-02-24T08:40:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/ziuus/dept-chatbot","commit_stats":null,"previous_names":["ziuus/dept-chatbot"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/ziuus/dept-chatbot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziuus%2Fdept-chatbot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziuus%2Fdept-chatbot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziuus%2Fdept-chatbot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziuus%2Fdept-chatbot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziuus","download_url":"https://codeload.github.com/ziuus/dept-chatbot/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziuus%2Fdept-chatbot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34067353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-08T15:02:26.399Z","updated_at":"2026-06-08T15:02:30.435Z","avatar_url":"https://github.com/ziuus.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Department AI Brain (Backend Only)\n\nProduction-oriented AI service for department queries:\n- Structured lookup for strict facts (teacher cabin, subjects taught).\n- RAG for natural language Q\u0026A using faculty knowledge chunks.\n- Guardrailed LLM prompt to reduce hallucinations.\n- Domain guardrail for non-department questions.\n- Abusive language filter.\n- Optional API key auth (`X-API-Key`) and request rate limiting.\n- Readiness endpoint and request-id based logging.\n\n## 1) Setup\n\n```bash\npython -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\ncp .env.example .env\n```\n\nSet provider values in `.env`.\n\nOpenAI example:\n\n```env\nAI_PROVIDER=openai\nOPENAI_API_KEY=your_openai_key\nLLM_MODEL=gpt-4.1-mini\nEMBEDDING_MODEL=text-embedding-3-small\n```\n\nGemini example:\n\n```env\nAI_PROVIDER=gemini\nGEMINI_API_KEY=your_gemini_key\nLLM_MODEL=gemini-1.5-flash\nEMBEDDING_MODEL=text-embedding-004\n```\n\n## 2) Run API\n\n```bash\nuvicorn app.main:app --reload\n```\n\nAPI base: `http://127.0.0.1:8000`\n\nProduction run (example):\n\n```bash\nuvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 2\n```\n\n## 3) Endpoints\n\n- `GET /health`\n- `GET /ready`\n- `POST /ingest`  \n  Builds embeddings and loads faculty chunks into Chroma.\n- `POST /query`  \n  Body:\n  ```json\n  {\n    \"question\": \"Where can I find AI sir?\"\n  }\n  ```\n\nResponse:\n```json\n{\n  \"answer\": \"Dr. Anil Mehta is in cabin 402. Availability: 10:00-13:00.\",\n  \"route\": \"structured\",\n  \"sources\": [\n    {\n      \"id\": \"fac-001\",\n      \"text\": \"...\",\n      \"metadata\": {\"source\": \"structured\"},\n      \"score\": null\n    }\n  ]\n}\n```\n\nIf `SERVICE_API_KEY` is set, include:\n\n```http\nX-API-Key: \u003cyour-key\u003e\n```\n\n## 4) Data\n\nEdit `data/faculty.json` with real faculty details. Re-run `POST /ingest` after changes.\n\n## 5) Notes\n\n- If no strict match is found, service falls back to RAG.\n- If info is missing in retrieved context, assistant should return:  \n  `I don't have that information right now.`\n- Public-agent controls:\n  - Off-topic questions can be blocked (`ALLOW_OFF_TOPIC=false`).\n  - Low-confidence retrieval is rejected using `MAX_RAG_DISTANCE`.\n- Runtime note:\n  - On Python `3.14+`, Chroma is disabled by the service for compatibility, so RAG endpoints return unavailable.\n  - Use Python `3.12` or `3.13` for full RAG (`/ingest` + vector retrieval).\n\n## 6) Production Environment Variables\n\n- `AI_PROVIDER`: `openai` or `gemini`.\n- `OPENAI_API_KEY`: required when `AI_PROVIDER=openai`.\n- `GEMINI_API_KEY`: required when `AI_PROVIDER=gemini`.\n- `SERVICE_API_KEY`: optional API key for `/query` and `/ingest`.\n- `RATE_LIMIT_REQUESTS`: max requests in the rate window per client IP.\n- `RATE_LIMIT_WINDOW_SECONDS`: rate window size.\n- `MAX_QUESTION_CHARS`: hard max input length.\n- `TOP_K`: RAG retrieval depth.\n- `MAX_RAG_DISTANCE`: relevance threshold for accepted retrieval results.\n\n## 7) Run Tests\n\n```bash\npytest -q\n```\n\n## 8) Docker\n\n```bash\ndocker build -t dept-ai-brain .\ndocker run --rm -p 8000:8000 --env-file .env dept-ai-brain\n```\n\n## 9) Voice Frontend (Next.js)\n\nA simple voice UI is available in `frontend/`.\n\nRun backend first (example port):\n\n```bash\nuvicorn app.main:app --reload --port 8001\n```\n\nThen run frontend:\n\n```bash\ncd frontend\nnpm install\ncp .env.local.example .env.local\nnpm run dev\n```\n\nOpen `http://127.0.0.1:3000` and ask questions by voice.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziuus%2Fdept-chatbot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziuus%2Fdept-chatbot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziuus%2Fdept-chatbot/lists"}