You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -277,31 +303,15 @@ class ConditionAgent_Agentflow implements INode {
277
303
constmessages: BaseMessageLike[]=[
278
304
{
279
305
role: 'system',
280
-
content: CONDITION_AGENT_SYSTEM_PROMPT
306
+
content: systemPrompt
281
307
},
282
308
{
283
309
role: 'user',
284
-
content: `{"input": "Hello", "scenarios": ["user is asking about AI", "default"], "instruction": "Your task is to check and see if user is asking topic about AI"}`
310
+
content: `{"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."}`
content: `{"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"}`
293
-
},
294
-
{
295
-
role: 'assistant',
296
-
content: `\`\`\`json\n{"output": "user is asking about AI"}\n\`\`\``
297
-
},
298
-
{
299
-
role: 'user',
300
-
content: `{"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"}`
301
-
},
302
-
{
303
-
role: 'assistant',
304
-
content: `\`\`\`json\n{"output": "user is interested in AI topics"}\n\`\`\``
314
+
content: `\`\`\`json\n{"output": "user is not asking about AI"}\n\`\`\``
305
315
}
306
316
]
307
317
// Use to store messages with image file references as we do not want to store the base64 data into database
@@ -374,15 +384,19 @@ class ConditionAgent_Agentflow implements INode {
thrownewError('LLM response is missing the "output" key or it is not a string.')
382
392
}
383
393
calledOutputName=parsedResponse.output
384
394
}catch(error){
385
-
console.warn(`Failed to parse LLM response: ${error}. Using default output.`)
395
+
thrownewError(
396
+
`Failed to parse a valid scenario from the LLM's response. Please check if the model is capable of following JSON output instructions. Raw LLM Response: "${
exportconstCONDITION_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."
43
-
44
-
- **Input**: A string representing the user's query or message.
45
-
- **Scenarios**: A list of predefined scenarios that relate to the input.
46
-
- **Instruction**: Determine if the input fits any of the scenarios.
47
-
48
-
## Steps
49
-
50
-
1. **Read the input string** and the list of scenarios.
51
-
2. **Analyze the content of the input** to identify its main topic or intention.
52
-
3. **Compare the input with each scenario**:
53
-
- If a scenario matches the main topic of the input, select that scenario.
54
-
- If no scenarios match, prepare to output "\`\`\`json\n{"output": "default"}\`\`\`"
55
-
4. **Output the result**: If a match is found, return the corresponding scenario in JSON; otherwise, return "\`\`\`json\n{"output": "default"}\`\`\`"
56
-
57
-
## Output Format
58
-
59
-
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.
60
-
61
-
## Examples
62
-
63
-
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"}
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"}
67
-
**Output**: "\`\`\`json\n{"output": "user is asking about AI"}\`\`\`"
68
-
69
-
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"}
70
-
**Output**: "\`\`\`json\n{"output": "user is interested in AI topics"}\`\`\`"
71
-
72
-
## Note
73
-
- Ensure that the input scenarios align well with potential user queries for accurate matching
74
-
- DO NOT include anything other than the JSON in your response.
42
+
exportconstCONDITION_AGENT_SYSTEM_PROMPT=`
43
+
<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>
44
+
45
+
<ul>
46
+
<li><strong>Input</strong>: A string representing the user's query, message or data.</li>
47
+
<li><strong>Scenarios</strong>: A list of predefined scenarios that relate to the input.</li>
48
+
<li><strong>Instruction</strong>: Determine which of the provided scenarios is the best fit for the input.</li>
49
+
</ul>
50
+
51
+
<h2>Steps</h2>
52
+
<ol>
53
+
<li><strong>Read the input string</strong> and the list of scenarios.</li>
54
+
<li><strong>Analyze the content of the input</strong> to identify its main topic or intention.</li>
55
+
<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>
56
+
<li><strong>Output the result</strong>: Return the selected scenario in the specified JSON format.</li>
57
+
</ol>
58
+
59
+
<h2>Output Format</h2>
60
+
<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>
61
+
62
+
<h2>Examples</h2>
63
+
<ol>
64
+
<li>
65
+
<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>
66
+
<p><strong>Output</strong>: <code>{"output": "user is not asking about AI"}</code></p>
67
+
</li>
68
+
<li>
69
+
<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>
70
+
<p><strong>Output</strong>: <code>{"output": "user is asking about AI"}</code></p>
71
+
</li>
72
+
<li>
73
+
<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>
74
+
<p><strong>Output</strong>: <code>{"output": "user is interested in AI topics"}</code></p>
75
+
</li>
76
+
</ol>
77
+
78
+
<h2>Note</h2>
79
+
<ul>
80
+
<li>Ensure that the input scenarios align well with potential user queries for accurate matching.</li>
81
+
<li>DO NOT include anything other than the JSON in your response.</li>
0 commit comments