fix test for windows

This commit is contained in:
Paul Gauthier 2024-06-28 17:09:08 -07:00
parent a042914e66
commit 6f1e26157e

View file

@ -821,39 +821,40 @@ class Coder:
exhausted = False exhausted = False
interrupted = False interrupted = False
while True: try:
try: while True:
yield from self.send(messages, functions=self.functions) try:
break yield from self.send(messages, functions=self.functions)
except KeyboardInterrupt: break
interrupted = True except KeyboardInterrupt:
break interrupted = True
except litellm.ContextWindowExceededError: break
# The input is overflowing the context window! except litellm.ContextWindowExceededError:
exhausted = True # The input is overflowing the context window!
break
except litellm.exceptions.BadRequestError as br_err:
self.io.tool_error(f"BadRequestError: {br_err}")
return
except FinishReasonLength:
# We hit the 4k output limit!
if not self.main_model.can_prefill:
exhausted = True exhausted = True
break break
except litellm.exceptions.BadRequestError as br_err:
self.io.tool_error(f"BadRequestError: {br_err}")
return
except FinishReasonLength:
# We hit the 4k output limit!
if not self.main_model.can_prefill:
exhausted = True
break
# Use prefill to continue the response # Use prefill to continue the response
self.multi_response_content += self.partial_response_content self.multi_response_content += self.partial_response_content
if messages[-1]["role"] == "assistant": if messages[-1]["role"] == "assistant":
messages[-1]["content"] = self.multi_response_content messages[-1]["content"] = self.multi_response_content
else: else:
messages.append(dict(role="assistant", content=self.multi_response_content)) messages.append(dict(role="assistant", content=self.multi_response_content))
except Exception as err: except Exception as err:
self.io.tool_error(f"Unexpected error: {err}") self.io.tool_error(f"Unexpected error: {err}")
traceback.print_exc() traceback.print_exc()
return return
finally:
if self.mdstream: if self.mdstream:
self.live_incremental_response(True) self.live_incremental_response(True)
if self.multi_response_content: if self.multi_response_content:
self.multi_response_content += self.partial_response_content self.multi_response_content += self.partial_response_content