mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 18:54:30 +00:00
(docs) litellm ollama docker image
This commit is contained in:
parent
f2eb1b4658
commit
5a39a3554d
4 changed files with 64 additions and 0 deletions
36
cookbook/litellm-ollama-docker-image/test.py
Normal file
36
cookbook/litellm-ollama-docker-image/test.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
|
||||
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}')
|
||||
|
||||
response = openai.ChatCompletion.create(
|
||||
model="ollama/llama2",
|
||||
messages = [
|
||||
{
|
||||
"role": "user",
|
||||
"content": "this is a test request, acknowledge that you got it"
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
print(f'LiteLLM: response from proxy {response}')
|
Loading…
Add table
Add a link
Reference in a new issue