summaryrefslogtreecommitdiff
path: root/src/ollama_web/tools/helper
diff options
context:
space:
mode:
Diffstat (limited to 'src/ollama_web/tools/helper')
-rw-r--r--src/ollama_web/tools/helper/pagination.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/ollama_web/tools/helper/pagination.py b/src/ollama_web/tools/helper/pagination.py
index 7f18ac8..748338b 100644
--- a/src/ollama_web/tools/helper/pagination.py
+++ b/src/ollama_web/tools/helper/pagination.py
@@ -64,7 +64,10 @@ def make_token(tool: str, url: str, offset: int, **extra: Any) -> str:
"offset": int(offset),
}
payload.update(extra)
- raw = json.dumps(payload, ensure_ascii=False, separators=(",", ":")).encode("utf-8")
+ # ensure_ascii=True keeps the token pure ASCII so truncation of the
+ # token by the model or tool-result trimming cannot split a multibyte
+ # UTF-8 sequence (which would raise UnicodeDecodeError on decode).
+ raw = json.dumps(payload, ensure_ascii=True, separators=(",", ":")).encode("ascii")
return _b64url_encode(raw)