diff options
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() |
