Skip to content

Commit

Permalink
fix oai completion api error
Browse files Browse the repository at this point in the history
Signed-off-by: pandyamarut <[email protected]>
  • Loading branch information
pandyamarut committed Sep 6, 2024
1 parent f3a530b commit 814f50a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ async def _handle_chat_or_completion_request(self, openai_request: JobInput):
yield create_error_response(str(e)).model_dump()
return

response_generator = await generator_function(request, raw_request=None)
dummy_request = DummyRequest()
response_generator = await generator_function(request, raw_request=dummy_request)

if not openai_request.openai_input.get("stream") or isinstance(response_generator, ErrorResponse):
yield response_generator.model_dump()
Expand Down
4 changes: 3 additions & 1 deletion src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ def __init__(self, job):
self.openai_input = job.get("openai_input")

class DummyRequest:
def __init__(self):
self.headers = {}
async def is_disconnected(self):
return False

class BatchSize:
def __init__(self, max_batch_size, min_batch_size, batch_size_growth_factor):
self.max_batch_size = max_batch_size
Expand Down

0 comments on commit 814f50a

Please sign in to comment.