mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-03 03:05:00 +00:00
fix: Improve LLM empty response handling with clearer warning messages
This commit is contained in:
parent
012afc0708
commit
204a88c171
2 changed files with 8 additions and 4 deletions
|
@ -1721,7 +1721,7 @@ class Coder:
|
||||||
|
|
||||||
def show_send_output_stream(self, completion):
|
def show_send_output_stream(self, completion):
|
||||||
received_content = False
|
received_content = False
|
||||||
|
|
||||||
for chunk in completion:
|
for chunk in completion:
|
||||||
if len(chunk.choices) == 0:
|
if len(chunk.choices) == 0:
|
||||||
continue
|
continue
|
||||||
|
@ -1765,9 +1765,9 @@ class Coder:
|
||||||
sys.stdout.write(safe_text)
|
sys.stdout.write(safe_text)
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
yield text
|
yield text
|
||||||
|
|
||||||
if not received_content:
|
if not received_content:
|
||||||
self.io.tool_warning("Empty response received from LLM.")
|
self.io.tool_warning("Empty response received from LLM. Check your provider account?")
|
||||||
|
|
||||||
def live_incremental_response(self, final):
|
def live_incremental_response(self, final):
|
||||||
show_resp = self.render_incremental_response(final)
|
show_resp = self.render_incremental_response(final)
|
||||||
|
|
|
@ -933,6 +933,10 @@ class InputOutput:
|
||||||
return mdStream
|
return mdStream
|
||||||
|
|
||||||
def assistant_output(self, message, pretty=None):
|
def assistant_output(self, message, pretty=None):
|
||||||
|
if not message:
|
||||||
|
self.tool_warning("Empty response received from LLM. Check your provider account?")
|
||||||
|
return
|
||||||
|
|
||||||
show_resp = message
|
show_resp = message
|
||||||
|
|
||||||
# Coder will force pretty off if fence is not triple-backticks
|
# Coder will force pretty off if fence is not triple-backticks
|
||||||
|
@ -944,7 +948,7 @@ class InputOutput:
|
||||||
message, style=self.assistant_output_color, code_theme=self.code_theme
|
message, style=self.assistant_output_color, code_theme=self.code_theme
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
show_resp = Text(message or "<no response>")
|
show_resp = Text(message or "(empty response)")
|
||||||
|
|
||||||
self.console.print(show_resp)
|
self.console.print(show_resp)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue