Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 AI Agent Chatbot (FastAPI + Ollama + TinyLLaMA)

An interactive AI chatbot powered by Ollama and TinyLLaMA, served using FastAPI, and connected to a sleek custom frontend using HTML, CSS, and JavaScript.


🧠 Features

  • 💬 Chat with a local LLM (tinyllama) using Ollama
  • 🌐 FastAPI backend with RESTful API
  • 📁 Static frontend served via FastAPI
  • 💾 Persistent chat history saved in chatlog.json
  • 🔁 Reset conversation functionality
  • 📜 View conversation history via endpoint

🛠️ Tech Stack

  • Backend: FastAPI
  • Frontend: HTML + CSS + JS
  • Model Runtime: Ollama
  • Model Used: tinyllama (or any other compatible LLM via Ollama)
  • Others: Pydantic, Requests, CORS, JSON

🔍 ML Concepts Applied:

  • Inference pipelines
  • Prompt logic
  • Data persistence and session state

🚀 Getting Started

1. Clone the Repository

git clone https://github.com/yourusername/ai-agent-chatbot.git
cd ai-agent-chatbot

2. Setup Python Environment

python -m venv venv
venv\Scripts\activate     # On Windows
# source venv/bin/activate  # On macOS/Linux

pip install -r requirements.txt

3. Install Ollama and Model

Install Ollama for your OS.

Then run:

ollama run tinyllama

Ensure Ollama is running in a separate terminal before starting FastAPI!


4. Run the Backend

uvicorn main:app --reload

The server starts at: http://localhost:8000

📝 Sample Chat Log

This project includes a chatlog-demo.json file to demonstrate the structure of saved conversations.
Note: Real-time chat logs are stored in chatlog.json, which is excluded from version control to protect user privacy.


5. Access the Frontend

Open your browser and visit:

http://localhost:8000/frontend/

You're ready to chat with your local AI! 🎉


📂 Project Structure

AI-agent-chatbot/
├── frontend/
│   ├── index.html
│   └── script.js
├── main.py
├── chatlog.json
├── requirements.txt
└── README.md

📡 API Endpoints

Method Endpoint Description
POST /api/chat Send a message to the chatbot
POST /api/reset Clear chat history
GET /api/history Get full chat history

🧹 Resetting Chat

Click the "Reset" button in the UI or call:

curl -X POST http://localhost:8000/api/reset

🔧 Future Enhancements

  • Add multi-agent orchestration logic with role-based LLMs (e.g., Research Agent, Summarizer Agent)
  • Integrate embeddings-based memory for personalized responses
  • Lightweight UI with feedback metrics

🙋‍♀️ Made by

Shreya H S Machine Learning & Cloud Enthusiast 🌙☁️🤖 Do Checkout - Medium Post


📄 License

This project is open-source and free to use. Modify and build upon it as needed!

About

Lightweight local AI chatbot with FastAPI backend and Ollama LLM integration. Supports chat history and reset.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages