Merge pull request #1168 from clevcode/main

Fix for issue that occured when proxying to ollama
This commit is contained in:
Krish Dholakia 2023-12-18 17:54:59 -08:00 committed by GitHub
commit 67112ea81d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View file

@ -195,7 +195,7 @@ async def ollama_acompletion(url, data, model_response, encoding, logging_obj):
raise OllamaError(status_code=resp.status, message=text)
completion_string = ""
async for line in resp.content.iter_any():
async for line in resp.content:
if line:
try:
json_chunk = line.decode("utf-8")

View file

@ -2026,11 +2026,9 @@ async def atext_completion(*args, **kwargs):
response = text_completion(*args, **kwargs)
else:
# Await normally
init_response = await loop.run_in_executor(None, func_with_context)
if isinstance(init_response, dict) or isinstance(init_response, ModelResponse): ## CACHING SCENARIO
response = init_response
elif asyncio.iscoroutine(init_response):
response = await init_response
response = await loop.run_in_executor(None, func_with_context)
if asyncio.iscoroutine(response):
response = await response
else:
# Call the synchronous function using run_in_executor
response = await loop.run_in_executor(None, func_with_context)