The Oshepherd guiding the Ollama(s) inference orchestration.
Project description
oshepherd
The Oshepherd guiding the Ollama(s) inference orchestration.
A centralized Flask API service, using Celery and Redis to orchestrate multiple Ollama servers as workers.
Install
pip install oshepherd
Usage
-
Setup Redis:
Celery uses Redis as message broker and backend. You'll need a Redis instance, which you can provision for free in redislabs.com.
-
Setup Flask API Server:
# define configuration env file # use credentials for redis as broker and backend cp .api.env.template .api.env # start api oshepherd start-api --env-file .api.env
-
Setup Celery/Ollama Worker(s):
# install ollama https://ollama.com/download # optionally pull the model ollama pull mistral # define configuration env file # use credentials for redis as broker and backend cp .worker.env.template .worker.env # start worker oshepherd start-worker --env-file .worker.env
-
Now you're ready to execute Ollama completions remotely. You can point your Ollama client to your oshepherd api server by setting the
host
, and it will return your requested completions from any of the workers:- ollama-python client:
import ollama client = ollama.Client(host="http://127.0.0.1:5001") ollama_response = client.generate({"model": "mistral", "prompt": "Why is the sky blue?"})
- ollama-js client:
import { Ollama } from "ollama/browser"; const ollama = new Ollama({ host: "http://127.0.0.1:5001" }); const ollamaResponse = await ollama.generate({ model: "mistral", prompt: "Why is the sky blue?", });
- Raw http request:
curl -X POST -H "Content-Type: application/json" -L http://127.0.0.1:5001/api/generate/ -d '{ "model": "mistral", "prompt":"Why is the sky blue?" }'
Disclaimers 🚨
This package is in alpha, its architecture and api might change in the near future. Currently this is getting tested in a controlled environment by real users, but haven't been audited, nor tested thorugly. Use it at your own risk.
As this is an alpha version, support and responses might be limited. We'll do our best to address questions and issues as quickly as possible.
API server parity
- Generate a completion:
POST /api/generate
- Generate a chat completion:
POST /api/chat
- Generate Embeddings:
POST /api/embeddings
- List Local Models:
GET /api/tags
(pending)
Oshepherd API server has been designed to maintain compatibility with the endpoints defined by Ollama, ensuring that any official client (i.e.: ollama-python, ollama-js) can use this server as host and receive expected responses. For more details on the full API specifications, refer to the official Ollama API documentation.
Contribution guidelines
We welcome contributions! If you find a bug or have suggestions for improvements, please open an issue or submit a pull request pointing to development
branch. Before creating a new issue/pull request, take a moment to search through the existing issues/pull requests to avoid duplicates.
Conda Support
To run and build locally you can use conda:
conda create -n oshepherd python=3.8
conda activate oshepherd
pip install -r requirements.txt
# install oshepherd
pip install -e .
Tests
Follow usage instructions to start api server and celery worker using a local ollama, and then run the tests:
pytest -s tests/
Author
This is a project developed and maintained by mnemonica.ai.
License
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file oshepherd-0.0.9.tar.gz
.
File metadata
- Download URL: oshepherd-0.0.9.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47e4369bbab7d2c17ed4166c184fe160bfa9791a66e1b784419e4d403dbde7df |
|
MD5 | 4df36f2494941851bbe6ed60d34e567f |
|
BLAKE2b-256 | 9509856bca19306b97bc0a7e54da99933365f466a4ca9ea653d0296a3b4ae3b0 |
File details
Details for the file oshepherd-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: oshepherd-0.0.9-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.8.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76d8485748ebebecbfc9d465d9e7aa90bb0856ccbedc5ddbcfa259551d50f4ae |
|
MD5 | 6d4ae7e993713b341cc34ba5ff2007ad |
|
BLAKE2b-256 | 672ccc09512b0e162f84afd48f7c88883edf50220ed2e03bcb286b58a00085e6 |