Skip to content

About

AI Q&A chatbot — FastAPI backend + Groq LLM + SQLite chat history

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

24 Commits

Folders and files

Repository files navigation

🤖 Hosted API LLM Bot

An AI question-answering chatbot with a FastAPI backend, a lightweight JavaScript web front-end, and conversation history saved in a SQLite database. Answers are generated by a large language model served through the Groq API (Llama 4 Scout).

✨ Features Ask anything — send a question and get an AI-generated answer in real time. Conversation history — every question and answer is stored and can be retrieved later. Fast responses — powered by Groq's high-speed LLM inference. Clean separation — Python backend (API + model) and a simple HTML/CSS/JS frontend. Secure by design — the API key is kept in an environment variable, database queries use prepared statements, and CORS is restricted to the allowed frontend URL. 🛠️ Tech Stack Layer Technology Backend Python, FastAPI, Uvicorn AI Model Groq API — meta-llama/llama-4-scout-17b-16e-instruct Database SQLite Frontend HTML, CSS, JavaScript Config python-dotenv 📁 Project Structure hosted_api_llm.bot/ ├── main.py # FastAPI backend (endpoints + Groq + SQLite) ├── requirements.txt # Python dependencies ├── index.html # Frontend page ├── index.css # Frontend styling ├── app.js / index.js # Frontend logic (calls the API) ├── package.json # Frontend config └── src/ # Additional frontend source 🔌 API Endpoints Method Endpoint Description POST /ask Send a question (JSON), get an AI answer, and save it to history. GET /history Return the 50 most recent question-and-answer pairs. 🚀 Getting Started

  1. Clone the repository bash git clone https://github.com/Kehkashantaj/hosted_api_llm.bot.git cd hosted_api_llm.bot
  2. Install Python dependencies bash pip install -r requirements.txt
  3. Add your Groq API key

Create a file named .env in the project folder and add:

GROQ_API_KEY=your_groq_api_key_here

Get a free API key from https://console.groq.com

  1. Run the backend bash uvicorn main:app --reload

The API will be available at http://127.0.0.1:8000.

  1. Open the frontend

Open index.html in your browser (or serve it with any static server) to start chatting with the bot.

💡 How It Works You type a question in the web page and hit send. The frontend sends it to the /ask endpoint. The backend forwards the question to the Groq LLM, gets an answer, and saves both to the SQLite database. The answer is returned and shown on the page. You can revisit past conversations through the /history endpoint. 📌 Notes Keep your GROQ_API_KEY private — never commit the .env file. The frontend's allowed origin is configured via CORS in main.py; update it to match wherever you deploy the frontend. 👩‍💻 Author

Kehkashan Taj — @Kehkashantaj

About

AI Q&A chatbot — FastAPI backend + Groq LLM + SQLite chat history

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages