mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-15 11:02:36 +02:00
fix truncate.
This commit is contained in:
parent
ce9bd1cd02
commit
05ae935d8c
1 changed files with 3 additions and 4 deletions
|
|
@ -186,14 +186,13 @@ class ExecutePyCode(ExecuteCode, Action):
|
|||
def truncate(result: str, keep_len: int = 2000) -> str:
|
||||
desc = f"Truncated to show only the last {keep_len} characters\n"
|
||||
if result.startswith(desc):
|
||||
result = result[-len(desc) :]
|
||||
result = result[len(desc) :]
|
||||
|
||||
if len(result) > keep_len:
|
||||
result = result[-keep_len:]
|
||||
|
||||
if not result.startswith(desc):
|
||||
return desc + result
|
||||
return desc
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def remove_escape_and_color_codes(input_str):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue