Skip to content

Commit

Permalink
Fix issue found by unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
paulovcmedeiros committed Mar 2, 2024
1 parent a86c27a commit 3cb587e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pyrobbot/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def yield_response_from_msg(
)

except (ReachedMaxNumberOfAttemptsError, openai.OpenAIError) as error:
yield self.response_failure_message(error=error)
yield self.response_failure_message(exchange_id=exchange_id, error=error)

def start(self):
"""Start the chat."""
Expand Down Expand Up @@ -319,14 +319,16 @@ def report_token_usage(self, report_current_chat=True, report_general: bool = Fa
print()
print(df.attrs["disclaimer"])

def response_failure_message(self, error: Optional[Exception] = None):
def response_failure_message(
self, exchange_id: Optional[str] = "", error: Optional[Exception] = None
):
"""Return the error message errors getting a response."""
msg = "Could not get a response right now."
if error is not None:
msg += f" The reason seems to be: {error} "
msg += "Please check your connection or OpenAI API key."
logger.opt(exception=True).debug(error)
return AssistantResponseChunk(msg)
return AssistantResponseChunk(exchange_id=exchange_id, content=msg)

def stt(self, speech: AudioSegment):
"""Convert audio to text."""
Expand Down

0 comments on commit 3cb587e

Please sign in to comment.