diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-08-02 15:50:41 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-08-02 15:50:41 +0900 |
| commit | 515f96a7779f117a7e37f854de2ded99160d0c76 (patch) | |
| tree | b63e4b39da1f7edb18146e94b16a76d4925948a4 /src/ollama_web/routes/chat.py | |
| parent | 1729e1c399a41b4128b5dd7ef0286fae128e6157 (diff) | |
scrape_url / pdf_to_text / search_and_fetch はページング(継続トークン方式)に対応
mypy 6エラー修正
Diffstat (limited to 'src/ollama_web/routes/chat.py')
| -rw-r--r-- | src/ollama_web/routes/chat.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/src/ollama_web/routes/chat.py b/src/ollama_web/routes/chat.py index d69fa36..e5b90d3 100644 --- a/src/ollama_web/routes/chat.py +++ b/src/ollama_web/routes/chat.py @@ -113,8 +113,8 @@ def _attachment_context(store: SessionStore, session_id: str, file_ids: list[str continue text = _limit_text(chat_file.text or "", settings.max_attachment_text_chars) parts.append( - f"<attached-file name=\"{html.escape(chat_file.name)}\" id=\"{chat_file.id}\" " - f"source=\"{chat_file.source}\">\n{text}\n</attached-file>" + f'<attached-file name="{html.escape(chat_file.name)}" id="{chat_file.id}" ' + f'source="{chat_file.source}">\n{text}\n</attached-file>' ) if not parts: return "" @@ -276,8 +276,14 @@ async def _chat_event_stream( logger.info("enabled tools capability fallback for cloud model %s", model) async for event in llm.astream_chat_with_tools( - messages, model, think=think, host=host, registry=registry, - capabilities=capabilities, options=ollama_options, language=language, + messages, + model, + think=think, + host=host, + registry=registry, + capabilities=capabilities, + options=ollama_options, + language=language, ): if event.get("type") == "delta": assistant_text = _limit_text( @@ -296,8 +302,7 @@ async def _chat_event_stream( # Persist the error as the assistant message so it survives reloads # and re-renders in the chat pane. assistant_text = ( - f"[ERROR] {error_msg}\n\n" - f"{t('errors.vision_model_required', lang=language)}" + f"[ERROR] {error_msg}\n\n{t('errors.vision_model_required', lang=language)}" ) finally: @@ -375,4 +380,4 @@ async def chat(request: Request) -> StreamingResponse: async def _single_event(data: str) -> AsyncIterator[bytes]: """Yield a single SSE event and finish.""" - yield f"data: {data}\n\n".encode()
\ No newline at end of file + yield f"data: {data}\n\n".encode() |
