CoolFace
Apppublic

notionhive-ai/nh-chatbot

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

🧠 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.


πŸš€ 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.
  • β€”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.