fix async import error

This commit is contained in:
ishaan-jaff 2023-09-21 11:16:50 -07:00
parent e354f39cc1
commit 2b9e3434ff

View file

@ -2,9 +2,10 @@ import requests
import json
try:
from async_generator import async_generator, yield_ # optional dependancy if you want to use acompletion + streaming
except:
pass # this should not throw an error, it will impact the 'import litellm' statement
from async_generator import async_generator, yield_ # optional dependency
async_generator_imported = True
except ImportError:
async_generator_imported = False # this should not throw an error, it will impact the 'import litellm' statement
# ollama implementation
def get_ollama_response_stream(
@ -39,6 +40,7 @@ def get_ollama_response_stream(
print(f"Error decoding JSON: {e}")
session.close()
if async_generator_imported:
# ollama implementation
@async_generator
async def async_get_ollama_response_stream(