mirror of
https://github.com/open-webui/computer.git
synced 2026-11-25 23:00:55 -05:00
refac
This commit is contained in:
1 parent
054b528fad
commit
4486d6dcc6
2 files changed
+5
-7
No files matched your search
@@ -25,6 +25,7 @@ CHAT_MAX_ITERATIONS = int(os.environ.get("CHAT_MAX_ITERATIONS", "2048"))
|
||||
ENABLE_CHAT_RECONCILE_ON_STARTUP: bool = os.environ.get(
|
||||
"ENABLE_CHAT_RECONCILE_ON_STARTUP", "true"
|
||||
).lower() in ("true", "1", "yes")
|
||||
CHAT_TOOL_MAX_CHARS = int(os.environ.get("CHAT_TOOL_MAX_CHARS", "50000"))
|
||||
|
||||
# ── AI stream settings ──────────────────────────────────────
|
||||
STREAM_CONNECT_TIMEOUT_SECONDS = float(os.environ.get("CPTR_STREAM_CONNECT_TIMEOUT", "30"))
|
||||
|
||||
+4
-7
@@ -14,6 +14,7 @@ import os
|
||||
import uuid
|
||||
from pathlib import Path
|
||||
from typing import get_type_hints
|
||||
from cptr.env import CHAT_TOOL_MAX_CHARS
|
||||
|
||||
|
||||
# ── Background task state ───────────────────────────────────
|
||||
@@ -145,11 +146,6 @@ async def list_directory(
|
||||
except OSError:
|
||||
sz = 0
|
||||
entries.append(f"{rel / f} ({_human_size(sz)})")
|
||||
if len(entries) > 500:
|
||||
entries.append("... (truncated at 500)")
|
||||
break
|
||||
if len(entries) > 500:
|
||||
break
|
||||
else:
|
||||
for item in sorted(full.iterdir()):
|
||||
if item.name in ignore:
|
||||
@@ -167,7 +163,8 @@ async def list_directory(
|
||||
sz = 0
|
||||
entries.append(f"{item.name} ({_human_size(sz)})")
|
||||
|
||||
return "\n".join(entries) if entries else "(empty directory)"
|
||||
res = "\n".join(entries) if entries else "(empty directory)"
|
||||
return _truncate_output(res, max_chars=CHAT_TOOL_MAX_CHARS)
|
||||
|
||||
|
||||
async def search_files(
|
||||
@@ -199,7 +196,7 @@ async def search_files(
|
||||
# ripgrep not installed, fall back to Python
|
||||
res = await _search_python(query, full, case_insensitive)
|
||||
|
||||
return _truncate_output(res, max_chars=30_000)
|
||||
return _truncate_output(res, max_chars=CHAT_TOOL_MAX_CHARS)
|
||||
|
||||
|
||||
async def _search_rg(
|
||||
|
||||
Reference in new issue
Block a user