Skip to content

DevItBetter/graft

Repository files navigation

Ollama Framework

A Python framework for interacting with Ollama and its underlying language models.

Features

  • Direct client for interacting with Ollama API
  • FastAPI server implementation for enhanced functionality
  • Model management (loading, listing)
  • Chat completion with streaming support

Installation

# Clone the repository
git clone git@github.com:DevItBetter/ollama_project.git
cd ollama-framework

# Create a virtual environment
python -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Install the package in development mode
pip install -e .

Start Ollama

Make sure you have Ollama installed and running. You can start it with:

ollama serve

Running the API Server

For development with auto-reload:

# Recommended approach (with auto-reload)
python start_server.py --debug

# Alternative approaches
uvicorn ollama_framework.api.main:app --reload
python -m ollama_framework.api.main  # If main.py contains server code

API Examples

Basic Endpoints

Check if the API is running:

curl http://localhost:8000/
# {"message":"Welcome to the Ollama Framework API"}

curl http://localhost:8000/health
# {"status":"healthy","version":"0.1.0"}

Model Management

List all available models:

curl http://localhost:8000/api/models/
# {"models":[{"name":"llama3","modified_at":"2024-03-16T12:00:00Z"}, ...]}

Chat Completion

Send a chat message:

curl -X POST http://localhost:8000/api/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "llama3",
    "messages": [{"role": "user", "content": "Hello, how are you?"}]
  }'

Documentation

Once the server is running, view the interactive API documentation:

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages