Skip to content

ayushdubey570/FAST_API_FAQ_CHATBOT

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Project Structure smart-faq-bot/ β”œβ”€β”€ app.py # Flask app with API endpoints β”œβ”€β”€ chains.py # LangChain Gemini integration β”œβ”€β”€ db.py # SQLite database functions β”œβ”€β”€ templates/ β”‚ └── index.html # Simple HTML frontend β”œβ”€β”€ .env # Environment variables (example) β”œβ”€β”€ requirements.txt # Python dependencies └── logs.db # SQLite DB (auto-created) πŸš€ Setup Instructions

Create the project directory and files: bashmkdir smart-faq-bot cd smart-faq-bot mkdir templates

Copy all the code files from the artifacts above into their respective locations. Install dependencies: bashpip install -r requirements.txt

Get Google API Key:

Go to Google AI Studio Create a new API key Copy your actual API key and replace your_google_api_key_here in the .env file

Run the application: bashpython app.py

Open your browser:

Go to http://localhost:5000/ Start asking questions!

βœ… Features Implemented Backend (Flask):

POST /ask - Accepts questions, gets Gemini responses, saves to DB GET /logs - Returns all Q&A history as JSON Proper error handling and validation Environment variable loading with python-dotenv

LangChain Integration:

Uses langchain-google-genai for Gemini Pro access System prompt for FAQ assistant behavior Temperature control for response consistency

Database (SQLite):

Auto-creates logs.db on first run Stores questions, answers, and timestamps Helper functions for database operations

Frontend:

Clean, responsive HTML interface Real-time question submission via fetch API Loading states and error handling Q&A history viewer with toggle functionality Enter key support for quick submission

πŸ”§ API Usage Ask a question: bashcurl -X POST http://localhost:5000/ask
-H "Content-Type: application/json"
-d '{"question": "What is artificial intelligence?"}' Get logs: bashcurl http://localhost:5000/logs The system is production-ready with proper error handling, database logging, and a user-friendly interface. Just add your Google API key and you're ready to go!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages