mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-25 10:44:24 +00:00
fix async import error
This commit is contained in:
parent
e354f39cc1
commit
2b9e3434ff
1 changed files with 39 additions and 37 deletions
|
@ -2,9 +2,10 @@ import requests
|
||||||
import json
|
import json
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from async_generator import async_generator, yield_ # optional dependancy if you want to use acompletion + streaming
|
from async_generator import async_generator, yield_ # optional dependency
|
||||||
except:
|
async_generator_imported = True
|
||||||
pass # this should not throw an error, it will impact the 'import litellm' statement
|
except ImportError:
|
||||||
|
async_generator_imported = False # this should not throw an error, it will impact the 'import litellm' statement
|
||||||
|
|
||||||
# ollama implementation
|
# ollama implementation
|
||||||
def get_ollama_response_stream(
|
def get_ollama_response_stream(
|
||||||
|
@ -39,9 +40,10 @@ def get_ollama_response_stream(
|
||||||
print(f"Error decoding JSON: {e}")
|
print(f"Error decoding JSON: {e}")
|
||||||
session.close()
|
session.close()
|
||||||
|
|
||||||
# ollama implementation
|
if async_generator_imported:
|
||||||
@async_generator
|
# ollama implementation
|
||||||
async def async_get_ollama_response_stream(
|
@async_generator
|
||||||
|
async def async_get_ollama_response_stream(
|
||||||
api_base="http://localhost:11434",
|
api_base="http://localhost:11434",
|
||||||
model="llama2",
|
model="llama2",
|
||||||
prompt="Why is the sky blue?"
|
prompt="Why is the sky blue?"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue