summaryrefslogtreecommitdiff
path: root/src/ollama_web/prompts
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-09-13 13:35:03 +0900
committertanaka takashi <isazaka@gmail.com>2026-09-13 13:35:03 +0900
commitf2d24cb7d437ad099291262d7c1b021809cd66ae (patch)
treed9a11a3795e0296358cea7a497edffbe898f4583 /src/ollama_web/prompts
parentf36cc852cc1792bd624ff701fb2476d0b43fa1af (diff)
feat(multimedia): MCP画像・音声artifactの安全な表示経路を追加
MCP Tool結果をテキストと型付きartifactへ分離し、画像・音声のbase64をMIME、サイズ、件数のallowlistで検証する。annotations.audienceを反映し、ユーザー向けartifactだけをセッションへ保存してSSEにはメタデータのみを公開する。 画像はvision capabilityが明示されたモデルだけへ渡し、非対応時は既存の多言語プロンプト機構による固定通知へ置き換える。MCP生成音声とユーザー添付音声はOllamaへ送らず、誤デコードしたテキストやbase64がモデル入力へ混入しないポリシーに統一する。 保存メディア用の認証済み同一オリジン配信ルートを追加し、セッションスコープ、MIME allowlist、nosniff、private/no-store、Rangeリクエストを適用する。UIはMCP由来HTMLを使わずDOM APIでimgとaudio controlsを生成し、CSPへmedia-src selfを追加する。 web_searchは文字列メタデータだけを返す既存仕様を維持する。scrape_urlとsearch_and_fetchは画像・音声・動画レスポンスを拒否し、search_and_fetchの対象拡張子を明示的allowlistへ変更して標準Webツールをテキスト専用の契約に揃える。 責務境界と導入しない過剰対策をdocs/multimedia.mdへ記録し、README、ツール仕様、CHANGELOGを更新する。MCP artifact変換・永続化、vision分岐、音声非送信、認証、Range配信、MIME偽装拒否をテストで追加確認した。 Validation: 148 tests passed; ruff check passed; mypy src passed; node --check src/ollama_web/static/app.js passed.
Diffstat (limited to 'src/ollama_web/prompts')
-rw-r--r--src/ollama_web/prompts/__init__.py2
-rw-r--r--src/ollama_web/prompts/en.json4
-rw-r--r--src/ollama_web/prompts/ja.json4
3 files changed, 9 insertions, 1 deletions
diff --git a/src/ollama_web/prompts/__init__.py b/src/ollama_web/prompts/__init__.py
index 5b6b53e..d750248 100644
--- a/src/ollama_web/prompts/__init__.py
+++ b/src/ollama_web/prompts/__init__.py
@@ -54,4 +54,4 @@ def get_prompt(key: str, lang: str | None = None, fallback: str | None = None) -
current = current[part]
if isinstance(current, str):
return current
- return fallback if fallback is not None else key \ No newline at end of file
+ return fallback if fallback is not None else key
diff --git a/src/ollama_web/prompts/en.json b/src/ollama_web/prompts/en.json
index 1d35f52..834a6e3 100644
--- a/src/ollama_web/prompts/en.json
+++ b/src/ollama_web/prompts/en.json
@@ -5,6 +5,10 @@
"pagination_incomplete_instruction": "A paged source still has unread content. Answer only from the retrieved portion and do not claim that the full source was reviewed.",
"attachment_prefix": "The following is the content of files attached by the user:",
"attachment_paging": "A PDF body is an initial preview. When has_more is true, pass the attached-file uri and next_token to pdf_to_text for the needed continuation. Do not claim to have read the full file while unread content remains.",
+ "vision_unsupported_attachment": "The user attached an image, but the currently selected model does not support image input. The image contents were not provided to the model. Explain this limitation to the user when relevant.",
+ "audio_unsupported_attachment": "The user attached audio. The audio data itself was not provided to the model. Explain this limitation to the user when relevant.",
+ "mcp_image_artifact_notice": "The MCP tool generated an image, but the current model does not support image input, so the image contents were not provided to the model.",
+ "mcp_audio_artifact_notice": "The MCP tool generated audio. The audio data itself was not provided to the model.",
"fetch": {
"candidate": "Candidate",
"title": "Title",
diff --git a/src/ollama_web/prompts/ja.json b/src/ollama_web/prompts/ja.json
index 6bcba63..5742fbc 100644
--- a/src/ollama_web/prompts/ja.json
+++ b/src/ollama_web/prompts/ja.json
@@ -5,6 +5,10 @@
"pagination_incomplete_instruction": "ページングされた資料に未取得部分があります。取得済み範囲だけを根拠に回答し、全文を確認したとは述べないでください。",
"attachment_prefix": "以下はユーザーが添付したファイルの内容です:",
"attachment_paging": "PDFは先頭プレビューです。has_more: true の場合、attached-file の uri と next_token を pdf_to_text に渡し、必要な範囲を続けて取得してください。未取得部分が残る場合は全文を読んだと主張しないでください。",
+ "vision_unsupported_attachment": "ユーザーは画像を添付しましたが、現在選択されているモデルは画像入力に対応していません。画像の内容はモデルへ提供されていません。必要に応じて、この制限をユーザーへ説明してください。",
+ "audio_unsupported_attachment": "ユーザーは音声を添付しました。音声データそのものはモデルへ提供されていません。必要に応じて、この制限をユーザーへ説明してください。",
+ "mcp_image_artifact_notice": "MCPツールは画像を生成しましたが、現在のモデルは画像入力に対応していないため、画像の内容はモデルへ提供されていません。",
+ "mcp_audio_artifact_notice": "MCPツールは音声を生成しました。音声データそのものはモデルへ提供されていません。",
"fetch": {
"candidate": "候補",
"title": "タイトル",