mirror of https://github.com/kortix-ai/suna.git
Refactor whitespace and formatting in async stream printer
- Cleaned up whitespace throughout the `print_stream` function for improved readability. - Standardized output formatting for function call detection and tool result messages, enhancing clarity in logs. - Ensured consistent handling of empty lines and message content, contributing to better overall code quality.
This commit is contained in:
parent
ac9dbd7127
commit
eb53999291
|
@ -69,7 +69,9 @@ async def print_stream(stream: AsyncGenerator[str, None]):
|
|||
|
||||
full_status = {**data, **status_details}
|
||||
finish_reason = full_status.get("finish_reason", "received")
|
||||
status_type = full_status.get("status_type", full_status.get("status", "unknown"))
|
||||
status_type = full_status.get(
|
||||
"status_type", full_status.get("status", "unknown")
|
||||
)
|
||||
print(f"[STATUS] {status_type} {finish_reason}")
|
||||
|
||||
elif event_type == "assistant":
|
||||
|
@ -96,7 +98,9 @@ async def print_stream(stream: AsyncGenerator[str, None]):
|
|||
match = invoke_name_regex.search(full_text)
|
||||
if match:
|
||||
current_function_name = match.group(1)
|
||||
print(f'[TOOL UPDATE] Calling function: "{current_function_name}"')
|
||||
print(
|
||||
f'[TOOL UPDATE] Calling function: "{current_function_name}"'
|
||||
)
|
||||
|
||||
if "</function_calls>" in full_text:
|
||||
parsing_state = "function_call_ended"
|
||||
|
@ -140,12 +144,7 @@ async def print_stream(stream: AsyncGenerator[str, None]):
|
|||
print(f"[TOOL RESULT] Failed to parse message content")
|
||||
continue
|
||||
|
||||
content_str = parsed_content.get("content", "")
|
||||
if not content_str:
|
||||
print(f"[TOOL RESULT] No content string in parsed content")
|
||||
continue
|
||||
|
||||
execution_result = try_parse_json(content_str)
|
||||
execution_result = parsed_content
|
||||
if not execution_result:
|
||||
print(f"[TOOL RESULT] Failed to parse execution result")
|
||||
continue
|
||||
|
|
Loading…
Reference in New Issue