Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

AI Generator with Ollama

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.

🚀 Features

  • 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

📋 Prerequisites

Before running this application, ensure you have:

  1. Python 3.13+ (this project uses Python 3.13.6)
  2. Ollama installed and running on your system
  3. A compatible Ollama model (default: llama3.2:latest)

Installing Ollama

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

🛠️ Installation

  1. Clone or download this project

  2. 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
  3. Install required dependencies:

    pip install -r requirements.txt
  4. Configure environment variables (optional): The .env file contains default configurations:

    OPENAI_API_KEY="ollama"
    LLM_ENDPOINT='http://localhost:11434/v1'
    OPENAI_MODEL=llama3.2:latest
    

🚀 Usage

Starting the Application

  1. Start Ollama server (if not already running):

    ollama serve
  2. Activate the virtual environment:

    source ollama-app/bin/activate
  3. Run the Flask application:

    python server.py
  4. Open your browser and navigate to:

    http://localhost:5000
    

Using the Web Interface

  1. Enter your prompt in the text area
  2. Click "Generate" to get AI responses
  3. The application will display the model's response below the form
  4. Connection status and model information are shown at the bottom

Health Check

Visit http://localhost:5000/health to check the application and Ollama connection status.

⚙️ Configuration

Environment Variables

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)

Using Different Models

To use a different Ollama model:

  1. Pull the model: ollama pull model-name
  2. Update the LLM_MODEL in .env file
  3. Restart the application

🏗️ Project Structure

.
├── .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

🔧 Troubleshooting

Common Issues

  1. "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
  2. "Model not found"

    • List available models: ollama list
    • Pull the required model: ollama pull llama3.2:latest
    • Update the model name in .env
  3. Virtual environment issues

    • Recreate the virtual environment: python -m venv ollama-app
    • Reinstall dependencies: pip install -r requirements.txt

Debug Mode

The application runs in debug mode by default. To disable it for production:

app.run(host="0.0.0.0", port=port, debug=False)

🤝 Contributing

Feel free to submit issues, feature requests, or pull requests to improve this project.

📝 License

This project is open source. Please check the license file for more details.

🔒 Privacy

This application processes all AI requests locally through Ollama. No data is sent to external services, ensuring complete privacy and control over your conversations.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages