fix: remove unsafe pop of messages (#47)
This commit is contained in:
@@ -157,13 +157,13 @@ class Session:
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
self.interrupt_reply()
|
self.interrupt_reply()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
# rewind to right before the last user message
|
||||||
|
self.exchange.rewind_to_last_user_message()
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
if self.exchange.messages:
|
|
||||||
self.exchange.messages.pop()
|
|
||||||
print(
|
print(
|
||||||
"\n[red]The error above was an exception we were not able to handle.\n\n[/]"
|
"\n[red]The error above was an exception we were not able to handle.\n\n[/]"
|
||||||
+ "These errors are often related to connection or authentication\n"
|
+ "These errors are often related to connection or authentication\n"
|
||||||
+ "We've removed your most recent input"
|
+ "We've removed the conversation up to the most recent user message"
|
||||||
+ " - [yellow]depending on the error you may be able to continue[/]"
|
+ " - [yellow]depending on the error you may be able to continue[/]"
|
||||||
)
|
)
|
||||||
self.notifier.stop()
|
self.notifier.stop()
|
||||||
|
|||||||
Reference in New Issue
Block a user