Sign inSign up

litellm/ollama

By litellm

Updated almost 3 years ago

An OpenAI API compatible server for local LLMs - llama2, mistral, codellama

Image
14

9.1K

litellm/ollama repository overview

LiteLLM/Ollama Docker Image

Powered by: https://github.com/BerriAI/litellm

Chat on WhatsApp Chat on Discord

This docker image creates an OpenAI API compatible server for the following local LLMs Here are some example open-source models that can be downloaded:

ModelParametersSizeDownload
Mistral7B4.1GBollama run mistral
Llama 27B3.8GBollama run llama2
Code Llama7B3.8GBollama run codellama
Llama 2 Uncensored7B3.8GBollama run llama2-uncensored
Llama 2 13B13B7.3GBollama run llama2:13b
Llama 2 70B70B39GBollama run llama2:70b
Orca Mini3B1.9GBollama run orca-mini
Vicuna7B3.8GBollama run vicuna

Usage

docker run --name ollama litellm/ollama

Testing your server

This docker container contains a test.py run python3 test.py to make a request to ollama/llama2

Making a request to this server

import openai

api_base = f"http://0.0.0.0:8000"

openai.api_base = api_base
openai.api_key = "temp-key"
print(openai.api_base)


print(f'LiteLLM: response from proxy with streaming')
response = openai.ChatCompletion.create(
    model="ollama/llama2", 
    messages = [
        {
            "role": "user",
            "content": "this is a test request, acknowledge that you got it"
        }
    ],
    stream=True
)

for chunk in response:
    print(f'LiteLLM: streaming response from proxy {chunk}')

Responses from this server

{
  "object": "chat.completion",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": " Hello! I acknowledge receipt of your test request. Please let me know if there's anything else I can assist you with.",
        "role": "assistant",
        "logprobs": null
      }
    }
  ],
  "id": "chatcmpl-403d5a85-2631-4233-92cb-01e6dffc3c39",
  "created": 1696992706.619709,
  "model": "ollama/llama2",
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 25,
    "total_tokens": 43
  }
}

Support / talk with founders

Tag summary

Content type

Image

Digest

sha256:9b8b1fede

Size

3.8 GB

Last updated

almost 3 years ago

docker pull litellm/ollama