A small, tool-augmented local AI agent built around a straightforward agent loop, with a FastAPI backend and a React + TypeScript frontend.
- 🤖 Autonomous Function Calling Agent: Integrates with any OpenAI-compatible local model backend (Ollama, LM Studio, vLLM, etc.).
- 🔁 Minimal Agent Loop: Lets the model request a tool, observes the result, and continues until it can produce a final answer—without a heavyweight agent framework.
- 🛠️ Built-in Tool Matrix:
- 🌐 Web Search (
search_web): Locates relevant search results using DuckDuckGo. - 📄 Web Scraper (
parse_webpage): Downloads and extracts clean readable text from selected webpages. - 🐍 Python Sandbox (
execute_python_code): Runs Python code locally for calculations, data analysis, and logic verification. - 📅 Date & Time Query (
get_current_date): Resolves current time context for date-sensitive questions.
- 🌐 Web Search (
- ⚡ Streaming Responses: Streams model output incrementally from the local LLM to the browser over Server-Sent Events (SSE).
- 🔧 Live Tool Activity: Emits structured tool start and completion events so the UI can show which tool is currently running.
- 💻 Two Interfaces:
- CLI: A lightweight terminal chat in
chat.py. - Web UI: A classic light conversation interface with Markdown rendering, syntax highlighting, and tool activity indicators.
- CLI: A lightweight terminal chat in
local-chat-agent/
├── configs/
│ └── llm.yaml # Model parameters (base_url, model name, system prompt)
├── core/
│ └── agent.py # Core ChatAgent class with OpenAI function-calling loop
├── tools/
│ ├── definitions.py # OpenAI function schemas & execution mapping
│ ├── execute_python_code.py
│ ├── get_current_date.py
│ ├── parse_webpage.py
│ └── search_web.py
├── server.py # FastAPI backend server with SSE streaming endpoints
├── chat.py # CLI chat interface
├── local-ui-chat/ # React + TypeScript + Vite + Tailwind CSS frontend
├── pyproject.toml # Python dependencies (managed via uv)
└── README.md
- Python 3.13+
- uv
- Node.js and npm
- An OpenAI-compatible local LLM server running (e.g. Ollama or LM Studio on
http://localhost:11434/v1)
-
Install Python Dependencies: Using
uv(recommended):uv sync
-
Configure Your Model: Edit configs/llm.yaml:
model: "your-model" # Your local model name base_url: "http://localhost:11434/v1" # OpenAI-compatible endpoint URL api_key: "ollama" # API key (dummy string for local Ollama) system_prompt: | You are a helpful local AI assistant equipped with tools...
If the LLM server runs on another machine in your LAN, set
base_urlto that machine's address instead, for examplehttp://192.168.x.x:11434/v1. -
Start the API Server:
uv run server.py
The server will start on
http://localhost:8000.
-
Navigate to Frontend Directory:
cd local-ui-chat -
Install Dependencies:
npm install
-
Start Development Server:
npm run dev
Open
http://localhost:5173in your browser.
If you prefer using the terminal directly without launching the frontend:
uv run chat.py| Method | Endpoint | Description |
|---|---|---|
POST |
/chat |
Send user message ({"message": "string"}) and receive SSE stream (text/event-stream). |
DELETE |
/chat |
Clears current agent conversation memory. |
