An OpenAI API compatible server for local LLMs - llama2, mistral, codellama
9.1K
Powered by: https://github.com/BerriAI/litellm
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:
| Model | Parameters | Size | Download |
|---|---|---|---|
| Mistral | 7B | 4.1GB | ollama run mistral |
| Llama 2 | 7B | 3.8GB | ollama run llama2 |
| Code Llama | 7B | 3.8GB | ollama run codellama |
| Llama 2 Uncensored | 7B | 3.8GB | ollama run llama2-uncensored |
| Llama 2 13B | 13B | 7.3GB | ollama run llama2:13b |
| Llama 2 70B | 70B | 39GB | ollama run llama2:70b |
| Orca Mini | 3B | 1.9GB | ollama run orca-mini |
| Vicuna | 7B | 3.8GB | ollama run vicuna |
docker run --name ollama litellm/ollama
This docker container contains a test.py
run python3 test.py to make a request to ollama/llama2
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}')
{
"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
}
}
Content type
Image
Digest
sha256:9b8b1fede…
Size
3.8 GB
Last updated
almost 3 years ago
docker pull litellm/ollama