Create cookbook/liteLLM_Ollama.ipynb
Browse files
cookbook/liteLLM_Ollama.ipynb
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from litellm import completion
|
2 |
+
|
3 |
+
response = completion(
|
4 |
+
model="ollama/llama2",
|
5 |
+
messages=[{ "content": "respond in 20 words. who are you?","role": "user"}],
|
6 |
+
api_base="http://localhost:11434",
|
7 |
+
stream=True
|
8 |
+
)
|
9 |
+
print(response)
|
10 |
+
for chunk in response:
|
11 |
+
print(chunk['choices'][0]['delta'])
|