From e4d421c782a181f421e2987f75b4610845e3ef55 Mon Sep 17 00:00:00 2001 From: tanaka takashi Date: Wed, 24 Jun 2026 22:47:13 +0900 Subject: Harden web UI security --- src/ollama_web/llm.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/ollama_web/llm.py') diff --git a/src/ollama_web/llm.py b/src/ollama_web/llm.py index 40af2d4..a18abf4 100644 --- a/src/ollama_web/llm.py +++ b/src/ollama_web/llm.py @@ -198,7 +198,10 @@ def chat_with_tools( # Exceeded tool rounds: ask for a final answer without tools. logger.info( - "max tool rounds exceeded, requesting final answer without tools (cumulative_tool_chars=%d)", + ( + "max tool rounds exceeded, requesting final answer without tools " + "(cumulative_tool_chars=%d)" + ), cumulative_tool_chars, ) yield { @@ -354,7 +357,12 @@ def stream_chat_with_tools( # Always truncate per-tool result immediately so it does not bloat # the context even before we reach the cumulative limit. result = _trim_tool_result(result, settings.max_tool_result_chars) - logger.info("tool %s executed len=%d elapsed=%.2fs", name, len(result), time.time() - t1) + logger.info( + "tool %s executed len=%d elapsed=%.2fs", + name, + len(result), + time.time() - t1, + ) yield {"type": "tool_end", "name": name, "result": result} tool_results.append((name, result)) total_result_len += len(result) @@ -380,7 +388,10 @@ def stream_chat_with_tools( # Exceeded tool rounds: ask for a final answer without tools. logger.info( - "max tool rounds exceeded, requesting final answer without tools (cumulative_tool_chars=%d)", + ( + "max tool rounds exceeded, requesting final answer without tools " + "(cumulative_tool_chars=%d)" + ), cumulative_tool_chars, ) yield { -- cgit v1.2.3