8
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Open WebUIの隠れたLLM呼び出し9種:Chat Completion以外で何が動く?(Prompt/API/設定)

Posted at

はじめに

GMOコネクトの永田です。

Open WebUIを使っていると、チャット送信後に「関連質問」が自動表示されたり、チャットタイトルが自動生成されたりしますよね。

実はチャット本体とは別に、裏でLLM(Ollama等)を複数回呼び出していることをご存知でしょうか?

本記事では、Open WebUIのソースコードを深掘りして、Chat Completionを除く9種類のLLM呼び出し機能を分析します。

各機能のPromptテンプレート、APIエンドポイント、環境変数設定など、LLMリソース最適化やカスタマイズに必要な情報を整理しています。

最初にまとめ

  • 実装内容: Chat Completionを除く9種類のLLM呼び出し機能(自動実行6種、手動実行2種、システム内部1種)
  • カスタマイズ可能: すべてのPromptテンプレートは環境変数で言語やドメインに応じてカスタマイズ可能
  • リソース最適化: Follow-Up、Title、Tags、Image Prompt、Query Generation、Autocomplete、MOAは設定でDisable可能。LLM呼び出し量を削減可能

LLM呼び出し機能のサマリー表

Open WebUIが実装している全9種類のLLM呼び出し機能(Chat Completionを除く)を一覧にまとめました。

メイン処理(チャットの本体)

No. 機能名 呼び出しタイミング 設定でDisable可能 説明
0 Chat Completion
チャット応答生成
ユーザーがメッセージ送信時 - ユーザーのメッセージに対する回答を生成

自動実行タスク(チャット実行中・完了後に自動実行)

No. 機能名 呼び出しタイミング 設定でDisable可能 デフォルト
1 Follow-Up Questions
関連質問生成
チャット完了後 有効
2 Title Generation
タイトル生成
チャット完了後 有効
3 Tags Generation
タグ生成
チャット完了後 有効
4 Image Prompt Generation
画像プロンプト生成
画像生成リクエスト実行時 有効
5 Function Calling
関数呼び出し選択
ツール機能有効時 - -
6 Autocomplete
テキスト補完
ユーザー入力中 無効

手動実行タスク(ユーザー操作により実行)

No. 機能名 呼び出しタイミング 設定でDisable可能 デフォルト 用途
7 Query Generation
検索クエリ生成
Web検索実行時 有効 RAG/Web検索
8 MOA
複数モデル統合
ユーザーが「Merge Responses」ボタンを押下 - - 複数回答の統合

システム内部呼び出し

No. 機能名 呼び出しタイミング 用途
9 Voice Mode
音声アシスタント
音声モード有効時 音声対話最適化

各LLM呼び出しの詳細

それでは、各機能を詳しく見ていきましょう!


1. Follow-Up Questions(関連質問生成)

概要

チャット完了後、ユーザーが次に質問しそうな3-5個の関連質問を自動生成します。
会話の継続を促進し、ユーザー体験を向上させる機能です。

エンドポイント

POST /api/v1/tasks/follow_ups/completions

LLM Prompt

### Task:
Suggest 3-5 relevant follow-up questions or prompts that the user might naturally ask next in this conversation as a **user**, based on the chat history, to help continue or deepen the discussion.

### Guidelines:
- Write all follow-up questions from the user's point of view, directed to the assistant.
- Make questions concise, clear, and directly related to the discussed topic(s).
- Only suggest follow-ups that make sense given the chat content and do not repeat what was already covered.
- If the conversation is very short or not specific, suggest more general (but relevant) follow-ups the user might ask.
- Use the conversation's primary language; default to English if multilingual.
- Response must be a JSON array of strings, no extra text or formatting.

### Output:
JSON format: { "follow_ups": ["Question 1?", "Question 2?", "Question 3?"] }

### Chat History:
<chat_history>
{{MESSAGES:END:6}}
</chat_history>

