Files
xiaoli-cli/core/display.py
T
shuiyu1123 78fea7ccdd xiaoli-cli 7.0.0: 重构底层架构 + 移除工具截断
- 重构 core/ 底层 (7文件): app/runner/engine/parser/history/safety/display
- FC原生调用为主,prompt-JSON保底
- 移除所有工具返回截断 (ai_search/git_tools/cmd_executor/browser_auto/network_tools/sub_agent/tool_search)
- 删除无用文件 (旧服务器/WebUI/彩蛋/启动器等21个文件)
- 清理 constants.py 死代码
- 版本号更新为 7.0.0
2026-07-05 13:17:27 +08:00

45 lines
1.5 KiB
Python

"""显示输出"""
import sys
try:
from colorama import Fore, Style, init
init()
except ImportError:
class _D:
CYAN = GREEN = YELLOW = RED = LIGHTBLACK_EX = RESET_ALL = ''
Fore = Style = _D()
class Display:
def text(self, text, is_continue=False):
if text:
print(text)
def thinking(self, text):
if text:
t = text[:500] + "..." if len(text) > 500 else text
print(f"{Style.LIGHTBLACK_EX if hasattr(Style,'LIGHTBLACK_EX') else Fore.LIGHTBLACK_EX}[深度思考: {t}]{Style.RESET_ALL}")
def tool_start(self, tc):
args = tc.args[:80] + "..." if len(tc.args) > 80 else tc.args
print(f" {Fore.GREEN}OK 工具:{Fore.RESET_ALL if hasattr(Fore,'RESET_ALL') else Style.RESET_ALL} {tc.name}")
print(f" {Fore.CYAN}参数:{Style.RESET_ALL} {args}")
def tool_result(self, tc, result):
text = result.data if result.data is not None else result.error_message
if text:
s = str(text)
if len(s) > 2000:
lines = s.split("\n")
if len(lines) > 30:
s = "\n".join(lines[:30]) + f"\n... (共{len(lines)}行)"
print(f" {Fore.CYAN}结果:{Style.RESET_ALL}")
for line in s.split("\n"):
print(f" {line}")
def info(self, msg):
print(f"{Fore.YELLOW}{msg}{Style.RESET_ALL}")
def error(self, msg):
print(f"{Fore.RED}{msg}{Style.RESET_ALL}")