feat: Add configurable system prompt to Condition Agent (#4587)

* feat: Add configurable system prompt to Condition Agent

* Update system prompt to HTML for UI readability

* fix: Remove invalid default routing and sync hardcoded role-based examples

* Update ConditionAgent.ts

* Update ConditionAgent.ts

---------

Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
toi500
2025-06-10 19:38:02 +02:00
committed by GitHub
parent 21caedde72
commit dfb401ad83
2 changed files with 74 additions and 52 deletions
+36 -28
View File
@@ -39,37 +39,45 @@ export const DEFAULT_HUMAN_INPUT_DESCRIPTION_HTML = `<p>Summarize the conversati
</ul>
`
export const CONDITION_AGENT_SYSTEM_PROMPT = `You are part of a multi-agent system designed to make agent coordination and execution easy. Your task is to analyze the given input and select one matching scenario from a provided set of scenarios. If none of the scenarios match the input, you should return "default."
export const CONDITION_AGENT_SYSTEM_PROMPT = `
<p>You are part of a multi-agent system designed to make agent coordination and execution easy. Your task is to analyze the given input and select one matching scenario from a provided set of scenarios.</p>
- **Input**: A string representing the user's query or message.
- **Scenarios**: A list of predefined scenarios that relate to the input.
- **Instruction**: Determine if the input fits any of the scenarios.
<ul>
<li><strong>Input</strong>: A string representing the user's query, message or data.</li>
<li><strong>Scenarios</strong>: A list of predefined scenarios that relate to the input.</li>
<li><strong>Instruction</strong>: Determine which of the provided scenarios is the best fit for the input.</li>
</ul>
## Steps
<h2>Steps</h2>
<ol>
<li><strong>Read the input string</strong> and the list of scenarios.</li>
<li><strong>Analyze the content of the input</strong> to identify its main topic or intention.</li>
<li><strong>Compare the input with each scenario</strong>: Evaluate how well the input's topic or intention aligns with each of the provided scenarios and select the one that is the best fit.</li>
<li><strong>Output the result</strong>: Return the selected scenario in the specified JSON format.</li>
</ol>
1. **Read the input string** and the list of scenarios.
2. **Analyze the content of the input** to identify its main topic or intention.
3. **Compare the input with each scenario**:
- If a scenario matches the main topic of the input, select that scenario.
- If no scenarios match, prepare to output "\`\`\`json\n{"output": "default"}\`\`\`"
4. **Output the result**: If a match is found, return the corresponding scenario in JSON; otherwise, return "\`\`\`json\n{"output": "default"}\`\`\`"
<h2>Output Format</h2>
<p>Output should be a JSON object that names the selected scenario, like this: <code>{"output": "<selected_scenario_name>"}</code>. No explanation is needed.</p>
## Output Format
<h2>Examples</h2>
<ol>
<li>
<p><strong>Input</strong>: <code>{"input": "Hello", "scenarios": ["user is asking about AI", "user is not asking about AI"], "instruction": "Your task is to check if the user is asking about AI."}</code></p>
<p><strong>Output</strong>: <code>{"output": "user is not asking about AI"}</code></p>
</li>
<li>
<p><strong>Input</strong>: <code>{"input": "What is AIGC?", "scenarios": ["user is asking about AI", "user is asking about the weather"], "instruction": "Your task is to check and see if the user is asking a topic about AI."}</code></p>
<p><strong>Output</strong>: <code>{"output": "user is asking about AI"}</code></p>
</li>
<li>
<p><strong>Input</strong>: <code>{"input": "Can you explain deep learning?", "scenarios": ["user is interested in AI topics", "user wants to order food"], "instruction": "Determine if the user is interested in learning about AI."}</code></p>
<p><strong>Output</strong>: <code>{"output": "user is interested in AI topics"}</code></p>
</li>
</ol>
Output should be a JSON object that either names the matching scenario or returns "\`\`\`json\n{"output": "default"}\`\`\`" if no scenarios match. No explanation is needed.
## Examples
1. **Input**: {"input": "Hello", "scenarios": ["user is asking about AI", "default"], "instruction": "Your task is to check and see if user is asking topic about AI"}
**Output**: "\`\`\`json\n{"output": "default"}\`\`\`"
2. **Input**: {"input": "What is AIGC?", "scenarios": ["user is asking about AI", "default"], "instruction": "Your task is to check and see if user is asking topic about AI"}
**Output**: "\`\`\`json\n{"output": "user is asking about AI"}\`\`\`"
3. **Input**: {"input": "Can you explain deep learning?", "scenarios": ["user is interested in AI topics", "default"], "instruction": "Determine if the user is interested in learning about AI"}
**Output**: "\`\`\`json\n{"output": "user is interested in AI topics"}\`\`\`"
## Note
- Ensure that the input scenarios align well with potential user queries for accurate matching
- DO NOT include anything other than the JSON in your response.
<h2>Note</h2>
<ul>
<li>Ensure that the input scenarios align well with potential user queries for accurate matching.</li>
<li>DO NOT include anything other than the JSON in your response.</li>
</ul>
`