キーポイント

  • メッセージ数: 最後の6メッセージを参照({{MESSAGES:END:6}}
  • 出力形式: JSON形式 { "follow_ups": [...] }
  • 言語対応: 会話の主要言語を自動判定

GitHub ソースコード

設定

# 環境変数
ENABLE_FOLLOW_UP_GENERATION=true  # 有効化フラグ
FOLLOW_UP_GENERATION_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

2. Title Generation(タイトル生成)

概要

チャット内容を**3-5語で要約したタイトル(絵文字付き)**を自動生成します。
チャットセッションの識別・整理に利用されます。

エンドポイント

POST /api/v1/tasks/title/completions

LLM Prompt

### Task:
Generate a concise, 3-5 word title with an emoji summarizing the chat history.

### Guidelines:
- The title should clearly represent the main theme or subject of the conversation.
- Use emojis that enhance understanding of the topic, but avoid quotation marks or special formatting.
- Write the title in the chat's primary language; default to English if multilingual.
- Prioritize accuracy over excessive creativity; keep it clear and simple.
- Your entire response must consist solely of the JSON object, without any introductory or concluding text.
- The output must be a single, raw JSON object, without any markdown code fences or other encapsulating text.
- Ensure no conversational text, affirmations, or explanations precede or follow the raw JSON output, as this will cause direct parsing failure.

### Output:
JSON format: { "title": "your concise title here" }

### Examples:
- { "title": "📉 Stock Market Trends" }
- { "title": "🍪 Perfect Chocolate Chip Recipe" }
- { "title": "Evolution of Music Streaming" }
- { "title": "Remote Work Productivity Tips" }
- { "title": "Artificial Intelligence in Healthcare" }
- { "title": "🎮 Video Game Development Insights" }

### Chat History:
<chat_history>
{{MESSAGES:END:2}}
</chat_history>

キーポイント

  • メッセージ数: 最後の2メッセージのみ参照(軽量)
  • 出力形式: JSON形式 { "title": "..." }
  • 特殊パラメータ: num_predict: 1000(出力トークン数制限)

GitHub ソースコード

設定

ENABLE_TITLE_GENERATION=true  # 有効化フラグ
TITLE_GENERATION_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

3. Tags Generation(タグ生成)

概要

チャット内容を1-3個のタグで分類します。
タグで検索・フィルタリングして、関連するチャットを素早く見つけられます。

エンドポイント

POST /api/v1/tasks/tags/completions

LLM Prompt

### Task:
Generate 1-3 broad tags categorizing the main themes of the chat history, along with 1-3 more specific subtopic tags.

### Guidelines:
- Start with high-level domains (e.g. Science, Technology, Philosophy, Arts, Politics, Business, Health, Sports, Entertainment, Education)
- Consider including relevant subfields/subdomains if they are strongly represented throughout the conversation
- If content is too short (less than 3 messages) or too diverse, use only ["General"]
- Use the chat's primary language; default to English if multilingual
- Prioritize accuracy over specificity

### Output:
JSON format: { "tags": ["tag1", "tag2", "tag3"] }

### Chat History:
<chat_history>
{{MESSAGES:END:6}}
</chat_history>

キーポイント

  • メッセージ数: 最後の6メッセージ
  • 出力形式: JSON形式 { "tags": [...] }
  • ドメイン分類: Science, Technology, Education等の高レベルドメインを推奨

GitHub ソースコード

設定

ENABLE_TAGS_GENERATION=true  # 有効化フラグ
TAGS_GENERATION_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

4. Image Prompt Generation(画像プロンプト生成)

概要

フロントエンドから画像生成リクエスト(features.image_generation)が送信され、かつ入力画像がない場合、その画像生成用の詳細なプロンプトを自動生成します。
DALL-E、Stable Diffusion等の画像生成AIへの入力プロンプトを最適化するために利用されます。

具体的には:

  1. ユーザーが「猫の画像を生成して」と言う
  2. フロントエンドが画像生成リクエストを送信(features.image_generation
  3. 入力画像がない場合(画像編集ではなく新規生成)
  4. Image Prompt Generationが呼び出される
  5. ユーザーの簡潔な指示(「猫」)を詳細なプロンプト(「茶色い猫が窓際で日光を浴びている...」)に変換
  6. 変換されたプロンプトで画像生成APIを呼び出す

エンドポイント

POST /api/v1/tasks/image_prompt/completions

LLM Prompt

### Task:
Generate a detailed prompt for an image generation task based on the given language and context. Describe the image as if you were explaining it to someone who cannot see it. Include relevant details, colors, shapes, and any other important elements.

### Guidelines:
- Be descriptive and detailed, focusing on the most important aspects of the image.
- Avoid making assumptions or adding information not present in the image.
- Use the chat's primary language; default to English if multilingual.
- If the image is too complex, focus on the most prominent elements.

### Output:
Strictly return in JSON format:
{
    "prompt": "Your detailed description here."
}

### Chat History:
<chat_history>
{{MESSAGES:END:6}}
</chat_history>

キーポイント

  • メッセージ数: 最後の6メッセージ
  • 出力形式: JSON形式 { "prompt": "..." }
  • 用途: DALL-E、Stable Diffusion等の画像生成AIへのプロンプト

GitHub ソースコード

設定

ENABLE_IMAGE_PROMPT_GENERATION=true  # 有効化フラグ
IMAGE_PROMPT_GENERATION_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

5. Function Calling(関数呼び出し選択)

概要

利用可能なツール/関数から、ユーザーのクエリに最適な関数を選択します。
LLMベースの関数呼び出し(Function Calling)機能で使用されます。

システムプロンプト

Available Tools: {{TOOLS}}

Your task is to choose and return the correct tool(s) from the list of available tools based on the query. Follow these guidelines:

- Return only the JSON object, without any additional text or explanation.

- If no tools match the query, return an empty array: 
   {
     "tool_calls": []
   }

- If one or more tools match the query, construct a JSON response containing a "tool_calls" array with objects that include:
   - "name": The tool's name.
   - "parameters": A dictionary of required parameters and their corresponding values.

The format for the JSON response is strictly:
{
  "tool_calls": [
    {"name": "toolName1", "parameters": {"key1": "value1"}},
    {"name": "toolName2", "parameters": {"key2": "value2"}}
  ]
}

キーポイント

  • 実行位置: チャット処理中のMiddlewareで自動実行
  • 入力: 利用可能なツール定義({{TOOLS}}
  • 出力形式: JSON形式 { "tool_calls": [...] }
  • 用途: LLMによる動的な関数選択・実行

GitHub ソースコード

設定

TOOLS_FUNCTION_CALLING_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

6. Autocomplete(テキスト補完)

概要

ユーザーの入力途中でテキスト補完候補を生成します(デフォルト無効)。

エンドポイント

POST /api/v1/tasks/auto/completions

LLM Prompt

### Task:
You are an autocompletion system. Continue the text in `<text>` based on the **completion type** in `<type>` and the given language.  

### **Instructions**:
1. Analyze `<text>` for context and meaning.  
2. Use `<type>` to guide your output:  
   - **General**: Provide a natural, concise continuation.  
   - **Search Query**: Complete as if generating a realistic search query.  
3. Start as if you are directly continuing `<text>`. Do **not** repeat, paraphrase, or respond as a model. Simply complete the text.  
4. Ensure the continuation:
   - Flows naturally from `<text>`.  
   - Avoids repetition, overexplaining, or unrelated ideas.  
5. If unsure, return: `{ "text": "" }`.  

### **Output Rules**:
- Respond only in JSON format: `{ "text": "<your_completion>" }`.

### **Examples**:
#### Example 1:  
Input:  
<type>General</type>  
<text>The sun was setting over the horizon, painting the sky</text>  
Output:  
{ "text": "with vibrant shades of orange and pink." }

#### Example 2:  
Input:  
<type>Search Query</type>  
<text>Top-rated restaurants in</text>  
Output:  
{ "text": "New York City for Italian cuisine." }  

---
### Context:
<chat_history>
{{MESSAGES:END:6}}
</chat_history>
<type>{{TYPE}}</type>  
<text>{{PROMPT}}</text>  

キーポイント

  • メッセージ数: 最後の6メッセージ(コンテキスト用)
  • 出力形式: JSON形式 { "text": "..." }
  • 補完タイプ: General(通常補完)、Search Query(検索クエリ補完)
  • デフォルト: 無効(パフォーマンス考慮)

GitHub ソースコード

設定

ENABLE_AUTOCOMPLETE_GENERATION=false  # デフォルト無効
AUTOCOMPLETE_GENERATION_INPUT_MAX_LENGTH=-1  # 入力長制限(-1=無制限)
AUTOCOMPLETE_GENERATION_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

7. Query Generation(検索クエリ生成)

概要

ユーザーのクエリに対して、Web検索に最適な1-3個の検索クエリを生成します。
RAG(Retrieval Augmented Generation)/Web検索機能で使用されます。

エンドポイント

POST /api/v1/tasks/queries/completions

LLM Prompt

### Task:
Analyze the chat history to determine the necessity of generating search queries, in the given language. By default, **prioritize generating 1-3 broad and relevant search queries** unless it is absolutely certain that no additional information is required. The aim is to retrieve comprehensive, updated, and valuable information even with minimal uncertainty. If no search is unequivocally needed, return an empty list.

### Guidelines:
- Respond **EXCLUSIVELY** with a JSON object. Any form of extra commentary, explanation, or additional text is strictly prohibited.
- When generating search queries, respond in the format: { "queries": ["query1", "query2"] }, ensuring each query is distinct, concise, and relevant to the topic.
- If and only if it is entirely certain that no useful results can be retrieved by a search, return: { "queries": [] }.
- Err on the side of suggesting search queries if there is **any chance** they might provide useful or updated information.
- Be concise and focused on composing high-quality search queries, avoiding unnecessary elaboration, commentary, or assumptions.
- Today's date is: {{CURRENT_DATE}}.
- Always prioritize providing actionable and broad queries that maximize informational coverage.

### Output:
Strictly return in JSON format: 
{
  "queries": ["query1", "query2"]
}

### Chat History:
<chat_history>
{{MESSAGES:END:6}}
</chat_history>

キーポイント

  • メッセージ数: 最後の6メッセージ
  • 出力形式: JSON形式 { "queries": [...] }
  • 特殊変数: {{CURRENT_DATE}}(現在日付を自動挿入)
  • 条件付き実行: 検索不要と判定された場合は空配列を返却

GitHub ソースコード

設定

ENABLE_SEARCH_QUERY_GENERATION=true  # Web検索
ENABLE_RETRIEVAL_QUERY_GENERATION=true  # RAG検索
QUERY_GENERATION_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

8. MOA(複数モデル統合)

概要

複数のLLMモデルの応答を統合し、高品質な回答を生成します。
ユーザーが「Merge Responses」ボタンを押下したときに実行されます。

エンドポイント

POST /api/v1/tasks/moa/completions

LLM Prompt

You have been provided with a set of responses from various models to the latest user query: "{{prompt}}"

Your task is to synthesize these responses into a single, high-quality response. It is crucial to critically evaluate the information provided in these responses, recognizing that some of it may be biased or incorrect. Your response should not simply replicate the given answers but should offer a refined, accurate, and comprehensive reply to the instruction. Ensure your response is well-structured, coherent, and adheres to the highest standards of accuracy and reliability.

Responses from models: {{responses}}

キーポイント

  • 入力: 元の質問({{prompt}})+ 複数モデルの応答({{responses}}
  • 出力形式: テキスト応答(ストリーミング対応)
  • 呼び出し条件:
    • マルチモデル回答表示中
    • すべての回答が完了(done
  • UI: チャット応答のすぐ下に「Merge Responses」ボタンが表示

GitHub ソースコード


9. Voice Mode(音声アシスタント)

概要

音声入出力用に最適化されたアシスタント。
音声で読み上げるための簡潔で自然な応答を生成します。

LLM Prompt

You are a friendly, concise voice assistant.

Everything you say will be spoken aloud.
Keep responses short, clear, and natural.

STYLE:
- Use simple words and short sentences.
- Sound warm and conversational.
- Avoid long explanations, lists, or complex phrasing.

BEHAVIOR:
- Give the quickest helpful answer first.
- Offer extra detail only if needed.
- Ask for clarification only when necessary.

VOICE OPTIMIZATION:
- Break information into small, easy-to-hear chunks.
- Avoid dense wording or anything that sounds like reading text.

ERROR HANDLING:
- If unsure, say so briefly and offer options.
- If something is unsafe or impossible, decline kindly and suggest a safe alternative.

Stay consistent, helpful, and easy to listen to.

キーポイント

  • 実行タイミング: 音声モード有効時にシステムプロンプトとして機能
  • 出力形式: テキスト(音声合成エンジンで読み上げ)
  • 最適化: 短文、シンプルな表現、会話的なトーン

GitHub ソースコード

設定

VOICE_MODE_PROMPT_TEMPLATE=""  # カスタムPrompt(空=デフォルト使用)

まとめ(再掲)

  • 実装内容: Chat Completionを除く9種類のLLM呼び出し機能(自動実行6種、手動実行2種、システム内部1種)
  • カスタマイズ可能: すべてのPromptテンプレートは環境変数で言語やドメインに応じてカスタマイズ可能
  • リソース最適化: Follow-Up、Title、Tags、Image Prompt、Query Generation、Autocomplete、MOAは設定でDisable可能。LLM呼び出し量を削減可能

最後に、GMOコネクトではサービス開発支援や技術支援をはじめ、幅広い支援を行っておりますので、何かありましたらお気軽にお問合せください。

お問合せ: https://gmo-connect.jp/contactus/

8
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?