fix: add error handling and fallback values in Parse AI Response node
- Add optional chaining (?.) for safe navigation of response properties - Add fallback values if response fields are missing - Extract vertrauen field directly in Parse node for easier reference - Update Check Confidence node to reference $json.vertrauen instead of nested path - Handles cases where LLM response format is unexpected
This commit is contained in:
@@ -110,13 +110,18 @@
|
||||
"assignments": [
|
||||
{
|
||||
"name": "response_text",
|
||||
"value": "={{ $json.choices[0].message.content }}",
|
||||
"value": "={{ $json.choices?.[0]?.message?.content || '{}' }}",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "ai_response",
|
||||
"value": "={{ JSON.parse($json.response_text) }}",
|
||||
"value": "={{ typeof $json.response_text === 'string' ? JSON.parse($json.response_text) : $json.response_text }}",
|
||||
"type": "object"
|
||||
},
|
||||
{
|
||||
"name": "vertrauen",
|
||||
"value": "={{ $json.ai_response?.vertrauen || 0.5 }}",
|
||||
"type": "number"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -138,7 +143,7 @@
|
||||
"conditions": [
|
||||
{
|
||||
"id": "condition_1",
|
||||
"leftValue": "={{ $json.ai_response.vertrauen }}",
|
||||
"leftValue": "={{ $json.vertrauen }}",
|
||||
"rightValue": 0.6,
|
||||
"operator": {
|
||||
"name": "filter.operator.gte",
|
||||
@@ -183,7 +188,7 @@
|
||||
},
|
||||
{
|
||||
"name": "reason",
|
||||
"value": "Confidence {{$json.ai_response.vertrauen}} < 0.6",
|
||||
"value": "Confidence {{$json.vertrauen}} < 0.6",
|
||||
"type": "string"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user