Spaces:
Sleeping
Sleeping
| license: apache-2.0 | |
| emoji: π§ | |
| sdk: docker | |
| colorFrom: blue | |
| colorTo: purple | |
| thumbnail: >- | |
| https://cdn-uploads.huggingface.co/production/uploads/68734d5a2ae5ca930a3d195a/71R1ZoEhLA6neM5WSpxt4.png | |
| # π§ Notionhive AI Chatbot | |
| A FastAPI-based intelligent FAQ chatbot powered by Google Gemini and LangChain, designed to answer questions based on Notionhive's official FAQs and website: [notionhive.com](https://notionhive.com). | |
| --- | |
| ## π Features | |
| * Semantic search using Sentence Transformers & Chroma DB | |
| * Gemini AI (gemini-2.0-flash) for accurate response generation | |
| * CSV-based FAQ management (upload, add, delete, view) | |
| * RESTful API built with FastAPI | |
| * Prompt structure enforcing Notionhive's tone and boundaries | |
| * CORS enabled for frontend integration | |
| --- | |
| ## π Project Structure | |
| ``` | |
| . | |
| βββ main.py # FastAPI app initialization | |
| βββ faq_routes.py # All chatbot + FAQ management API endpoints | |
| βββ faq_services.py # Vector store logic, Gemini model setup | |
| βββ chatbot_prompt.py # Prompt template for Gemini responses | |
| βββ faqs.csv # Stored FAQs (question/answer pairs) | |
| βββ README.md | |
| ``` | |
| --- | |
| ## π Requirements | |
| * Python 3.9+ | |
| * Google API Key for Gemini | |
| * `sentence-transformers` | |
| * `langchain` | |
| * `chromadb` | |
| * `fastapi`, `uvicorn` | |
| * `python-dotenv`, `pandas` | |
| Install dependencies: | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| --- | |
| ## π Environment Setup | |
| Create a `.env` file in your root directory with the following: | |
| ```env | |
| GOOGLE_API_KEY=your_google_api_key_here | |
| ``` | |
| --- | |
| ## π Usage | |
| Run the API server locally: | |
| ```bash | |
| uvicorn main:app --reload | |
| ``` | |
| Access endpoints: | |
| * `POST /ask` β Ask a question | |
| * `POST /add_faq` β Add a new FAQ | |
| * `POST /upload_faqs_csv` β Upload bulk FAQs from CSV | |
| * `DELETE /delete_faq` β Delete FAQ by content | |
| * `DELETE /deleted/{faq_id}` β Delete FAQ by ID | |
| * `DELETE /delete/destroyall` β Delete all FAQs | |
| * `GET /get_faqs` β View all FAQs | |
| * `POST /retrain` β Reload vector DB | |
| --- | |
| ## π€ Chatbot Behavior | |
| * Introduces itself as **Noah**, Notionhiveβs AI Assistant. | |
| * Answers based on FAQs and content from [notionhive.com](https://notionhive.com). | |
| * Uses web search *only if* FAQ-based answers arenβt available and question is general or critical. | |
| * Will never generate fabricated or speculative responses. | |
| --- | |
| ## π Notes | |
| * All FAQs are stored in `faqs.csv`. Updating this file retrains the vector search index. | |
| * Currently single-tenant; for multi-tenant expansion, isolate CSV and vector store per tenant ID. | |
| --- | |
| ## π¨βπΌ Credits | |
| Developed by the Notionhive AI team. |