Skip to content

OpenRAG is a comprehensive, single package Retrieval-Augmented Generation platform built on Langflow, Docling, and Opensearch.

Python

Fix chat 500s by restoring retrieval Agent schema and fallback guards.

Olfa Maslah53b9c8b70de5
diff --git a/flows/openrag_agent.json b/flows/openrag_agent.json
index 214d991a3..c92243d47 100644
--- a/flows/openrag_agent.json
+++ b/flows/openrag_agent.json
@@ -22,12 +22,12 @@
"type": "other"
}
},
- "id": "xy-edge__MCP-7EY21{œdataTypeœ:œMCPœ,œidœ:œMCP-7EY21œ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-Nfw7u{œfieldNameœ:œtoolsœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}",
+ "id": "xy-edge__MCP-7EY21{\u0153dataType\u0153:\u0153MCP\u0153,\u0153id\u0153:\u0153MCP-7EY21\u0153,\u0153name\u0153:\u0153component_as_tool\u0153,\u0153output_types\u0153:[\u0153Tool\u0153]}-Agent-Nfw7u{\u0153fieldName\u0153:\u0153tools\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Tool\u0153],\u0153type\u0153:\u0153other\u0153}",
"selected": false,
"source": "MCP-7EY21",
- "sourceHandle": "{œdataTypeœ:œMCPœ,œidœ:œMCP-7EY21œ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153MCP\u0153,\u0153id\u0153:\u0153MCP-7EY21\u0153,\u0153name\u0153:\u0153component_as_tool\u0153,\u0153output_types\u0153:[\u0153Tool\u0153]}",
"target": "Agent-Nfw7u",
- "targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153tools\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Tool\u0153],\u0153type\u0153:\u0153other\u0153}"
},
{
"animated": false,
@@ -52,12 +52,12 @@
"type": "other"
}
},
- "id": "xy-edge__Agent-Nfw7u{œdataTypeœ:œAgentœ,œidœ:œAgent-Nfw7uœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}-ChatOutput-gWl8E{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-gWl8Eœ,œinputTypesœ:[œDataœ,œDataFrameœ,œMessageœ],œtypeœ:œotherœ}",
+ "id": "xy-edge__Agent-Nfw7u{\u0153dataType\u0153:\u0153Agent\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153name\u0153:\u0153response\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-ChatOutput-gWl8E{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153ChatOutput-gWl8E\u0153,\u0153inputTypes\u0153:[\u0153Data\u0153,\u0153DataFrame\u0153,\u0153Message\u0153],\u0153type\u0153:\u0153other\u0153}",
"selected": false,
"source": "Agent-Nfw7u",
- "sourceHandle": "{œdataTypeœ:œAgentœ,œidœ:œAgent-Nfw7uœ,œnameœ:œresponseœ,œoutput_typesœ:[œMessageœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153Agent\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153name\u0153:\u0153response\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}",
"target": "ChatOutput-gWl8E",
- "targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œChatOutput-gWl8Eœ,œinputTypesœ:[œDataœ,œDataFrameœ,œMessageœ],œtypeœ:œotherœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153ChatOutput-gWl8E\u0153,\u0153inputTypes\u0153:[\u0153Data\u0153,\u0153DataFrame\u0153,\u0153Message\u0153],\u0153type\u0153:\u0153other\u0153}"
},
{
"animated": false,
@@ -80,12 +80,12 @@
"type": "other"
}
},
- "id": "xy-edge__CalculatorComponent-KrlMH{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-KrlMHœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-Nfw7u{œfieldNameœ:œtoolsœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}",
+ "id": "xy-edge__CalculatorComponent-KrlMH{\u0153dataType\u0153:\u0153CalculatorComponent\u0153,\u0153id\u0153:\u0153CalculatorComponent-KrlMH\u0153,\u0153name\u0153:\u0153component_as_tool\u0153,\u0153output_types\u0153:[\u0153Tool\u0153]}-Agent-Nfw7u{\u0153fieldName\u0153:\u0153tools\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Tool\u0153],\u0153type\u0153:\u0153other\u0153}",
"selected": false,
"source": "CalculatorComponent-KrlMH",
- "sourceHandle": "{œdataTypeœ:œCalculatorComponentœ,œidœ:œCalculatorComponent-KrlMHœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153CalculatorComponent\u0153,\u0153id\u0153:\u0153CalculatorComponent-KrlMH\u0153,\u0153name\u0153:\u0153component_as_tool\u0153,\u0153output_types\u0153:[\u0153Tool\u0153]}",
"target": "Agent-Nfw7u",
- "targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153tools\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Tool\u0153],\u0153type\u0153:\u0153other\u0153}"
},
{
"animated": false,
@@ -108,12 +108,12 @@
"type": "other"
}
},
- "id": "xy-edge__EmbeddingModel-zLHKs{œdataTypeœ:œEmbeddingModelœ,œidœ:œEmbeddingModel-zLHKsœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{œfieldNameœ:œembeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}",
+ "id": "xy-edge__EmbeddingModel-zLHKs{\u0153dataType\u0153:\u0153EmbeddingModel\u0153,\u0153id\u0153:\u0153EmbeddingModel-zLHKs\u0153,\u0153name\u0153:\u0153embeddings\u0153,\u0153output_types\u0153:[\u0153Embeddings\u0153]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{\u0153fieldName\u0153:\u0153embedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Embeddings\u0153],\u0153type\u0153:\u0153other\u0153}",
"selected": false,
"source": "EmbeddingModel-zLHKs",
- "sourceHandle": "{œdataTypeœ:œEmbeddingModelœ,œidœ:œEmbeddingModel-zLHKsœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153EmbeddingModel\u0153,\u0153id\u0153:\u0153EmbeddingModel-zLHKs\u0153,\u0153name\u0153:\u0153embeddings\u0153,\u0153output_types\u0153:[\u0153Embeddings\u0153]}",
"target": "OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE",
- "targetHandle": "{œfieldNameœ:œembeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153embedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Embeddings\u0153],\u0153type\u0153:\u0153other\u0153}"
},
{
"animated": false,
@@ -136,12 +136,12 @@
"type": "other"
}
},
- "id": "xy-edge__EmbeddingModel-J6YgA{œdataTypeœ:œEmbeddingModelœ,œidœ:œEmbeddingModel-J6YgAœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{œfieldNameœ:œembeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}",
+ "id": "xy-edge__EmbeddingModel-J6YgA{\u0153dataType\u0153:\u0153EmbeddingModel\u0153,\u0153id\u0153:\u0153EmbeddingModel-J6YgA\u0153,\u0153name\u0153:\u0153embeddings\u0153,\u0153output_types\u0153:[\u0153Embeddings\u0153]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{\u0153fieldName\u0153:\u0153embedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Embeddings\u0153],\u0153type\u0153:\u0153other\u0153}",
"selected": false,
"source": "EmbeddingModel-J6YgA",
- "sourceHandle": "{œdataTypeœ:œEmbeddingModelœ,œidœ:œEmbeddingModel-J6YgAœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153EmbeddingModel\u0153,\u0153id\u0153:\u0153EmbeddingModel-J6YgA\u0153,\u0153name\u0153:\u0153embeddings\u0153,\u0153output_types\u0153:[\u0153Embeddings\u0153]}",
"target": "OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE",
- "targetHandle": "{œfieldNameœ:œembeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153embedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Embeddings\u0153],\u0153type\u0153:\u0153other\u0153}"
},
{
"animated": false,
@@ -164,12 +164,12 @@
"type": "other"
}
},
- "id": "xy-edge__EmbeddingModel-aIP4U{œdataTypeœ:œEmbeddingModelœ,œidœ:œEmbeddingModel-aIP4Uœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{œfieldNameœ:œembeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}",
+ "id": "xy-edge__EmbeddingModel-aIP4U{\u0153dataType\u0153:\u0153EmbeddingModel\u0153,\u0153id\u0153:\u0153EmbeddingModel-aIP4U\u0153,\u0153name\u0153:\u0153embeddings\u0153,\u0153output_types\u0153:[\u0153Embeddings\u0153]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{\u0153fieldName\u0153:\u0153embedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Embeddings\u0153],\u0153type\u0153:\u0153other\u0153}",
"selected": false,
"source": "EmbeddingModel-aIP4U",
- "sourceHandle": "{œdataTypeœ:œEmbeddingModelœ,œidœ:œEmbeddingModel-aIP4Uœ,œnameœ:œembeddingsœ,œoutput_typesœ:[œEmbeddingsœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153EmbeddingModel\u0153,\u0153id\u0153:\u0153EmbeddingModel-aIP4U\u0153,\u0153name\u0153:\u0153embeddings\u0153,\u0153output_types\u0153:[\u0153Embeddings\u0153]}",
"target": "OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE",
- "targetHandle": "{œfieldNameœ:œembeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œEmbeddingsœ],œtypeœ:œotherœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153embedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Embeddings\u0153],\u0153type\u0153:\u0153other\u0153}"
},
{
"animated": false,
@@ -192,12 +192,12 @@
"type": "str"
}
},
- "id": "xy-edge__TextInput-aHsQb{œdataTypeœ:œTextInputœ,œidœ:œTextInput-aHsQbœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{œfieldNameœ:œfilter_expressionœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
+ "id": "xy-edge__TextInput-aHsQb{\u0153dataType\u0153:\u0153TextInput\u0153,\u0153id\u0153:\u0153TextInput-aHsQb\u0153,\u0153name\u0153:\u0153text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{\u0153fieldName\u0153:\u0153filter_expression\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
"selected": false,
"source": "TextInput-aHsQb",
- "sourceHandle": "{œdataTypeœ:œTextInputœ,œidœ:œTextInput-aHsQbœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153TextInput\u0153,\u0153id\u0153:\u0153TextInput-aHsQb\u0153,\u0153name\u0153:\u0153text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}",
"target": "OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE",
- "targetHandle": "{œfieldNameœ:œfilter_expressionœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153filter_expression\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}"
},
{
"animated": false,
@@ -220,12 +220,12 @@
"type": "str"
}
},
- "id": "xy-edge__ChatInput-ci8VE{œdataTypeœ:œChatInputœ,œidœ:œChatInput-ci8VEœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}-Prompt Template-7kZsI{œfieldNameœ:œinputœ,œidœ:œPrompt Template-7kZsIœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
+ "id": "xy-edge__ChatInput-ci8VE{\u0153dataType\u0153:\u0153ChatInput\u0153,\u0153id\u0153:\u0153ChatInput-ci8VE\u0153,\u0153name\u0153:\u0153message\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-Prompt Template-7kZsI{\u0153fieldName\u0153:\u0153input\u0153,\u0153id\u0153:\u0153Prompt Template-7kZsI\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
"selected": false,
"source": "ChatInput-ci8VE",
- "sourceHandle": "{œdataTypeœ:œChatInputœ,œidœ:œChatInput-ci8VEœ,œnameœ:œmessageœ,œoutput_typesœ:[œMessageœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153ChatInput\u0153,\u0153id\u0153:\u0153ChatInput-ci8VE\u0153,\u0153name\u0153:\u0153message\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}",
"target": "Prompt Template-7kZsI",
- "targetHandle": "{œfieldNameœ:œinputœ,œidœ:œPrompt Template-7kZsIœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153input\u0153,\u0153id\u0153:\u0153Prompt Template-7kZsI\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}"
},
{
"animated": false,
@@ -248,12 +248,12 @@
"type": "str"
}
},
- "id": "xy-edge__Prompt Template-7kZsI{œdataTypeœ:œPrompt Templateœ,œidœ:œPrompt Template-7kZsIœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}-Agent-Nfw7u{œfieldNameœ:œinput_valueœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
+ "id": "xy-edge__Prompt Template-7kZsI{\u0153dataType\u0153:\u0153Prompt Template\u0153,\u0153id\u0153:\u0153Prompt Template-7kZsI\u0153,\u0153name\u0153:\u0153prompt\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-Agent-Nfw7u{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
"selected": false,
"source": "Prompt Template-7kZsI",
- "sourceHandle": "{œdataTypeœ:œPrompt Templateœ,œidœ:œPrompt Template-7kZsIœ,œnameœ:œpromptœ,œoutput_typesœ:[œMessageœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153Prompt Template\u0153,\u0153id\u0153:\u0153Prompt Template-7kZsI\u0153,\u0153name\u0153:\u0153prompt\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}",
"target": "Agent-Nfw7u",
- "targetHandle": "{œfieldNameœ:œinput_valueœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153input_value\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}"
},
{
"animated": false,
@@ -276,12 +276,12 @@
"type": "str"
}
},
- "id": "xy-edge__TextInput-aHsQb{œdataTypeœ:œTextInputœ,œidœ:œTextInput-aHsQbœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}-Prompt Template-7kZsI{œfieldNameœ:œfilterœ,œidœ:œPrompt Template-7kZsIœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}",
+ "id": "xy-edge__TextInput-aHsQb{\u0153dataType\u0153:\u0153TextInput\u0153,\u0153id\u0153:\u0153TextInput-aHsQb\u0153,\u0153name\u0153:\u0153text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}-Prompt Template-7kZsI{\u0153fieldName\u0153:\u0153filter\u0153,\u0153id\u0153:\u0153Prompt Template-7kZsI\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}",
"selected": false,
"source": "TextInput-aHsQb",
- "sourceHandle": "{œdataTypeœ:œTextInputœ,œidœ:œTextInput-aHsQbœ,œnameœ:œtextœ,œoutput_typesœ:[œMessageœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153TextInput\u0153,\u0153id\u0153:\u0153TextInput-aHsQb\u0153,\u0153name\u0153:\u0153text\u0153,\u0153output_types\u0153:[\u0153Message\u0153]}",
"target": "Prompt Template-7kZsI",
- "targetHandle": "{œfieldNameœ:œfilterœ,œidœ:œPrompt Template-7kZsIœ,œinputTypesœ:[œMessageœ],œtypeœ:œstrœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153filter\u0153,\u0153id\u0153:\u0153Prompt Template-7kZsI\u0153,\u0153inputTypes\u0153:[\u0153Message\u0153],\u0153type\u0153:\u0153str\u0153}"
},
{
"animated": false,
@@ -304,12 +304,12 @@
"type": "other"
}
},
- "id": "xy-edge__OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{œdataTypeœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}-Agent-Nfw7u{œfieldNameœ:œtoolsœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}",
+ "id": "xy-edge__OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE{\u0153dataType\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153name\u0153:\u0153component_as_tool\u0153,\u0153output_types\u0153:[\u0153Tool\u0153]}-Agent-Nfw7u{\u0153fieldName\u0153:\u0153tools\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Tool\u0153],\u0153type\u0153:\u0153other\u0153}",
"selected": false,
"source": "OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE",
- "sourceHandle": "{œdataTypeœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbeddingœ,œidœ:œOpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvEœ,œnameœ:œcomponent_as_toolœ,œoutput_typesœ:[œToolœ]}",
+ "sourceHandle": "{\u0153dataType\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding\u0153,\u0153id\u0153:\u0153OpenSearchVectorStoreComponentMultimodalMultiEmbedding-TyvvE\u0153,\u0153name\u0153:\u0153component_as_tool\u0153,\u0153output_types\u0153:[\u0153Tool\u0153]}",
"target": "Agent-Nfw7u",
- "targetHandle": "{œfieldNameœ:œtoolsœ,œidœ:œAgent-Nfw7uœ,œinputTypesœ:[œToolœ],œtypeœ:œotherœ}"
+ "targetHandle": "{\u0153fieldName\u0153:\u0153tools\u0153,\u0153id\u0153:\u0153Agent-Nfw7u\u0153,\u0153inputTypes\u0153:[\u0153Tool\u0153],\u0153type\u0153:\u0153other\u0153}"
}
],
"nodes": [
@@ -1293,6 +1293,8 @@
},
{
"data": {
+ "description": "Define the agent's instructions, then enter a task to complete using tools.",
+ "display_name": "Agent",
"id": "Agent-Nfw7u",
"node": {
"base_classes": [
@@ -1306,23 +1308,14 @@
"documentation": "https://docs.langflow.org/agents",
"edited": false,
"field_order": [
- "agent_llm",
+ "model",
"api_key",
- "base_url",
+ "base_url_ibm_watsonx",
"project_id",
- "max_output_tokens",
- "max_tokens",
- "model_kwargs",
- "model_name",
- "openai_api_base",
- "api_key",
- "temperature",
- "seed",
- "max_retries",
- "timeout",
"system_prompt",
"context_id",
"n_messages",
+ "max_tokens",
"format_instructions",
"output_schema",
"tools",
@@ -1335,23 +1328,23 @@
],
"frozen": false,
"icon": "bot",
- "last_updated": "2025-12-02T21:33:13.268Z",
+ "last_updated": "2026-03-06T16:29:04.384Z",
"legacy": false,
"metadata": {
- "code_hash": "d64b11c24a1c",
+ "code_hash": "108da32d83f1",
"dependencies": {
"dependencies": [
- {
- "name": "langchain_core",
- "version": "0.3.79"
- },
{
"name": "pydantic",
- "version": "2.10.6"
+ "version": "2.11.10"
},
{
"name": "lfx",
- "version": "0.2.0.dev19"
+ "version": "0.3.0"
+ },
+ {
+ "name": "langchain_core",
+ "version": "0.3.83"
}
],
"total_dependencies": 3
@@ -1366,6 +1359,7 @@
"cache": true,
"display_name": "Response",
"group_outputs": false,
+ "hidden": null,
"loop_types": null,
"method": "message_response",
"name": "response",
@@ -1382,10 +1376,12 @@
"pinned": false,
"template": {
"_frontend_node_flow_id": {
+ "input_types": [],
"value": "1098eea1-6649-4e1d-aed1-b77249fb8dd0"
},
"_frontend_node_folder_id": {
- "value": "69a7745e-dfb8-40a7-b5cb-5da3af0b10b6"
+ "input_types": [],
+ "value": "c2b04832-8cbf-473b-afd0-014e4e86b84b"
},
"_type": "Component",
"add_current_date_tool": {
@@ -1398,6 +1394,7 @@
"list": false,
"list_add_label": "Add More",
"name": "add_current_date_tool",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1411,6 +1408,7 @@
"agent_description": {
"_input_type": "MultilineInput",
"advanced": true,
+ "ai_enabled": false,
"copy_field": false,
"display_name": "Agent Description [Deprecated]",
"dynamic": false,
@@ -1423,6 +1421,8 @@
"load_from_db": false,
"multiline": true,
"name": "agent_description",
+ "override_skip": false,
+ "password": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1434,86 +1434,58 @@
"type": "str",
"value": "A helpful assistant with access to the following tools:"
},
- "agent_llm": {
- "_input_type": "DropdownInput",
- "advanced": false,
- "combobox": false,
- "dialog_inputs": {},
- "display_name": "Model Provider",
+ "api_key": {
+ "_input_type": "SecretStrInput",
+ "advanced": true,
+ "display_name": "API Key",
"dynamic": false,
- "external_options": {
- "fields": {
- "data": {
- "node": {
- "display_name": "Connect other models",
- "icon": "CornerDownLeft",
- "name": "connect_other_models"
- }
- }
- }
- },
- "info": "The provider of the language model that the agent will use to generate responses.",
+ "info": "Falls back to OPENAI_API_KEY environment variable",
"input_types": [],
- "name": "agent_llm",
- "options": [
- "Anthropic",
- "Google Generative AI",
- "OpenAI",
- "IBM watsonx.ai",
- "Ollama"
- ],
- "options_metadata": [
- {
- "icon": "Anthropic"
- },
- {
- "icon": "GoogleGenerativeAI"
- },
- {
- "icon": "OpenAI"
- },
- {
- "icon": "WatsonxAI"
- },
- {
- "icon": "Ollama"
- }
- ],
+ "load_from_db": false,
+ "name": "api_key",
+ "override_skip": false,
+ "password": true,
"placeholder": "",
"real_time_refresh": true,
- "refresh_button": false,
"required": false,
- "selected_metadata": {
- "icon": "OpenAI"
- },
"show": true,
"title_case": false,
- "toggle": false,
- "tool_mode": false,
- "trace_as_metadata": true,
- "track_in_telemetry": true,
+ "track_in_telemetry": false,
"type": "str",
- "value": "OpenAI"
+ "value": ""
},
- "api_key": {
- "_input_type": "SecretStrInput",
+ "base_url_ibm_watsonx": {
+ "_input_type": "DropdownInput",
"advanced": false,
- "display_name": "OpenAI API Key",
+ "combobox": false,
+ "dialog_inputs": {},
+ "display_name": "watsonx API Endpoint",
"dynamic": false,
- "info": "The OpenAI API Key to use for the OpenAI model.",
+ "external_options": {},
+ "info": "The base URL of the API (IBM watsonx.ai only)",
"input_types": [],
- "load_from_db": true,
- "name": "api_key",
+ "name": "base_url_ibm_watsonx",
+ "options": [
+ "https://us-south.ml.cloud.ibm.com",
+ "https://eu-de.ml.cloud.ibm.com",
+ "https://eu-gb.ml.cloud.ibm.com",
+ "https://au-syd.ml.cloud.ibm.com",
+ "https://jp-tok.ml.cloud.ibm.com",
+ "https://ca-tor.ml.cloud.ibm.com"
+ ],
+ "options_metadata": [],
"override_skip": false,
- "password": true,
"placeholder": "",
"real_time_refresh": true,
"required": false,
- "show": true,
+ "show": false,
"title_case": false,
- "track_in_telemetry": false,
+ "toggle": false,
+ "tool_mode": false,
+ "trace_as_metadata": true,
+ "track_in_telemetry": true,
"type": "str",
- "value": "OPENAI_API_KEY"
+ "value": "https://us-south.ml.cloud.ibm.com"
},
"code": {
"advanced": true,
@@ -1532,7 +1504,7 @@
"show": true,
"title_case": false,
"type": "code",
- "value": "import json\nimport re\n\nfrom langchain_core.tools import StructuredTool, Tool\nfrom pydantic import ValidationError\n\nfrom lfx.base.agents.agent import LCToolsAgentComponent\nfrom lfx.base.agents.events import ExceptionWithMessageError\nfrom lfx.base.models.model_input_constants import (\n ALL_PROVIDER_FIELDS,\n MODEL_DYNAMIC_UPDATE_FIELDS,\n MODEL_PROVIDERS_DICT,\n MODEL_PROVIDERS_LIST,\n MODELS_METADATA,\n)\nfrom lfx.base.models.model_utils import get_model_name\nfrom lfx.components.helpers import CurrentDateComponent\nfrom lfx.components.langchain_utilities.tool_calling import ToolCallingAgentComponent\nfrom lfx.components.models_and_agents.memory import MemoryComponent\nfrom lfx.custom.custom_component.component import get_component_toolkit\nfrom lfx.custom.utils import update_component_build_config\nfrom lfx.helpers.base_model import build_model_from_schema\nfrom lfx.inputs.inputs import BoolInput, SecretStrInput, StrInput\nfrom lfx.io import DropdownInput, IntInput, MessageTextInput, MultilineInput, Output, TableInput\nfrom lfx.log.logger import logger\nfrom lfx.schema.data import Data\nfrom lfx.schema.dotdict import dotdict\nfrom lfx.schema.message import Message\nfrom lfx.schema.table import EditMode\n\n\ndef set_advanced_true(component_input):\n component_input.advanced = True\n return component_input\n\n\nclass AgentComponent(ToolCallingAgentComponent):\n display_name: str = \"Agent\"\n description: str = \"Define the agent's instructions, then enter a task to complete using tools.\"\n documentation: str = \"https://docs.langflow.org/agents\"\n icon = \"bot\"\n beta = False\n name = \"Agent\"\n\n memory_inputs = [set_advanced_true(component_input) for component_input in MemoryComponent().inputs]\n\n # Filter out json_mode from OpenAI inputs since we handle structured output differently\n if \"OpenAI\" in MODEL_PROVIDERS_DICT:\n openai_inputs_filtered = [\n input_field\n for input_field in MODEL_PROVIDERS_DICT[\"OpenAI\"][\"inputs\"]\n if not (hasattr(input_field, \"name\") and input_field.name == \"json_mode\")\n ]\n else:\n openai_inputs_filtered = []\n\n inputs = [\n DropdownInput(\n name=\"agent_llm\",\n display_name=\"Model Provider\",\n info=\"The provider of the language model that the agent will use to generate responses.\",\n options=[*MODEL_PROVIDERS_LIST],\n value=\"OpenAI\",\n real_time_refresh=True,\n refresh_button=False,\n input_types=[],\n options_metadata=[MODELS_METADATA[key] for key in MODEL_PROVIDERS_LIST if key in MODELS_METADATA],\n external_options={\n \"fields\": {\n \"data\": {\n \"node\": {\n \"name\": \"connect_other_models\",\n \"display_name\": \"Connect other models\",\n \"icon\": \"CornerDownLeft\",\n }\n }\n },\n },\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"API Key\",\n info=\"The API key to use for the model.\",\n required=True,\n ),\n StrInput(\n name=\"base_url\",\n display_name=\"Base URL\",\n info=\"The base URL of the API.\",\n required=True,\n show=False,\n ),\n StrInput(\n name=\"project_id\",\n display_name=\"Project ID\",\n info=\"The project ID of the model.\",\n required=True,\n show=False,\n ),\n IntInput(\n name=\"max_output_tokens\",\n display_name=\"Max Output Tokens\",\n info=\"The maximum number of tokens to generate.\",\n show=False,\n ),\n *openai_inputs_filtered,\n MultilineInput(\n name=\"system_prompt\",\n display_name=\"Agent Instructions\",\n info=\"System Prompt: Initial instructions and context provided to guide the agent's behavior.\",\n value=\"You are a helpful assistant that can use tools to answer questions and perform tasks.\",\n advanced=False,\n ),\n MessageTextInput(\n name=\"context_id\",\n display_name=\"Context ID\",\n info=\"The context ID of the chat. Adds an extra layer to the local memory.\",\n value=\"\",\n advanced=True,\n ),\n IntInput(\n name=\"n_messages\",\n display_name=\"Number of Chat History Messages\",\n value=100,\n info=\"Number of chat history messages to retrieve.\",\n advanced=True,\n show=True,\n ),\n MultilineInput(\n name=\"format_instructions\",\n display_name=\"Output Format Instructions\",\n info=\"Generic Template for structured output formatting. Valid only with Structured response.\",\n value=(\n \"You are an AI that extracts structured JSON objects from unstructured text. \"\n \"Use a predefined schema with expected types (str, int, float, bool, dict). \"\n \"Extract ALL relevant instances that match the schema - if multiple patterns exist, capture them all. \"\n \"Fill missing or ambiguous values with defaults: null for missing values. \"\n \"Remove exact duplicates but keep variations that have different field values. \"\n \"Always return valid JSON in the expected format, never throw errors. \"\n \"If multiple objects can be extracted, return them all in the structured format.\"\n ),\n advanced=True,\n ),\n TableInput(\n name=\"output_schema\",\n display_name=\"Output Schema\",\n info=(\n \"Schema Validation: Define the structure and data types for structured output. \"\n \"No validation if no output schema.\"\n ),\n advanced=True,\n required=False,\n value=[],\n table_schema=[\n {\n \"name\": \"name\",\n \"display_name\": \"Name\",\n \"type\": \"str\",\n \"description\": \"Specify the name of the output field.\",\n \"default\": \"field\",\n \"edit_mode\": EditMode.INLINE,\n },\n {\n \"name\": \"description\",\n \"display_name\": \"Description\",\n \"type\": \"str\",\n \"description\": \"Describe the purpose of the output field.\",\n \"default\": \"description of field\",\n \"edit_mode\": EditMode.POPOVER,\n },\n {\n \"name\": \"type\",\n \"display_name\": \"Type\",\n \"type\": \"str\",\n \"edit_mode\": EditMode.INLINE,\n \"description\": (\"Indicate the data type of the output field (e.g., str, int, float, bool, dict).\"),\n \"options\": [\"str\", \"int\", \"float\", \"bool\", \"dict\"],\n \"default\": \"str\",\n },\n {\n \"name\": \"multiple\",\n \"display_name\": \"As List\",\n \"type\": \"boolean\",\n \"description\": \"Set to True if this output field should be a list of the specified type.\",\n \"default\": \"False\",\n \"edit_mode\": EditMode.INLINE,\n },\n ],\n ),\n *LCToolsAgentComponent.get_base_inputs(),\n # removed memory inputs from agent component\n # *memory_inputs,\n BoolInput(\n name=\"add_current_date_tool\",\n display_name=\"Current Date\",\n advanced=True,\n info=\"If true, will add a tool to the agent that returns the current date.\",\n value=True,\n ),\n ]\n outputs = [\n Output(name=\"response\", display_name=\"Response\", method=\"message_response\"),\n ]\n\n async def get_agent_requirements(self):\n \"\"\"Get the agent requirements for the agent.\"\"\"\n llm_model, display_name = await self.get_llm()\n if llm_model is None:\n msg = \"No language model selected. Please choose a model to proceed.\"\n raise ValueError(msg)\n self.model_name = get_model_name(llm_model, display_name=display_name)\n\n # Get memory data\n self.chat_history = await self.get_memory_data()\n await logger.adebug(f\"Retrieved {len(self.chat_history)} chat history messages\")\n if isinstance(self.chat_history, Message):\n self.chat_history = [self.chat_history]\n\n # Add current date tool if enabled\n if self.add_current_date_tool:\n if not isinstance(self.tools, list): # type: ignore[has-type]\n self.tools = []\n current_date_tool = (await CurrentDateComponent(**self.get_base_args()).to_toolkit()).pop(0)\n\n if not isinstance(current_date_tool, StructuredTool):\n msg = \"CurrentDateComponent must be converted to a StructuredTool\"\n raise TypeError(msg)\n self.tools.append(current_date_tool)\n\n # Set shared callbacks for tracing the tools used by the agent\n self.set_tools_callbacks(self.tools, self._get_shared_callbacks())\n\n return llm_model, self.chat_history, self.tools\n\n async def message_response(self) -> Message:\n try:\n llm_model, self.chat_history, self.tools = await self.get_agent_requirements()\n # Set up and run agent\n self.set(\n llm=llm_model,\n tools=self.tools or [],\n chat_history=self.chat_history,\n input_value=self.input_value,\n system_prompt=self.system_prompt,\n )\n agent = self.create_agent_runnable()\n result = await self.run_agent(agent)\n\n # Store result for potential JSON output\n self._agent_result = result\n\n except (ValueError, TypeError, KeyError) as e:\n await logger.aerror(f\"{type(e).__name__}: {e!s}\")\n raise\n except ExceptionWithMessageError as e:\n await logger.aerror(f\"ExceptionWithMessageError occurred: {e}\")\n raise\n # Avoid catching blind Exception; let truly unexpected exceptions propagate\n except Exception as e:\n await logger.aerror(f\"Unexpected error: {e!s}\")\n raise\n else:\n return result\n\n def _preprocess_schema(self, schema):\n \"\"\"Preprocess schema to ensure correct data types for build_model_from_schema.\"\"\"\n processed_schema = []\n for field in schema:\n processed_field = {\n \"name\": str(field.get(\"name\", \"field\")),\n \"type\": str(field.get(\"type\", \"str\")),\n \"description\": str(field.get(\"description\", \"\")),\n \"multiple\": field.get(\"multiple\", False),\n }\n # Ensure multiple is handled correctly\n if isinstance(processed_field[\"multiple\"], str):\n processed_field[\"multiple\"] = processed_field[\"multiple\"].lower() in [\n \"true\",\n \"1\",\n \"t\",\n \"y\",\n \"yes\",\n ]\n processed_schema.append(processed_field)\n return processed_schema\n\n async def build_structured_output_base(self, content: str):\n \"\"\"Build structured output with optional BaseModel validation.\"\"\"\n json_pattern = r\"\\{.*\\}\"\n schema_error_msg = \"Try setting an output schema\"\n\n # Try to parse content as JSON first\n json_data = None\n try:\n json_data = json.loads(content)\n except json.JSONDecodeError:\n json_match = re.search(json_pattern, content, re.DOTALL)\n if json_match:\n try:\n json_data = json.loads(json_match.group())\n except json.JSONDecodeError:\n return {\"content\": content, \"error\": schema_error_msg}\n else:\n return {\"content\": content, \"error\": schema_error_msg}\n\n # If no output schema provided, return parsed JSON without validation\n if not hasattr(self, \"output_schema\") or not self.output_schema or len(self.output_schema) == 0:\n return json_data\n\n # Use BaseModel validation with schema\n try:\n processed_schema = self._preprocess_schema(self.output_schema)\n output_model = build_model_from_schema(processed_schema)\n\n # Validate against the schema\n if isinstance(json_data, list):\n # Multiple objects\n validated_objects = []\n for item in json_data:\n try:\n validated_obj = output_model.model_validate(item)\n validated_objects.append(validated_obj.model_dump())\n except ValidationError as e:\n await logger.aerror(f\"Validation error for item: {e}\")\n # Include invalid items with error info\n validated_objects.append({\"data\": item, \"validation_error\": str(e)})\n return validated_objects\n\n # Single object\n try:\n validated_obj = output_model.model_validate(json_data)\n return [validated_obj.model_dump()] # Return as list for consistency\n except ValidationError as e:\n await logger.aerror(f\"Validation error: {e}\")\n return [{\"data\": json_data, \"validation_error\": str(e)}]\n\n except (TypeError, ValueError) as e:\n await logger.aerror(f\"Error building structured output: {e}\")\n # Fallback to parsed JSON without validation\n return json_data\n\n async def json_response(self) -> Data:\n \"\"\"Convert agent response to structured JSON Data output with schema validation.\"\"\"\n # Always use structured chat agent for JSON response mode for better JSON formatting\n try:\n system_components = []\n\n # 1. Agent Instructions (system_prompt)\n agent_instructions = getattr(self, \"system_prompt\", \"\") or \"\"\n if agent_instructions:\n system_components.append(f\"{agent_instructions}\")\n\n # 2. Format Instructions\n format_instructions = getattr(self, \"format_instructions\", \"\") or \"\"\n if format_instructions:\n system_components.append(f\"Format instructions: {format_instructions}\")\n\n # 3. Schema Information from BaseModel\n if hasattr(self, \"output_schema\") and self.output_schema and len(self.output_schema) > 0:\n try:\n processed_schema = self._preprocess_schema(self.output_schema)\n output_model = build_model_from_schema(processed_schema)\n schema_dict = output_model.model_json_schema()\n schema_info = (\n \"You are given some text that may include format instructions, \"\n \"explanations, or other content alongside a JSON schema.\\n\\n\"\n \"Your task:\\n\"\n \"- Extract only the JSON schema.\\n\"\n \"- Return it as valid JSON.\\n\"\n \"- Do not include format instructions, explanations, or extra text.\\n\\n\"\n \"Input:\\n\"\n f\"{json.dumps(schema_dict, indent=2)}\\n\\n\"\n \"Output (only JSON schema):\"\n )\n system_components.append(schema_info)\n except (ValidationError, ValueError, TypeError, KeyError) as e:\n await logger.aerror(f\"Could not build schema for prompt: {e}\", exc_info=True)\n\n # Combine all components\n combined_instructions = \"\\n\\n\".join(system_components) if system_components else \"\"\n llm_model, self.chat_history, self.tools = await self.get_agent_requirements()\n self.set(\n llm=llm_model,\n tools=self.tools or [],\n chat_history=self.chat_history,\n input_value=self.input_value,\n system_prompt=combined_instructions,\n )\n\n # Create and run structured chat agent\n try:\n structured_agent = self.create_agent_runnable()\n except (NotImplementedError, ValueError, TypeError) as e:\n await logger.aerror(f\"Error with structured chat agent: {e}\")\n raise\n try:\n result = await self.run_agent(structured_agent)\n except (\n ExceptionWithMessageError,\n ValueError,\n TypeError,\n RuntimeError,\n ) as e:\n await logger.aerror(f\"Error with structured agent result: {e}\")\n raise\n # Extract content from structured agent result\n if hasattr(result, \"content\"):\n content = result.content\n elif hasattr(result, \"text\"):\n content = result.text\n else:\n content = str(result)\n\n except (\n ExceptionWithMessageError,\n ValueError,\n TypeError,\n NotImplementedError,\n AttributeError,\n ) as e:\n await logger.aerror(f\"Error with structured chat agent: {e}\")\n # Fallback to regular agent\n content_str = \"No content returned from agent\"\n return Data(data={\"content\": content_str, \"error\": str(e)})\n\n # Process with structured output validation\n try:\n structured_output = await self.build_structured_output_base(content)\n\n # Handle different output formats\n if isinstance(structured_output, list) and structured_output:\n if len(structured_output) == 1:\n return Data(data=structured_output[0])\n return Data(data={\"results\": structured_output})\n if isinstance(structured_output, dict):\n return Data(data=structured_output)\n return Data(data={\"content\": content})\n\n except (ValueError, TypeError) as e:\n await logger.aerror(f\"Error in structured output processing: {e}\")\n return Data(data={\"content\": content, \"error\": str(e)})\n\n async def get_memory_data(self):\n # TODO: This is a temporary fix to avoid message duplication. We should develop a function for this.\n messages = (\n await MemoryComponent(**self.get_base_args())\n .set(\n session_id=self.graph.session_id,\n context_id=self.context_id,\n order=\"Ascending\",\n n_messages=self.n_messages,\n )\n .retrieve_messages()\n )\n return [\n message for message in messages if getattr(message, \"id\", None) != getattr(self.input_value, \"id\", None)\n ]\n\n async def get_llm(self):\n if not isinstance(self.agent_llm, str):\n return self.agent_llm, None\n\n try:\n provider_info = MODEL_PROVIDERS_DICT.get(self.agent_llm)\n if not provider_info:\n msg = f\"Invalid model provider: {self.agent_llm}\"\n raise ValueError(msg)\n\n component_class = provider_info.get(\"component_class\")\n display_name = component_class.display_name\n inputs = provider_info.get(\"inputs\")\n prefix = provider_info.get(\"prefix\", \"\")\n\n return self._build_llm_model(component_class, inputs, prefix), display_name\n\n except (AttributeError, ValueError, TypeError, RuntimeError) as e:\n await logger.aerror(f\"Error building {self.agent_llm} language model: {e!s}\")\n msg = f\"Failed to initialize language model: {e!s}\"\n raise ValueError(msg) from e\n\n def _build_llm_model(self, component, inputs, prefix=\"\"):\n model_kwargs = {}\n for input_ in inputs:\n if hasattr(self, f\"{prefix}{input_.name}\"):\n model_kwargs[input_.name] = getattr(self, f\"{prefix}{input_.name}\")\n return component.set(**model_kwargs).build_model()\n\n def set_component_params(self, component):\n provider_info = MODEL_PROVIDERS_DICT.get(self.agent_llm)\n if provider_info:\n inputs = provider_info.get(\"inputs\")\n prefix = provider_info.get(\"prefix\")\n # Filter out json_mode and only use attributes that exist on this component\n model_kwargs = {}\n for input_ in inputs:\n if hasattr(self, f\"{prefix}{input_.name}\"):\n model_kwargs[input_.name] = getattr(self, f\"{prefix}{input_.name}\")\n\n return component.set(**model_kwargs)\n return component\n\n def delete_fields(self, build_config: dotdict, fields: dict | list[str]) -> None:\n \"\"\"Delete specified fields from build_config.\"\"\"\n for field in fields:\n if build_config is not None and field in build_config:\n build_config.pop(field, None)\n\n def update_input_types(self, build_config: dotdict) -> dotdict:\n \"\"\"Update input types for all fields in build_config.\"\"\"\n for key, value in build_config.items():\n if isinstance(value, dict):\n if value.get(\"input_types\") is None:\n build_config[key][\"input_types\"] = []\n elif hasattr(value, \"input_types\") and value.input_types is None:\n value.input_types = []\n return build_config\n\n async def update_build_config(\n self, build_config: dotdict, field_value: str, field_name: str | None = None\n ) -> dotdict:\n # Iterate over all providers in the MODEL_PROVIDERS_DICT\n # Existing logic for updating build_config\n if field_name in (\"agent_llm\",):\n build_config[\"agent_llm\"][\"value\"] = field_value\n provider_info = MODEL_PROVIDERS_DICT.get(field_value)\n if provider_info:\n component_class = provider_info.get(\"component_class\")\n if component_class and hasattr(component_class, \"update_build_config\"):\n # Call the component class's update_build_config method\n build_config = await update_component_build_config(\n component_class, build_config, field_value, \"model_name\"\n )\n\n provider_configs: dict[str, tuple[dict, list[dict]]] = {\n provider: (\n MODEL_PROVIDERS_DICT[provider][\"fields\"],\n [\n MODEL_PROVIDERS_DICT[other_provider][\"fields\"]\n for other_provider in MODEL_PROVIDERS_DICT\n if other_provider != provider\n ],\n )\n for provider in MODEL_PROVIDERS_DICT\n }\n if field_value in provider_configs:\n fields_to_add, fields_to_delete = provider_configs[field_value]\n\n # Delete fields from other providers\n for fields in fields_to_delete:\n self.delete_fields(build_config, fields)\n\n # Add provider-specific fields\n if field_value == \"OpenAI\" and not any(field in build_config for field in fields_to_add):\n build_config.update(fields_to_add)\n else:\n build_config.update(fields_to_add)\n # Reset input types for agent_llm\n build_config[\"agent_llm\"][\"input_types\"] = []\n build_config[\"agent_llm\"][\"display_name\"] = \"Model Provider\"\n elif field_value == \"connect_other_models\":\n # Delete all provider fields\n self.delete_fields(build_config, ALL_PROVIDER_FIELDS)\n # # Update with custom component\n custom_component = DropdownInput(\n name=\"agent_llm\",\n display_name=\"Language Model\",\n info=\"The provider of the language model that the agent will use to generate responses.\",\n options=[*MODEL_PROVIDERS_LIST],\n real_time_refresh=True,\n refresh_button=False,\n input_types=[\"LanguageModel\"],\n placeholder=\"Awaiting model input.\",\n options_metadata=[MODELS_METADATA[key] for key in MODEL_PROVIDERS_LIST if key in MODELS_METADATA],\n external_options={\n \"fields\": {\n \"data\": {\n \"node\": {\n \"name\": \"connect_other_models\",\n \"display_name\": \"Connect other models\",\n \"icon\": \"CornerDownLeft\",\n },\n }\n },\n },\n )\n build_config.update({\"agent_llm\": custom_component.to_dict()})\n # Update input types for all fields\n build_config = self.update_input_types(build_config)\n\n # Validate required keys\n default_keys = [\n \"code\",\n \"_type\",\n \"agent_llm\",\n \"tools\",\n \"input_value\",\n \"add_current_date_tool\",\n \"system_prompt\",\n \"agent_description\",\n \"max_iterations\",\n \"handle_parsing_errors\",\n \"verbose\",\n ]\n missing_keys = [key for key in default_keys if key not in build_config]\n if missing_keys:\n msg = f\"Missing required keys in build_config: {missing_keys}\"\n raise ValueError(msg)\n if (\n isinstance(self.agent_llm, str)\n and self.agent_llm in MODEL_PROVIDERS_DICT\n and field_name in MODEL_DYNAMIC_UPDATE_FIELDS\n ):\n provider_info = MODEL_PROVIDERS_DICT.get(self.agent_llm)\n if provider_info:\n component_class = provider_info.get(\"component_class\")\n component_class = self.set_component_params(component_class)\n prefix = provider_info.get(\"prefix\")\n if component_class and hasattr(component_class, \"update_build_config\"):\n # Call each component class's update_build_config method\n # remove the prefix from the field_name\n if isinstance(field_name, str) and isinstance(prefix, str):\n field_name = field_name.replace(prefix, \"\")\n build_config = await update_component_build_config(\n component_class, build_config, field_value, \"model_name\"\n )\n return dotdict({k: v.to_dict() if hasattr(v, \"to_dict\") else v for k, v in build_config.items()})\n\n async def _get_tools(self) -> list[Tool]:\n component_toolkit = get_component_toolkit()\n tools_names = self._build_tools_names()\n agent_description = self.get_tool_description()\n # TODO: Agent Description Depreciated Feature to be removed\n description = f\"{agent_description}{tools_names}\"\n\n tools = component_toolkit(component=self).get_tools(\n tool_name=\"Call_Agent\",\n tool_description=description,\n # here we do not use the shared callbacks as we are exposing the agent as a tool\n callbacks=self.get_langchain_callbacks(),\n )\n if hasattr(self, \"tools_metadata\"):\n tools = component_toolkit(component=self, metadata=self.tools_metadata).update_tools_metadata(tools=tools)\n\n return tools\n"
+ "value": "from __future__ import annotations\n\nimport json\nimport re\nfrom typing import TYPE_CHECKING\n\nfrom pydantic import ValidationError\n\nfrom lfx.components.models_and_agents.memory import MemoryComponent\n\nif TYPE_CHECKING:\n from langchain_core.tools import Tool\n\nfrom lfx.base.agents.agent import LCToolsAgentComponent\nfrom lfx.base.agents.events import ExceptionWithMessageError\nfrom lfx.base.models.unified_models import (\n apply_provider_variable_config_to_build_config,\n get_language_model_options,\n get_llm,\n update_model_options_in_build_config,\n)\nfrom lfx.base.models.watsonx_constants import IBM_WATSONX_URLS\nfrom lfx.components.helpers import CurrentDateComponent\nfrom lfx.components.langchain_utilities.tool_calling import ToolCallingAgentComponent\nfrom lfx.custom.custom_component.component import get_component_toolkit\nfrom lfx.field_typing.range_spec import RangeSpec\nfrom lfx.helpers.base_model import build_model_from_schema\nfrom lfx.inputs.inputs import BoolInput, DropdownInput, ModelInput, StrInput\nfrom lfx.io import IntInput, MessageTextInput, MultilineInput, Output, SecretStrInput, TableInput\nfrom lfx.log.logger import logger\nfrom lfx.schema.data import Data\nfrom lfx.schema.dotdict import dotdict\nfrom lfx.schema.message import Message\nfrom lfx.schema.table import EditMode\n\n\ndef set_advanced_true(component_input):\n component_input.advanced = True\n return component_input\n\n\nclass AgentComponent(ToolCallingAgentComponent):\n display_name: str = \"Agent\"\n description: str = \"Define the agent's instructions, then enter a task to complete using tools.\"\n documentation: str = \"https://docs.langflow.org/agents\"\n icon = \"bot\"\n beta = False\n name = \"Agent\"\n\n memory_inputs = [set_advanced_true(component_input) for component_input in MemoryComponent().inputs]\n\n inputs = [\n ModelInput(\n name=\"model\",\n display_name=\"Language Model\",\n info=\"Select your model provider\",\n real_time_refresh=True,\n required=True,\n ),\n SecretStrInput(\n name=\"api_key\",\n display_name=\"API Key\",\n info=\"Model Provider API key\",\n real_time_refresh=True,\n advanced=True,\n ),\n DropdownInput(\n name=\"base_url_ibm_watsonx\",\n display_name=\"watsonx API Endpoint\",\n info=\"The base URL of the API (IBM watsonx.ai only)\",\n options=IBM_WATSONX_URLS,\n value=IBM_WATSONX_URLS[0],\n show=False,\n real_time_refresh=True,\n ),\n StrInput(\n name=\"project_id\",\n display_name=\"watsonx Project ID\",\n info=\"The project ID associated with the foundation model (IBM watsonx.ai only)\",\n show=False,\n required=False,\n ),\n MultilineInput(\n name=\"system_prompt\",\n display_name=\"Agent Instructions\",\n info=\"System Prompt: Initial instructions and context provided to guide the agent's behavior.\",\n value=\"You are a helpful assistant that can use tools to answer questions and perform tasks.\",\n advanced=False,\n ),\n MessageTextInput(\n name=\"context_id\",\n display_name=\"Context ID\",\n info=\"The context ID of the chat. Adds an extra layer to the local memory.\",\n value=\"\",\n advanced=True,\n ),\n IntInput(\n name=\"n_messages\",\n display_name=\"Number of Chat History Messages\",\n value=100,\n info=\"Number of chat history messages to retrieve.\",\n advanced=True,\n show=True,\n ),\n IntInput(\n name=\"max_tokens\",\n display_name=\"Max Tokens\",\n info=\"Maximum number of tokens to generate. Field name varies by provider.\",\n advanced=True,\n range_spec=RangeSpec(min=1, max=128000, step=1, step_type=\"int\"),\n ),\n MultilineInput(\n name=\"format_instructions\",\n display_name=\"Output Format Instructions\",\n info=\"Generic Template for structured output formatting. Valid only with Structured response.\",\n value=(\n \"You are an AI that extracts structured JSON objects from unstructured text. \"\n \"Use a predefined schema with expected types (str, int, float, bool, dict). \"\n \"Extract ALL relevant instances that match the schema - if multiple patterns exist, capture them all. \"\n \"Fill missing or ambiguous values with defaults: null for missing values. \"\n \"Remove exact duplicates but keep variations that have different field values. \"\n \"Always return valid JSON in the expected format, never throw errors. \"\n \"If multiple objects can be extracted, return them all in the structured format.\"\n ),\n advanced=True,\n ),\n TableInput(\n name=\"output_schema\",\n display_name=\"Output Schema\",\n info=(\n \"Schema Validation: Define the structure and data types for structured output. \"\n \"No validation if no output schema.\"\n ),\n advanced=True,\n required=False,\n value=[],\n table_schema=[\n {\n \"name\": \"name\",\n \"display_name\": \"Name\",\n \"type\": \"str\",\n \"description\": \"Specify the name of the output field.\",\n \"default\": \"field\",\n \"edit_mode\": EditMode.INLINE,\n },\n {\n \"name\": \"description\",\n \"display_name\": \"Description\",\n \"type\": \"str\",\n \"description\": \"Describe the purpose of the output field.\",\n \"default\": \"description of field\",\n \"edit_mode\": EditMode.POPOVER,\n },\n {\n \"name\": \"type\",\n \"display_name\": \"Type\",\n \"type\": \"str\",\n \"edit_mode\": EditMode.INLINE,\n \"description\": (\"Indicate the data type of the output field (e.g., str, int, float, bool, dict).\"),\n \"options\": [\"str\", \"int\", \"float\", \"bool\", \"dict\"],\n \"default\": \"str\",\n },\n {\n \"name\": \"multiple\",\n \"display_name\": \"As List\",\n \"type\": \"boolean\",\n \"description\": \"Set to True if this output field should be a list of the specified type.\",\n \"default\": \"False\",\n \"edit_mode\": EditMode.INLINE,\n },\n ],\n ),\n *LCToolsAgentComponent.get_base_inputs(),\n # removed memory inputs from agent component\n # *memory_inputs,\n BoolInput(\n name=\"add_current_date_tool\",\n display_name=\"Current Date\",\n advanced=True,\n info=\"If true, will add a tool to the agent that returns the current date.\",\n value=True,\n ),\n ]\n outputs = [\n Output(name=\"response\", display_name=\"Response\", method=\"message_response\"),\n ]\n\n async def get_agent_requirements(self):\n \"\"\"Get the agent requirements for the agent.\"\"\"\n from langchain_core.tools import StructuredTool\n\n max_tokens_val = getattr(self, \"max_tokens\", None)\n if max_tokens_val in {\"\", 0}:\n max_tokens_val = None\n llm_model = get_llm(\n model=self.model,\n user_id=self.user_id,\n api_key=self.api_key,\n max_tokens=max_tokens_val,\n watsonx_url=getattr(self, \"base_url_ibm_watsonx\", None),\n watsonx_project_id=getattr(self, \"project_id\", None),\n )\n if llm_model is None:\n msg = \"No language model selected. Please choose a model to proceed.\"\n raise ValueError(msg)\n\n # Get memory data\n self.chat_history = await self.get_memory_data()\n await logger.adebug(f\"Retrieved {len(self.chat_history)} chat history messages\")\n if isinstance(self.chat_history, Message):\n self.chat_history = [self.chat_history]\n\n # Add current date tool if enabled\n if self.add_current_date_tool:\n if not isinstance(self.tools, list): # type: ignore[has-type]\n self.tools = []\n current_date_tool = (await CurrentDateComponent(**self.get_base_args()).to_toolkit()).pop(0)\n\n if not isinstance(current_date_tool, StructuredTool):\n msg = \"CurrentDateComponent must be converted to a StructuredTool\"\n raise TypeError(msg)\n self.tools.append(current_date_tool)\n\n # Set shared callbacks for tracing the tools used by the agent\n self.set_tools_callbacks(self.tools, self._get_shared_callbacks())\n\n return llm_model, self.chat_history, self.tools\n\n async def message_response(self) -> Message:\n try:\n llm_model, self.chat_history, self.tools = await self.get_agent_requirements()\n # Set up and run agent\n self.set(\n llm=llm_model,\n tools=self.tools or [],\n chat_history=self.chat_history,\n input_value=self.input_value,\n system_prompt=self.system_prompt,\n )\n agent = self.create_agent_runnable()\n result = await self.run_agent(agent)\n\n # Store result for potential JSON output\n self._agent_result = result\n\n except (ValueError, TypeError, KeyError) as e:\n await logger.aerror(f\"{type(e).__name__}: {e!s}\")\n raise\n except ExceptionWithMessageError as e:\n await logger.aerror(f\"ExceptionWithMessageError occurred: {e}\")\n raise\n # Avoid catching blind Exception; let truly unexpected exceptions propagate\n except Exception as e:\n await logger.aerror(f\"Unexpected error: {e!s}\")\n raise\n else:\n return result\n\n def _preprocess_schema(self, schema):\n \"\"\"Preprocess schema to ensure correct data types for build_model_from_schema.\"\"\"\n processed_schema = []\n for field in schema:\n processed_field = {\n \"name\": str(field.get(\"name\", \"field\")),\n \"type\": str(field.get(\"type\", \"str\")),\n \"description\": str(field.get(\"description\", \"\")),\n \"multiple\": field.get(\"multiple\", False),\n }\n # Ensure multiple is handled correctly\n if isinstance(processed_field[\"multiple\"], str):\n processed_field[\"multiple\"] = processed_field[\"multiple\"].lower() in [\n \"true\",\n \"1\",\n \"t\",\n \"y\",\n \"yes\",\n ]\n processed_schema.append(processed_field)\n return processed_schema\n\n async def build_structured_output_base(self, content: str):\n \"\"\"Build structured output with optional BaseModel validation.\"\"\"\n json_pattern = r\"\\{.*\\}\"\n schema_error_msg = \"Try setting an output schema\"\n\n # Try to parse content as JSON first\n json_data = None\n try:\n json_data = json.loads(content)\n except json.JSONDecodeError:\n json_match = re.search(json_pattern, content, re.DOTALL)\n if json_match:\n try:\n json_data = json.loads(json_match.group())\n except json.JSONDecodeError:\n return {\"content\": content, \"error\": schema_error_msg}\n else:\n return {\"content\": content, \"error\": schema_error_msg}\n\n # If no output schema provided, return parsed JSON without validation\n if not hasattr(self, \"output_schema\") or not self.output_schema or len(self.output_schema) == 0:\n return json_data\n\n # Use BaseModel validation with schema\n try:\n processed_schema = self._preprocess_schema(self.output_schema)\n output_model = build_model_from_schema(processed_schema)\n\n # Validate against the schema\n if isinstance(json_data, list):\n # Multiple objects\n validated_objects = []\n for item in json_data:\n try:\n validated_obj = output_model.model_validate(item)\n validated_objects.append(validated_obj.model_dump())\n except ValidationError as e:\n await logger.aerror(f\"Validation error for item: {e}\")\n # Include invalid items with error info\n validated_objects.append({\"data\": item, \"validation_error\": str(e)})\n return validated_objects\n\n # Single object\n try:\n validated_obj = output_model.model_validate(json_data)\n return [validated_obj.model_dump()] # Return as list for consistency\n except ValidationError as e:\n await logger.aerror(f\"Validation error: {e}\")\n return [{\"data\": json_data, \"validation_error\": str(e)}]\n\n except (TypeError, ValueError) as e:\n await logger.aerror(f\"Error building structured output: {e}\")\n # Fallback to parsed JSON without validation\n return json_data\n\n async def json_response(self) -> Data:\n \"\"\"Convert agent response to structured JSON Data output with schema validation.\"\"\"\n # Always use structured chat agent for JSON response mode for better JSON formatting\n try:\n system_components = []\n\n # 1. Agent Instructions (system_prompt)\n agent_instructions = getattr(self, \"system_prompt\", \"\") or \"\"\n if agent_instructions:\n system_components.append(f\"{agent_instructions}\")\n\n # 2. Format Instructions\n format_instructions = getattr(self, \"format_instructions\", \"\") or \"\"\n if format_instructions:\n system_components.append(f\"Format instructions: {format_instructions}\")\n\n # 3. Schema Information from BaseModel\n if hasattr(self, \"output_schema\") and self.output_schema and len(self.output_schema) > 0:\n try:\n processed_schema = self._preprocess_schema(self.output_schema)\n output_model = build_model_from_schema(processed_schema)\n schema_dict = output_model.model_json_schema()\n schema_info = (\n \"You are given some text that may include format instructions, \"\n \"explanations, or other content alongside a JSON schema.\\n\\n\"\n \"Your task:\\n\"\n \"- Extract only the JSON schema.\\n\"\n \"- Return it as valid JSON.\\n\"\n \"- Do not include format instructions, explanations, or extra text.\\n\\n\"\n \"Input:\\n\"\n f\"{json.dumps(schema_dict, indent=2)}\\n\\n\"\n \"Output (only JSON schema):\"\n )\n system_components.append(schema_info)\n except (ValidationError, ValueError, TypeError, KeyError) as e:\n await logger.aerror(f\"Could not build schema for prompt: {e}\", exc_info=True)\n\n # Combine all components\n combined_instructions = \"\\n\\n\".join(system_components) if system_components else \"\"\n llm_model, self.chat_history, self.tools = await self.get_agent_requirements()\n self.set(\n llm=llm_model,\n tools=self.tools or [],\n chat_history=self.chat_history,\n input_value=self.input_value,\n system_prompt=combined_instructions,\n )\n\n # Create and run structured chat agent\n try:\n structured_agent = self.create_agent_runnable()\n except (NotImplementedError, ValueError, TypeError) as e:\n await logger.aerror(f\"Error with structured chat agent: {e}\")\n raise\n try:\n result = await self.run_agent(structured_agent)\n except (\n ExceptionWithMessageError,\n ValueError,\n TypeError,\n RuntimeError,\n ) as e:\n await logger.aerror(f\"Error with structured agent result: {e}\")\n raise\n # Extract content from structured agent result\n if hasattr(result, \"content\"):\n content = result.content\n elif hasattr(result, \"text\"):\n content = result.text\n else:\n content = str(result)\n\n except (\n ExceptionWithMessageError,\n ValueError,\n TypeError,\n NotImplementedError,\n AttributeError,\n ) as e:\n await logger.aerror(f\"Error with structured chat agent: {e}\")\n # Fallback to regular agent\n content_str = \"No content returned from agent\"\n return Data(data={\"content\": content_str, \"error\": str(e)})\n\n # Process with structured output validation\n try:\n structured_output = await self.build_structured_output_base(content)\n\n # Handle different output formats\n if isinstance(structured_output, list) and structured_output:\n if len(structured_output) == 1:\n return Data(data=structured_output[0])\n return Data(data={\"results\": structured_output})\n if isinstance(structured_output, dict):\n return Data(data=structured_output)\n return Data(data={\"content\": content})\n\n except (ValueError, TypeError) as e:\n await logger.aerror(f\"Error in structured output processing: {e}\")\n return Data(data={\"content\": content, \"error\": str(e)})\n\n async def get_memory_data(self):\n # TODO: This is a temporary fix to avoid message duplication. We should develop a function for this.\n messages = (\n await MemoryComponent(**self.get_base_args())\n .set(\n session_id=self.graph.session_id,\n context_id=self.context_id,\n order=\"Ascending\",\n n_messages=self.n_messages,\n )\n .retrieve_messages()\n )\n return [\n message for message in messages if getattr(message, \"id\", None) != getattr(self.input_value, \"id\", None)\n ]\n\n def update_input_types(self, build_config: dotdict) -> dotdict:\n \"\"\"Update input types for all fields in build_config.\"\"\"\n for key, value in build_config.items():\n if isinstance(value, dict):\n if value.get(\"input_types\") is None:\n build_config[key][\"input_types\"] = []\n elif hasattr(value, \"input_types\") and value.input_types is None:\n value.input_types = []\n return build_config\n\n async def update_build_config(\n self,\n build_config: dotdict,\n field_value: list[dict],\n field_name: str | None = None,\n ) -> dotdict:\n # Update model options with caching (for all field changes)\n # Agents require tool calling, so filter for only tool-calling capable models\n def get_tool_calling_model_options(user_id=None):\n return get_language_model_options(user_id=user_id, tool_calling=True)\n\n build_config = update_model_options_in_build_config(\n component=self,\n build_config=dict(build_config),\n cache_key_prefix=\"language_model_options_tool_calling\",\n get_options_func=get_tool_calling_model_options,\n field_name=field_name,\n field_value=field_value,\n )\n build_config = dotdict(build_config)\n\n # Iterate over all providers in the MODEL_PROVIDERS_DICT\n if field_name == \"model\":\n # Update input types for all fields\n build_config = self.update_input_types(build_config)\n\n # Show/hide provider-specific fields based on selected model\n # Get current model value - from field_value if model is being changed, otherwise from build_config\n current_model_value = field_value if field_name == \"model\" else build_config.get(\"model\", {}).get(\"value\")\n if isinstance(current_model_value, list) and len(current_model_value) > 0:\n selected_model = current_model_value[0]\n provider = selected_model.get(\"provider\", \"\")\n\n # Hide provider-specific fields by default before applying provider config\n for field in [\"base_url_ibm_watsonx\", \"project_id\"]:\n if field in build_config:\n build_config[field][\"show\"] = False\n build_config[field][\"required\"] = False\n\n # Apply provider variable configuration (advanced, required, info, env var fallback)\n if provider:\n build_config = apply_provider_variable_config_to_build_config(build_config, provider)\n\n # Validate required keys\n default_keys = [\n \"code\",\n \"_type\",\n \"model\",\n \"tools\",\n \"input_value\",\n \"add_current_date_tool\",\n \"system_prompt\",\n \"agent_description\",\n \"max_iterations\",\n \"handle_parsing_errors\",\n \"verbose\",\n ]\n missing_keys = [key for key in default_keys if key not in build_config]\n if missing_keys:\n msg = f\"Missing required keys in build_config: {missing_keys}\"\n raise ValueError(msg)\n return dotdict({k: v.to_dict() if hasattr(v, \"to_dict\") else v for k, v in build_config.items()})\n\n async def _get_tools(self) -> list[Tool]:\n component_toolkit = get_component_toolkit()\n tools_names = self._build_tools_names()\n agent_description = self.get_tool_description()\n # TODO: Agent Description Depreciated Feature to be removed\n description = f\"{agent_description}{tools_names}\"\n\n tools = component_toolkit(component=self).get_tools(\n tool_name=\"Call_Agent\",\n tool_description=description,\n # here we do not use the shared callbacks as we are exposing the agent as a tool\n callbacks=self.get_langchain_callbacks(),\n )\n if hasattr(self, \"tools_metadata\"):\n tools = component_toolkit(component=self, metadata=self.tools_metadata).update_tools_metadata(tools=tools)\n\n return tools\n"
},
"context_id": {
"_input_type": "MessageTextInput",
@@ -1547,6 +1519,7 @@
"list_add_label": "Add More",
"load_from_db": false,
"name": "context_id",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1561,6 +1534,7 @@
"format_instructions": {
"_input_type": "MultilineInput",
"advanced": true,
+ "ai_enabled": false,
"copy_field": false,
"display_name": "Output Format Instructions",
"dynamic": false,
@@ -1573,6 +1547,8 @@
"load_from_db": false,
"multiline": true,
"name": "format_instructions",
+ "override_skip": false,
+ "password": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1594,6 +1570,7 @@
"list": false,
"list_add_label": "Add More",
"name": "handle_parsing_errors",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1617,6 +1594,7 @@
"list_add_label": "Add More",
"load_from_db": false,
"name": "input_value",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1629,27 +1607,6 @@
"value": ""
},
"is_refresh": false,
- "json_mode": {
- "_input_type": "BoolInput",
- "advanced": true,
- "display_name": "JSON Mode",
- "dynamic": false,
- "info": "If True, it will output JSON regardless of passing a schema.",
- "input_types": [],
- "list": false,
- "list_add_label": "Add More",
- "name": "json_mode",
- "override_skip": false,
- "placeholder": "",
- "required": false,
- "show": true,
- "title_case": false,
- "tool_mode": false,
- "trace_as_metadata": true,
- "track_in_telemetry": true,
- "type": "bool",
- "value": false
- },
"max_iterations": {
"_input_type": "IntInput",
"advanced": true,
@@ -1660,26 +1617,6 @@
"list": false,
"list_add_label": "Add More",
"name": "max_iterations",
- "placeholder": "",
- "required": false,
- "show": true,
- "title_case": false,
- "tool_mode": false,
- "trace_as_metadata": true,
- "track_in_telemetry": true,
- "type": "int",
- "value": 15
- },
- "max_retries": {
- "_input_type": "IntInput",
- "advanced": true,
- "display_name": "Max Retries",
- "dynamic": false,
- "info": "The maximum number of retries to make when generating.",
- "input_types": [],
- "list": false,
- "list_add_label": "Add More",
- "name": "max_retries",
"override_skip": false,
"placeholder": "",
"required": false,
@@ -1689,25 +1626,26 @@
"trace_as_metadata": true,
"track_in_telemetry": true,
"type": "int",
- "value": 5
+ "value": 15
},
"max_tokens": {
"_input_type": "IntInput",
"advanced": true,
"display_name": "Max Tokens",
"dynamic": false,
- "info": "The maximum number of tokens to generate. Set to 0 for unlimited tokens.",
+ "info": "Maximum number of tokens to generate. Field name varies by provider.",
"input_types": [],
"list": false,
"list_add_label": "Add More",
+ "load_from_db": false,
"name": "max_tokens",
"override_skip": false,
"placeholder": "",
"range_spec": {
"max": 128000,
- "min": 0,
- "step": 0.1,
- "step_type": "float"
+ "min": 1,
+ "step": 1,
+ "step_type": "int"
},
"required": false,
"show": true,
@@ -1718,73 +1656,275 @@
"type": "int",
"value": ""
},
- "model_kwargs": {
- "_input_type": "DictInput",
- "advanced": true,
- "display_name": "Model Kwargs",
+ "model": {
+ "_input_type": "ModelInput",
+ "advanced": false,
+ "display_name": "Language Model",
"dynamic": false,
- "info": "Additional keyword arguments to pass to the model.",
- "input_types": [],
+ "external_options": {
+ "fields": {
+ "data": {
+ "node": {
+ "display_name": "Connect other models",
+ "icon": "CornerDownLeft",
+ "name": "connect_other_models"
+ }
+ }
+ }
+ },
+ "info": "Select your model provider",
+ "input_types": [
+ "LanguageModel"
+ ],
"list": false,
"list_add_label": "Add More",
- "name": "model_kwargs",
- "override_skip": false,
- "placeholder": "",
- "required": false,
- "show": true,
- "title_case": false,
- "tool_mode": false,
- "trace_as_input": true,
- "track_in_telemetry": false,
- "type": "dict",
- "value": {}
- },
- "model_name": {
- "_input_type": "DropdownInput",
- "advanced": false,
- "combobox": true,
- "dialog_inputs": {},
- "display_name": "Model Name",
- "dynamic": false,
- "external_options": {},
- "info": "To see the model names, first choose a provider. Then, enter your API key and click the refresh button next to the model name.",
- "input_types": [],
- "name": "model_name",
+ "load_from_db": false,
+ "model_type": "language",
+ "name": "model",
"options": [
- "gpt-4o-mini",
- "gpt-4o",
- "gpt-4.1",
- "gpt-4.1-mini",
- "gpt-4.1-nano",
- "gpt-4-turbo",
- "gpt-4-turbo-preview",
- "gpt-4",
- "gpt-3.5-turbo",
- "gpt-5.1",
- "gpt-5",
- "gpt-5-mini",
- "gpt-5-nano",
- "gpt-5-chat-latest",
- "o1",
- "o3-mini",
- "o3",
- "o3-pro",
- "o4-mini",
- "o4-mini-high"
+ {
+ "category": "Anthropic",
+ "icon": "Anthropic",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatAnthropic",
+ "model_name_param": "model"
+ },
+ "name": "claude-opus-4-6",
+ "provider": "Anthropic"
+ },
+ {
+ "category": "Anthropic",
+ "icon": "Anthropic",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatAnthropic",
+ "model_name_param": "model"
+ },
+ "name": "claude-sonnet-4-6",
+ "provider": "Anthropic"
+ },
+ {
+ "category": "Anthropic",
+ "icon": "Anthropic",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatAnthropic",
+ "model_name_param": "model"
+ },
+ "name": "claude-haiku-4-5-20251001",
+ "provider": "Anthropic"
+ },
+ {
+ "category": "Anthropic",
+ "icon": "Anthropic",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatAnthropic",
+ "model_name_param": "model"
+ },
+ "name": "claude-opus-4-5-20251101",
+ "provider": "Anthropic"
+ },
+ {
+ "category": "Anthropic",
+ "icon": "Anthropic",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatAnthropic",
+ "model_name_param": "model"
+ },
+ "name": "claude-sonnet-4-5-20250929",
+ "provider": "Anthropic"
+ },
+ {
+ "category": "OpenAI",
+ "icon": "OpenAI",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatOpenAI",
+ "model_name_param": "model",
+ "reasoning_models": [
+ "gpt-5.2"
+ ]
+ },
+ "name": "gpt-5.2",
+ "provider": "OpenAI"
+ },
+ {
+ "category": "OpenAI",
+ "icon": "OpenAI",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatOpenAI",
+ "model_name_param": "model",
+ "reasoning_models": [
+ "gpt-5.1"
+ ]
+ },
+ "name": "gpt-5.1",
+ "provider": "OpenAI"
+ },
+ {
+ "category": "OpenAI",
+ "icon": "OpenAI",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatOpenAI",
+ "model_name_param": "model",
+ "reasoning_models": [
+ "gpt-5"
+ ]
+ },
+ "name": "gpt-5",
+ "provider": "OpenAI"
+ },
+ {
+ "category": "OpenAI",
+ "icon": "OpenAI",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatOpenAI",
+ "model_name_param": "model",
+ "reasoning_models": [
+ "gpt-5-mini"
+ ]
+ },
+ "name": "gpt-5-mini",
+ "provider": "OpenAI"
+ },
+ {
+ "category": "OpenAI",
+ "icon": "OpenAI",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatOpenAI",
+ "model_name_param": "model",
+ "reasoning_models": [
+ "gpt-5-nano"
+ ]
+ },
+ "name": "gpt-5-nano",
+ "provider": "OpenAI"
+ },
+ {
+ "category": "IBM WatsonX",
+ "icon": "WatsonxAI",
+ "metadata": {
+ "api_key_param": "apikey",
+ "context_length": 128000,
+ "model_class": "ChatWatsonx",
+ "model_name_param": "model_id",
+ "project_id_param": "project_id",
+ "url_param": "url"
+ },
+ "name": "ibm/granite-3-2-8b-instruct",
+ "provider": "IBM WatsonX"
+ },
+ {
+ "category": "IBM WatsonX",
+ "icon": "WatsonxAI",
+ "metadata": {
+ "api_key_param": "apikey",
+ "context_length": 128000,
+ "model_class": "ChatWatsonx",
+ "model_name_param": "model_id",
+ "project_id_param": "project_id",
+ "url_param": "url"
+ },
+ "name": "ibm/granite-3-3-8b-instruct",
+ "provider": "IBM WatsonX"
+ },
+ {
+ "category": "IBM WatsonX",
+ "icon": "WatsonxAI",
+ "metadata": {
+ "api_key_param": "apikey",
+ "context_length": 128000,
+ "model_class": "ChatWatsonx",
+ "model_name_param": "model_id",
+ "project_id_param": "project_id",
+ "url_param": "url"
+ },
+ "name": "ibm/granite-3-8b-instruct",
+ "provider": "IBM WatsonX"
+ },
+ {
+ "category": "IBM WatsonX",
+ "icon": "WatsonxAI",
+ "metadata": {
+ "api_key_param": "apikey",
+ "context_length": 128000,
+ "model_class": "ChatWatsonx",
+ "model_name_param": "model_id",
+ "project_id_param": "project_id",
+ "url_param": "url"
+ },
+ "name": "ibm/granite-4-h-small",
+ "provider": "IBM WatsonX"
+ },
+ {
+ "category": "IBM WatsonX",
+ "icon": "WatsonxAI",
+ "metadata": {
+ "api_key_param": "apikey",
+ "context_length": 128000,
+ "model_class": "ChatWatsonx",
+ "model_name_param": "model_id",
+ "project_id_param": "project_id",
+ "url_param": "url"
+ },
+ "name": "ibm/granite-8b-code-instruct",
+ "provider": "IBM WatsonX"
+ },
+ {
+ "category": "Google Generative AI",
+ "icon": "GoogleGenerativeAI",
+ "metadata": {
+ "is_disabled_provider": true,
+ "variable_name": null
+ },
+ "name": "__enable_provider_Google Generative AI__",
+ "provider": "Google Generative AI"
+ }
],
- "options_metadata": [],
"override_skip": false,
- "placeholder": "",
- "real_time_refresh": false,
- "required": false,
+ "placeholder": "Setup Provider",
+ "real_time_refresh": true,
+ "refresh_button": true,
+ "required": true,
"show": true,
"title_case": false,
- "toggle": false,
"tool_mode": false,
- "trace_as_metadata": true,
- "track_in_telemetry": true,
- "type": "str",
- "value": "gpt-4o-mini"
+ "trace_as_input": true,
+ "track_in_telemetry": false,
+ "type": "model",
+ "value": [
+ {
+ "icon": "OpenAI",
+ "metadata": {
+ "api_key_param": "api_key",
+ "context_length": 128000,
+ "model_class": "ChatOpenAI",
+ "model_name_param": "model",
+ "reasoning_models": [
+ "gpt-5.2"
+ ]
+ },
+ "name": "gpt-5.2",
+ "provider": "OpenAI"
+ }
+ ]
},
"n_messages": {
"_input_type": "IntInput",
@@ -1796,6 +1936,7 @@
"list": false,
"list_add_label": "Add More",
"name": "n_messages",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1806,28 +1947,6 @@
"type": "int",
"value": 100
},
- "openai_api_base": {
- "_input_type": "StrInput",
- "advanced": true,
- "display_name": "OpenAI API Base",
- "dynamic": false,
- "info": "The base URL of the OpenAI API. Defaults to https://api.openai.com/v1. You can change this to use other APIs like JinaChat, LocalAI and Prem.",
- "input_types": [],
- "list": false,
- "list_add_label": "Add More",
- "load_from_db": false,
- "name": "openai_api_base",
- "override_skip": false,
- "placeholder": "",
- "required": false,
- "show": true,
- "title_case": false,
- "tool_mode": false,
- "trace_as_metadata": true,
- "track_in_telemetry": false,
- "type": "str",
- "value": ""
- },
"output_schema": {
"_input_type": "TableInput",
"advanced": true,
@@ -1838,6 +1957,7 @@
"is_list": true,
"list_add_label": "Add More",
"name": "output_schema",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1896,30 +2016,32 @@
"type": "table",
"value": []
},
- "seed": {
- "_input_type": "IntInput",
- "advanced": true,
- "display_name": "Seed",
+ "project_id": {
+ "_input_type": "StrInput",
+ "advanced": false,
+ "display_name": "watsonx Project ID",
"dynamic": false,
- "info": "The seed controls the reproducibility of the job.",
+ "info": "The project ID associated with the foundation model (IBM watsonx.ai only)",
"input_types": [],
"list": false,
"list_add_label": "Add More",
- "name": "seed",
+ "load_from_db": false,
+ "name": "project_id",
"override_skip": false,
"placeholder": "",
"required": false,
- "show": true,
+ "show": false,
"title_case": false,
"tool_mode": false,
"trace_as_metadata": true,
- "track_in_telemetry": true,
- "type": "int",
- "value": 1
+ "track_in_telemetry": false,
+ "type": "str",
+ "value": ""
},
"system_prompt": {
"_input_type": "MultilineInput",
"advanced": false,
+ "ai_enabled": false,
"copy_field": false,
"display_name": "Agent Instructions",
"dynamic": false,
@@ -1932,6 +2054,8 @@
"load_from_db": false,
"multiline": true,
"name": "system_prompt",
+ "override_skip": false,
+ "password": false,
"placeholder": "",
"required": false,
"show": true,
@@ -1941,59 +2065,7 @@
"trace_as_metadata": true,
"track_in_telemetry": false,
"type": "str",
- "value": "You are the OpenRAG Agent. You answer questions using retrieval, reasoning, and tool use.\nYou have access to several tools. Your job is to determine **which tool to use and when**.\n### Available Tools\n- OpenSearch Retrieval Tool:\n Use this to search the indexed knowledge base. Use when the user asks about product details, internal concepts, processes, architecture, documentation, roadmaps, or anything that may be stored in the index.\n- Conversation History:\n Use this to maintain continuity when the user is referring to previous turns. \n Do not treat history as a factual source.\n- Conversation File Context:\n Use this when the user asks about a document they uploaded or refers directly to its contents.\n- URL Ingestion Tool:\n Use this **only** when the user explicitly asks you to read, summarize, or analyze the content of a URL.\n Do not ingest URLs automatically.\n- Calculator / Expression Evaluation Tool:\n Use this when the user asks to compare numbers, compute estimates, calculate totals, analyze pricing, or answer any question requiring mathematics or quantitative reasoning.\n If the answer requires arithmetic, call the calculator tool rather than calculating internally.\n### Retrieval Decision Rules\nUse OpenSearch **whenever**:\n1. The question may be answered from internal or indexed data.\n2. The user references team names, product names, release plans, configurations, requirements, or official information.\n3. The user needs a factual, grounded answer.\nDo **not** use retrieval if:\n- The question is purely creative (e.g., storytelling, analogies) or personal preference.\n- The user simply wants text reformatted or rewritten from what is already present in the conversation.\nWhen uncertain → **Retrieve.** Retrieval is low risk and improves grounding.\n### URL Ingestion Rules\nOnly ingest URLs when the user explicitly says:\n- \"Read this link\"\n- \"Summarize this webpage\"\n- \"What does this site say?\"\n- \"Ingest this URL\"\nIf unclear → ask a clarifying question.\n### Calculator Usage Rules\nUse the calculator when:\n- Performing arithmetic\n- Estimating totals\n- Comparing values\n- Modeling cost, time, effort, scale, or projections\nDo not perform math internally. **Call the calculator tool instead.**\n### Answer Construction Rules\n1. When asked: \"What is OpenRAG\", answer the following:\n\"OpenRAG is an open-source package for building agentic RAG systems. It supports integration with a wide range of orchestration tools, vector databases, and LLM providers. OpenRAG connects and amplifies three popular, proven open-source projects into one powerful platform:\n**Langflow** – Langflow is a powerful tool to build and deploy AI agents and MCP servers. [Read more](https://www.langflow.org/)\n**OpenSearch** – OpenSearch is an open source, search and observability suite that brings order to unstructured data at scale. [Read more](https://opensearch.org/)\n**Docling** – Docling simplifies document processing with advanced PDF understanding, OCR support, and seamless AI integrations. Parse PDFs, DOCX, PPTX, images & more. [Read more](https://www.docling.ai/)\"\n2. Synthesize retrieved or ingested content in your own words.\n3. Support factual claims with citations in the format:\n (Source: <document_name_or_id>)\n4. If no supporting evidence is found:\n Say: \"No relevant supporting sources were found for that request.\"\n5. Never invent facts or hallucinate details.\n6. Be concise, direct, and confident. \n7. Do not reveal internal chain-of-thought."
- },
- "temperature": {
- "_input_type": "SliderInput",
- "advanced": true,
- "display_name": "Temperature",
- "dynamic": false,
- "info": "",
- "input_types": [],
- "max_label": "",
- "max_label_icon": "",
- "min_label": "",
- "min_label_icon": "",
- "name": "temperature",
- "override_skip": false,
- "placeholder": "",
- "range_spec": {
- "max": 1,
- "min": 0,
- "step": 0.01,
- "step_type": "float"
- },
- "required": false,
- "show": true,
- "slider_buttons": false,
- "slider_buttons_options": [],
- "slider_input": false,
- "title_case": false,
- "tool_mode": false,
- "track_in_telemetry": false,
- "type": "slider",
- "value": 0.1
- },
- "timeout": {
- "_input_type": "IntInput",
- "advanced": true,
- "display_name": "Timeout",
- "dynamic": false,
- "info": "The timeout for requests to OpenAI completion API.",
- "input_types": [],
- "list": false,
- "list_add_label": "Add More",
- "name": "timeout",
- "override_skip": false,
- "placeholder": "",
- "required": false,
- "show": true,
- "title_case": false,
- "tool_mode": false,
- "trace_as_metadata": true,
- "track_in_telemetry": true,
- "type": "int",
- "value": 700
+ "value": "You are the OpenRAG Agent. You answer questions using retrieval, reasoning, and tool use.\nYou have access to several tools. Your job is to determine **which tool to use and when**.\n### Available Tools\n- OpenSearch Retrieval Tool:\n Use this to search the indexed knowledge base. Use when the user asks about product details, internal concepts, processes, architecture, documentation, roadmaps, or anything that may be stored in the index.\n- Conversation History:\n Use this to maintain continuity when the user is referring to previous turns. \n Do not treat history as a factual source.\n- Conversation File Context:\n Use this when the user asks about a document they uploaded or refers directly to its contents.\n- URL Ingestion Tool:\n Use this **only** when the user explicitly asks you to read, summarize, or analyze the content of a URL.\n Do not ingest URLs automatically.\n- Calculator / Expression Evaluation Tool:\n Use this when the user asks to compare numbers, compute estimates, calculate totals, analyze pricing, or answer any question requiring mathematics or quantitative reasoning.\n If the answer requires arithmetic, call the calculator tool rather than calculating internally.\n### Retrieval Decision Rules\nUse OpenSearch **whenever**:\n1. The question may be answered from internal or indexed data.\n2. The user references team names, product names, release plans, configurations, requirements, or official information.\n3. The user needs a factual, grounded answer.\nDo **not** use retrieval if:\n- The question is purely creative (e.g., storytelling, analogies) or personal preference.\n- The user simply wants text reformatted or rewritten from what is already present in the conversation.\nWhen uncertain \u2192 **Retrieve.** Retrieval is low risk and improves grounding.\n### URL Ingestion Rules\nOnly ingest URLs when the user explicitly says:\n- \"Read this link\"\n- \"Summarize this webpage\"\n- \"What does this site say?\"\n- \"Ingest this URL\"\nIf unclear \u2192 ask a clarifying question.\n### Calculator Usage Rules\nUse the calculator when:\n- Performing arithmetic\n- Estimating totals\n- Comparing values\n- Modeling cost, time, effort, scale, or projections\nDo not perform math internally. **Call the calculator tool instead.**\n### Answer Construction Rules\n1. When asked: \"What is OpenRAG\", answer the following:\n\"OpenRAG is an open-source package for building agentic RAG systems. It supports integration with a wide range of orchestration tools, vector databases, and LLM providers. OpenRAG connects and amplifies three popular, proven open-source projects into one powerful platform:\n**Langflow** \u2013 Langflow is a powerful tool to build and deploy AI agents and MCP servers. [Read more](https://www.langflow.org/)\n**OpenSearch** \u2013 OpenSearch is an open source, search and observability suite that brings order to unstructured data at scale. [Read more](https://opensearch.org/)\n**Docling** \u2013 Docling simplifies document processing with advanced PDF understanding, OCR support, and seamless AI integrations. Parse PDFs, DOCX, PPTX, images & more. [Read more](https://www.docling.ai/)\"\n2. Synthesize retrieved or ingested content in your own words.\n3. Support factual claims with citations in the format:\n (Source: <document_name_or_id>)\n4. If no supporting evidence is found:\n Say: \"No relevant supporting sources were found for that request.\"\n5. Never invent facts or hallucinate details.\n6. Be concise, direct, and confident. \n7. Do not reveal internal chain-of-thought."
},
"tools": {
"_input_type": "HandleInput",
@@ -2007,6 +2079,7 @@
"list": true,
"list_add_label": "Add More",
"name": "tools",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -2026,6 +2099,7 @@
"list": false,
"list_add_label": "Add More",
"name": "verbose",
+ "override_skip": false,
"placeholder": "",
"required": false,
"show": true,
@@ -2045,7 +2119,7 @@
"dragging": false,
"id": "Agent-Nfw7u",
"measured": {
- "height": 594,
+ "height": 431,
"width": 320
},
"position": {
@@ -4792,4 +4866,4 @@
"assistants",
"agents"
]
-}
+}
\ No newline at end of file
diff --git a/src/services/search_service.py b/src/services/search_service.py
index 3dc45f2d3..cefdc6cc1 100644
--- a/src/services/search_service.py
+++ b/src/services/search_service.py
@@ -334,7 +334,7 @@ class SearchService:
"document_types": {"terms": {"field": "mimetype.keyword", "size": 10}},
"owners": {"terms": {"field": "owner_name.keyword", "size": 10}},
"connector_types": {"terms": {"field": "connector_type.keyword", "size": 10}},
- "embedding_models": {"terms": {"field": "embedding_model.keyword", "size": 10}},
+ "embedding_models": {"terms": {"field": "embedding_model", "size": 10}},
},
"_source": [
"filename",
@@ -473,7 +473,10 @@ class SearchService:
fallback_field = "chunk_embedding"
legacy_search_body = copy.deepcopy(search_body)
legacy_search_body.pop("min_score", None)
- legacy_search_body["query"]["bool"]["filter"] = filter_clauses
+ legacy_search_body["query"]["bool"]["filter"] = [
+ *filter_clauses,
+ {"exists": {"field": fallback_field}},
+ ]
knn_legacy = {
"knn": {