From f7e2c046dd588639a051f5c7dbd22d965376760e Mon Sep 17 00:00:00 2001 From: herumes <91907013+herumes@users.noreply.github.com> Date: Fri, 7 Jun 2024 22:14:45 -0700 Subject: [PATCH] Update completions.py --- shuttleai/schemas/chat/completions.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/shuttleai/schemas/chat/completions.py b/shuttleai/schemas/chat/completions.py index 0dddf52..6056916 100644 --- a/shuttleai/schemas/chat/completions.py +++ b/shuttleai/schemas/chat/completions.py @@ -3,6 +3,7 @@ from pydantic import BaseModel, Field +from shuttleai.exceptions import ShuttleAIException from shuttleai.schemas.common import UsageInfo @@ -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