A local web chat application powered by a Python FastAPI backend and the Gemini CLI. This project allows you to chat with an AI agent in a modern web interface, featuring multi-turn conversation capabilities.
- FastAPI Backend: Robust and fast Python backend serving the application.
- Gemini CLI Integration: Utilizes the
geminiCLI for intelligent responses. - Multi-turn Conversations: Supports maintaining context across multiple exchanges using session management.
- Modern UI: Clean and responsive HTML/CSS/JS frontend.
- Streaming-like Experience: Visual feedback while the AI is processing.
- Python 3.10+
- Gemini CLI: Ensure the
geminicommand-line tool is installed and authenticated. - uv (Optional but recommended): For fast Python package management.
-
Clone the repository:
git clone <repository-url> cd ai-web-chat
-
Install dependencies:
Using
uv(recommended):uv sync
Or using standard
pip:pip install -r requirements.txt
(Note: If
requirements.txtis missing, install directly:pip install fastapi uvicorn)
-
Start the server:
uv run main.py
Or with python directly:
python main.py
The server will start at
http://127.0.0.1:8000. -
Access the Chat: Open your browser and navigate to: http://127.0.0.1:8000/static/index.html
-
Start Chatting: Type your message in the input box and hit Send. The AI will respond, remembering the context of your conversation.
main.py: The FastAPI application entry point. Handles chat endpoints and invokes the Gemini CLI.static/: Contains the frontend assets (index.html,style.css,script.js).pyproject.toml: Project configuration and dependencies.
If you see an error like [Errno 98] error while attempting to bind on address ('127.0.0.1', 8000): address already in use, it means another process is already using port 8000.
Solution:
-
Find the process using port 8000:
lsof -i :8000
Or using
netstat:netstat -nlp | grep :8000 -
Kill the process: Take the PID (Process ID) from the output above and run:
kill <PID>
(Replace
<PID>with the actual number, e.g.,kill 12345)If the process refuses to close, use
-9to force kill it:kill -9 <PID>
-
Retry starting the server:
uv run main.py