Files
crm.clientright.ru/n8n_handle_empty_vector_result.json
Fedor 01c4fe80b5 chore: snapshot current working tree changes
Save all currently accumulated repository changes as a backup snapshot for Gitea so no local work is lost.
2026-03-26 14:19:01 +03:00

113 lines
3.6 KiB
JSON
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
"nodes": [
{
"parameters": {
"mode": "load",
"tableName": "=document_clime_emb",
"prompt": "={{ $json.chatInput }}",
"topK": 1,
"options": {
"metadata": {
"metadataValues": [
{
"name": "problem",
"value": "={{ $('классификатор').item.json.output.problem }}"
}
]
}
}
},
"type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
"typeVersion": 1.3,
"name": "Postgres PGVector Store"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "check_if_empty",
"leftValue": "={{ $json.length }}",
"rightValue": 0,
"operator": {
"type": "number",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"name": "Check if empty result",
"notes": "Проверяет, есть ли результаты векторного поиска"
},
{
"parameters": {
"jsCode": "// Обработка случая, когда векторный поиск не нашел результатов\nconst inputData = $input.all();\n\n// Если массив пустой или все элементы пустые\nif (inputData.length === 0 || inputData.every(item => !item.json || Object.keys(item.json).length === 0)) {\n return [{\n json: {\n error: 'no_results_found',\n message: 'Векторный поиск не нашел похожих документов',\n // Возвращаем исходные данные для продолжения workflow\n originalData: $('Postgres PGVector Store').item?.json || {},\n chatInput: $('классификатор').item?.json?.chatInput || '',\n problem: $('классификатор').item?.json?.output?.problem || '',\n // Можно установить флаг для другой логики\n useFallback: true\n }\n }];\n}\n\n// Если есть результаты - возвращаем как есть\nreturn inputData;"
},
"type": "n8n-nodes-base.code",
"name": "Handle empty result",
"notes": "Обрабатывает пустой результат векторного поиска"
},
{
"parameters": {
"mode": "combine",
"combinationMode": "multiplex",
"options": {}
},
"type": "n8n-nodes-base.merge",
"name": "Merge branches",
"notes": "Объединяет ветки с результатами и без"
}
],
"connections": {
"Postgres PGVector Store": {
"main": [
[
{
"node": "Check if empty result",
"type": "main",
"index": 0
}
]
]
},
"Check if empty result": {
"main": [
[
{
"node": "Handle empty result",
"type": "main",
"index": 0
}
],
[
{
"node": "Merge branches",
"type": "main",
"index": 0
}
]
]
},
"Handle empty result": {
"main": [
[
{
"node": "Merge branches",
"type": "main",
"index": 1
}
]
]
}
}
}