A simple Flask web application that provides a user-friendly interface to interact with local Ollama AI models. This project allows you to run AI conversations entirely on your local machine without sending data to external services.
- Local AI Processing: Uses Ollama for completely local AI inference
- Web Interface: Clean, responsive web UI for easy interaction
- Model Flexibility: Configurable to work with different Ollama models
- Health Monitoring: Built-in health check endpoint
- Error Handling: Comprehensive error messages and troubleshooting guidance
- Real-time Status: Connection status and model information display
Before running this application, ensure you have:
- Python 3.13+ (this project uses Python 3.13.6)
- Ollama installed and running on your system
- A compatible Ollama model (default:
llama3.2:latest)
Visit Ollama's official website to download and install Ollama for your operating system.
After installation, pull the required model:
ollama pull llama3.2:latest-
Clone or download this project
-
Create and set up the Python virtual environment:
# Create virtual environment python -m venv ollama-app # Activate virtual environment source ollama-app/bin/activate # On macOS/Linux # or ollama-app\Scripts\activate # On Windows
-
Install required dependencies:
pip install -r requirements.txt
-
Configure environment variables (optional): The
.envfile contains default configurations:OPENAI_API_KEY="ollama" LLM_ENDPOINT='http://localhost:11434/v1' OPENAI_MODEL=llama3.2:latest
-
Start Ollama server (if not already running):
ollama serve
-
Activate the virtual environment:
source ollama-app/bin/activate -
Run the Flask application:
python server.py
-
Open your browser and navigate to:
http://localhost:5000
- Enter your prompt in the text area
- Click "Generate" to get AI responses
- The application will display the model's response below the form
- Connection status and model information are shown at the bottom
Visit http://localhost:5000/health to check the application and Ollama connection status.
You can customize the application by modifying the .env file:
OPENAI_API_KEY: API key for OpenAI client (use "ollama" for local Ollama)LLM_ENDPOINT: Ollama server endpoint (default:http://localhost:11434/v1)LLM_MODEL: Model name to use (default:llama3.2:latest)PORT: Server port (default: 5000)
To use a different Ollama model:
- Pull the model:
ollama pull model-name - Update the
LLM_MODELin.envfile - Restart the application
.
├── .env # Environment configuration
├── server.py # Main Flask application
├── requirements.txt # Python dependencies
├── templates/
│ └── index.html # Web interface template
├── ollama-app/ # Python virtual environment
│ ├── bin/ # Virtual environment binaries
│ ├── lib/ # Python packages
│ └── pyvenv.cfg # Virtual environment configuration
└── README.md # This file
-
"Cannot connect to Ollama server"
- Ensure Ollama is running:
ollama serve - Check if the endpoint is correct in
.env - Verify Ollama is accessible:
curl http://localhost:11434/api/tags
- Ensure Ollama is running:
-
"Model not found"
- List available models:
ollama list - Pull the required model:
ollama pull llama3.2:latest - Update the model name in
.env
- List available models:
-
Virtual environment issues
- Recreate the virtual environment:
python -m venv ollama-app - Reinstall dependencies:
pip install -r requirements.txt
- Recreate the virtual environment:
The application runs in debug mode by default. To disable it for production:
app.run(host="0.0.0.0", port=port, debug=False)Feel free to submit issues, feature requests, or pull requests to improve this project.
This project is open source. Please check the license file for more details.
This application processes all AI requests locally through Ollama. No data is sent to external services, ensuring complete privacy and control over your conversations.