Update app.py
Browse files
app.py
CHANGED
|
@@ -66,16 +66,18 @@ def _serialize_input(val: Any) -> Any:
|
|
| 66 |
def _log_call_start(func_name: str, **kwargs: Any) -> None:
|
| 67 |
try:
|
| 68 |
compact = {k: _serialize_input(v) for k, v in kwargs.items()}
|
| 69 |
-
|
|
|
|
| 70 |
except Exception as exc:
|
| 71 |
-
print(f"[TOOL CALL] {func_name} (failed to log inputs: {exc})", flush=True)
|
| 72 |
|
| 73 |
|
| 74 |
def _log_call_end(func_name: str, output_desc: str) -> None:
|
| 75 |
try:
|
| 76 |
-
|
|
|
|
| 77 |
except Exception as exc:
|
| 78 |
-
print(f"[TOOL RESULT] {func_name} (failed to log output: {exc})", flush=True)
|
| 79 |
|
| 80 |
# Ensure Tools modules can import 'app' when this file is executed as a script
|
| 81 |
# (their code does `from app import ...`).
|
|
|
|
| 66 |
def _log_call_start(func_name: str, **kwargs: Any) -> None:
|
| 67 |
try:
|
| 68 |
compact = {k: _serialize_input(v) for k, v in kwargs.items()}
|
| 69 |
+
# Use sys.__stdout__ to avoid capturing logs in redirected output
|
| 70 |
+
print(f"[TOOL CALL] {func_name} inputs: {json.dumps(compact, ensure_ascii=False)[:800]}", flush=True, file=sys.__stdout__)
|
| 71 |
except Exception as exc:
|
| 72 |
+
print(f"[TOOL CALL] {func_name} (failed to log inputs: {exc})", flush=True, file=sys.__stdout__)
|
| 73 |
|
| 74 |
|
| 75 |
def _log_call_end(func_name: str, output_desc: str) -> None:
|
| 76 |
try:
|
| 77 |
+
# Use sys.__stdout__ to avoid capturing logs in redirected output
|
| 78 |
+
print(f"[TOOL RESULT] {func_name} output: {output_desc}", flush=True, file=sys.__stdout__)
|
| 79 |
except Exception as exc:
|
| 80 |
+
print(f"[TOOL RESULT] {func_name} (failed to log output: {exc})", flush=True, file=sys.__stdout__)
|
| 81 |
|
| 82 |
# Ensure Tools modules can import 'app' when this file is executed as a script
|
| 83 |
# (their code does `from app import ...`).
|