mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 01:04:59 +00:00
Try and avoid seaming errors when asking Sonnet to continue
This commit is contained in:
parent
fe4d75b123
commit
85ef60f083
1 changed files with 18 additions and 12 deletions
|
@ -807,8 +807,6 @@ class Coder:
|
||||||
|
|
||||||
messages = self.format_messages()
|
messages = self.format_messages()
|
||||||
|
|
||||||
self.io.log_llm_history("TO LLM", format_messages(messages))
|
|
||||||
|
|
||||||
if self.verbose:
|
if self.verbose:
|
||||||
utils.show_messages(messages, functions=self.functions)
|
utils.show_messages(messages, functions=self.functions)
|
||||||
|
|
||||||
|
@ -842,8 +840,8 @@ class Coder:
|
||||||
exhausted = True
|
exhausted = True
|
||||||
break
|
break
|
||||||
|
|
||||||
# Use prefill to continue the response
|
self.multi_response_content = self.get_multi_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:
|
||||||
|
@ -857,10 +855,8 @@ class Coder:
|
||||||
self.live_incremental_response(True)
|
self.live_incremental_response(True)
|
||||||
self.mdstream = None
|
self.mdstream = None
|
||||||
|
|
||||||
if self.multi_response_content:
|
self.partial_response_content = self.get_multi_response_content(True)
|
||||||
self.multi_response_content += self.partial_response_content
|
self.multi_response_content = ""
|
||||||
self.partial_response_content = self.multi_response_content
|
|
||||||
self.multi_response_content = ""
|
|
||||||
|
|
||||||
if exhausted:
|
if exhausted:
|
||||||
self.show_exhausted_error()
|
self.show_exhausted_error()
|
||||||
|
@ -880,8 +876,6 @@ class Coder:
|
||||||
|
|
||||||
self.io.tool_output()
|
self.io.tool_output()
|
||||||
|
|
||||||
self.io.log_llm_history("LLM RESPONSE", format_content("ASSISTANT", content))
|
|
||||||
|
|
||||||
if interrupted:
|
if interrupted:
|
||||||
content += "\n^C KeyboardInterrupt"
|
content += "\n^C KeyboardInterrupt"
|
||||||
self.cur_messages += [dict(role="assistant", content=content)]
|
self.cur_messages += [dict(role="assistant", content=content)]
|
||||||
|
@ -1074,6 +1068,8 @@ class Coder:
|
||||||
self.partial_response_content = ""
|
self.partial_response_content = ""
|
||||||
self.partial_response_function_call = dict()
|
self.partial_response_function_call = dict()
|
||||||
|
|
||||||
|
self.io.log_llm_history("TO LLM", format_messages(messages))
|
||||||
|
|
||||||
interrupted = False
|
interrupted = False
|
||||||
try:
|
try:
|
||||||
hash_object, completion = send_with_retries(
|
hash_object, completion = send_with_retries(
|
||||||
|
@ -1089,6 +1085,11 @@ class Coder:
|
||||||
self.keyboard_interrupt()
|
self.keyboard_interrupt()
|
||||||
interrupted = True
|
interrupted = True
|
||||||
finally:
|
finally:
|
||||||
|
self.io.log_llm_history(
|
||||||
|
"LLM RESPONSE",
|
||||||
|
format_content("ASSISTANT", self.partial_response_content),
|
||||||
|
)
|
||||||
|
|
||||||
if self.partial_response_content:
|
if self.partial_response_content:
|
||||||
self.io.ai_output(self.partial_response_content)
|
self.io.ai_output(self.partial_response_content)
|
||||||
elif self.partial_response_function_call:
|
elif self.partial_response_function_call:
|
||||||
|
@ -1207,8 +1208,13 @@ class Coder:
|
||||||
def render_incremental_response(self, final):
|
def render_incremental_response(self, final):
|
||||||
return self.get_multi_response_content()
|
return self.get_multi_response_content()
|
||||||
|
|
||||||
def get_multi_response_content(self):
|
def get_multi_response_content(self, final=False):
|
||||||
return self.multi_response_content + self.partial_response_content
|
cur = self.multi_response_content
|
||||||
|
new = self.partial_response_content
|
||||||
|
|
||||||
|
if new.rstrip() != new and not final:
|
||||||
|
new = new.rstrip()
|
||||||
|
return cur + new
|
||||||
|
|
||||||
def get_rel_fname(self, fname):
|
def get_rel_fname(self, fname):
|
||||||
return os.path.relpath(fname, self.root)
|
return os.path.relpath(fname, self.root)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue