Skip to content

Commit a9902f5

Browse files
committed
fix: use streaming for Shift+F2 title generation to avoid timeout
1 parent 5873182 commit a9902f5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

basilisk/gui/conversation_tab.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -824,20 +824,21 @@ def generate_conversation_title(self):
824824
temperature=self.temperature_spinner.GetValue(),
825825
top_p=self.top_p_spinner.GetValue(),
826826
max_tokens=self.max_tokens_spin_ctrl.GetValue(),
827-
stream=self.stream_mode.GetValue(),
827+
stream=True, # Required for Anthropic: long requests must use streaming
828828
)
829829
engine = self.current_engine
830830
completion_kw = {
831831
"system_message": None,
832832
"conversation": self.conversation,
833833
"new_block": new_block,
834-
"stream": False,
834+
"stream": True,
835835
}
836836
response = engine.completion(**completion_kw)
837-
new_block = engine.completion_response_without_stream(
838-
response=response, **completion_kw
839-
)
840-
return new_block.response.content
837+
content_parts = []
838+
for chunk in engine.completion_response_with_stream(response):
839+
if isinstance(chunk, str):
840+
content_parts.append(chunk)
841+
return "".join(content_parts).strip()
841842
except Exception as e:
842843
show_enhanced_error_dialog(
843844
parent=self,

0 commit comments

Comments
 (0)