Skip to content

Commit

Permalink
Merge pull request #59 from Supahands/develop
Browse files Browse the repository at this point in the history
Develop to main for bugfix
  • Loading branch information
OriginalByteMe authored Dec 11, 2024
2 parents 4e2a66f + 0ffb0b8 commit bc55ccb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ai_router.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,15 @@ async def handle_completion(
)

end_time = time.time()

response_obj.usage.response_time = (end_time - start_time) * 1000

response_obj.choices[0].message.content = redact_words(model_name, response_obj.choices[0].message.content)
# Check if response is empty and replace with default message
content = response_obj.choices[0].message.content
if not content or content.strip() == "":
response_obj.choices[0].message.content = "Sorry, I couldn't answer this question :("
else:
response_obj.choices[0].message.content = redact_words(model_name, content)

# Convert the usage object
response_obj.usage = Usage.from_response(response_obj)

Expand Down

0 comments on commit bc55ccb

Please sign in to comment.