Skip to content

Commit

Permalink
Update completions.py
Browse files Browse the repository at this point in the history
  • Loading branch information
herumes committed Jun 8, 2024
1 parent 482b3ef commit f7e2c04
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions shuttleai/schemas/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from pydantic import BaseModel, Field

from shuttleai.exceptions import ShuttleAIException
from shuttleai.schemas.common import UsageInfo


Expand Down Expand Up @@ -120,3 +121,17 @@ def provider_id(self) -> str:
@property
def request_id(self) -> str:
return self.x_sai.id

def print_response(self) -> None:
try:
print(f"Request ID: {self.request_id}")
print(f"Provider ID: {self.provider_id}")
print(f"Model: {self.model}")
print(f"Created: {self.created}")
print(f"Usage: {self.usage}")
for choice in self.choices:
print(f"Index: {choice.index}")
print(f"Message: {choice.message}")
print(f"Finish Reason: {choice.finish_reason}")
except Exception as e:
raise ShuttleAIException(f"Error printing response: {e}") from e

0 comments on commit f7e2c04

Please sign in to comment.