Skip to content

chingtechrd/ai-web-chat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Web Chat

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.

Features

  • FastAPI Backend: Robust and fast Python backend serving the application.
  • Gemini CLI Integration: Utilizes the gemini CLI 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.

Prerequisites

  • Python 3.10+
  • Gemini CLI: Ensure the gemini command-line tool is installed and authenticated.
  • uv (Optional but recommended): For fast Python package management.

Installation

  1. Clone the repository:

    git clone <repository-url>
    cd ai-web-chat
  2. Install dependencies:

    Using uv (recommended):

    uv sync

    Or using standard pip:

    pip install -r requirements.txt

    (Note: If requirements.txt is missing, install directly: pip install fastapi uvicorn)

Usage

  1. 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.

  2. Access the Chat: Open your browser and navigate to: http://127.0.0.1:8000/static/index.html

  3. Start Chatting: Type your message in the input box and hit Send. The AI will respond, remembering the context of your conversation.

Project Structure

  • 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.

Troubleshooting

Address already in use

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:

  1. Find the process using port 8000:

    lsof -i :8000

    Or using netstat:

    netstat -nlp | grep :8000
  2. 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 -9 to force kill it:

    kill -9 <PID>
  3. Retry starting the server:

    uv run main.py

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors