diff options
| author | tanaka takashi <isazaka@gmail.com> | 2026-06-28 14:47:26 +0900 |
|---|---|---|
| committer | tanaka takashi <isazaka@gmail.com> | 2026-06-28 14:47:26 +0900 |
| commit | 9e430700cc58adbed5baf110961c08cbcb6a7135 (patch) | |
| tree | e23126ed0636e5d09c92dfeaa98d3228b0bfc03a /src | |
| parent | 967bbca9829ce65edec7a945a571f91e4998a8be (diff) | |
システムプロンプトへローカルタイムの現在時刻を注入するように変更
Diffstat (limited to 'src')
| -rw-r--r-- | src/ollama_web/prompts/en.json | 1 | ||||
| -rw-r--r-- | src/ollama_web/prompts/ja.json | 1 | ||||
| -rw-r--r-- | src/ollama_web/routes/chat.py | 11 |
3 files changed, 11 insertions, 2 deletions
diff --git a/src/ollama_web/prompts/en.json b/src/ollama_web/prompts/en.json index 53af74b..72a0b20 100644 --- a/src/ollama_web/prompts/en.json +++ b/src/ollama_web/prompts/en.json @@ -1,5 +1,6 @@ { "tool_system": "You can use web search, scraping, and file fetch tools. Do not run more searches than necessary in a single response; review the results before conducting the next investigation. Tool results are summarized, so grasp the important points and use them effectively.", + "current_time": "Current time: {time}", "tool_limit_instruction": "The tool call limit has been reached. Based on the search results and conversation so far, please summarize the final answer the user requested.", "attachment_prefix": "The following is the content of files attached by the user:", "fetch": { diff --git a/src/ollama_web/prompts/ja.json b/src/ollama_web/prompts/ja.json index 40f6c7c..00698c2 100644 --- a/src/ollama_web/prompts/ja.json +++ b/src/ollama_web/prompts/ja.json @@ -1,5 +1,6 @@ { "tool_system": "あなたはWeb検索・スクレイピング・ファイル取得ツールを利用できます。一度の回答で必要以上に多くの検索を同時に行わず、結果を確認してから次の調査を行ってください。各ツール結果は要約されて提供されるため、重要なポイントを把握して活用してください。", + "current_time": "現在時刻: {time}", "tool_limit_instruction": "ツール呼び出しの上限に達しました。これまでの検索結果と会話を元に、ユーザーが求めた回答を最終的にまとめてください。", "attachment_prefix": "以下はユーザーが添付したファイルの内容です:", "fetch": { diff --git a/src/ollama_web/routes/chat.py b/src/ollama_web/routes/chat.py index c8cbcff..4c3fe48 100644 --- a/src/ollama_web/routes/chat.py +++ b/src/ollama_web/routes/chat.py @@ -8,6 +8,7 @@ import inspect import json import logging from collections.abc import AsyncIterator +from datetime import datetime from typing import Any from ollama import Message @@ -35,9 +36,15 @@ def _limit_text(text: str, limit: int) -> str: def _compose_system_prompt(language: str, custom_prompt: str) -> str: - """Combine the localized built-in tool prompt with the user prompt.""" + """Combine the localized built-in tool prompt, current time, and user prompt.""" tool_prompt = get_prompt("tool_system", lang=language) - return f"{tool_prompt}\n\n{custom_prompt}" if custom_prompt else tool_prompt + time_line = get_prompt("current_time", lang=language).format( + time=datetime.now().strftime("%Y-%m-%d %H:%M:%S") + ) + parts = [tool_prompt, time_line] + if custom_prompt: + parts.append(custom_prompt) + return "\n\n".join(parts) def _parse_messages(raw: list[dict[str, Any]]) -> list[Message]: |
