Closed youqugit closed 2 months ago
@youqugit Hello there! I'm a bot designed to help you solve bugs, answer questions, and become a contributor. I'm here to assist you while you wait for a human maintainer.
To ensure that the HTTP node correctly receives the result from the knowledge_retrieval
node in your Dify version 0.6.14 self-hosted workflow, you need to configure the output variable result
from the knowledge_retrieval
node and pass it to the HTTP node. Here is how you can do it:
Configure the Knowledge Retrieval Node:
knowledge_retrieval
node is set up to retrieve relevant text segments from the knowledge base using the query variable (e.g., sys.query
).result
will contain the retrieved text segments.Pass the Output to the HTTP Node:
result
from the knowledge_retrieval
node. This involves setting up the HTTP node to accept the result
as part of its input.Here is an example configuration:
nodes:
- id: knowledge_retrieval
type: knowledge_retrieval
config:
query_variable: sys.query
knowledge_base: your_knowledge_base_id
recall_mode: your_recall_mode
settings: your_settings
output:
result: knowledge_retrieval_result
- id: http_node
type: http
config:
url: your_http_endpoint
method: POST
headers:
Content-Type: application/json
body:
result: ${knowledge_retrieval_result}
In this configuration:
knowledge_retrieval
node retrieves the relevant text segments and stores them in the result
variable.http_node
is configured to send a POST request to your HTTP endpoint, including the result
from the knowledge_retrieval
node in the request body.Additionally, ensure that the knowledge_retrieval
node is correctly implemented to handle the retrieval process and return the results. The KnowledgeRetrievalNode
class in Dify handles the retrieval process and returns the results in the result
variable. Here is a snippet of the relevant part of the implementation:
class KnowledgeRetrievalNode(BaseNode):
_node_data_cls = KnowledgeRetrievalNodeData
node_type = NodeType.KNOWLEDGE_RETRIEVAL
def _run(self, variable_pool: VariablePool) -> NodeRunResult:
node_data: KnowledgeRetrievalNodeData = cast(self._node_data_cls, self.node_data)
# extract variables
query = variable_pool.get_variable_value(variable_selector=node_data.query_variable_selector)
variables = {
'query': query
}
if not query:
return NodeRunResult(
status=WorkflowNodeExecutionStatus.FAILED,
inputs=variables,
error="Query is required."
)
# retrieve knowledge
try:
results = self._fetch_dataset_retriever(
node_data=node_data, query=query
)
outputs = {
'result': results
}
return NodeRunResult(
status=WorkflowNodeExecutionStatus.SUCCEEDED,
inputs=variables,
process_data=None,
outputs=outputs
)
except Exception as e:
return NodeRunResult(
status=WorkflowNodeExecutionStatus.FAILED,
inputs=variables,
error=str(e)
)
By following these steps and ensuring the correct implementation of the KnowledgeRetrievalNode
, you can ensure that the HTTP node correctly receives the result from the knowledge_retrieval
node [1][2][3].
To continue talking to Dosu, mention @dosu.
Because the output of the Knowledge retrieval is not plain text, it return results in array, so you could use a code node or jinja node to extract things as you want, then they are able to be referenced node.
Self Checks
Dify version
0.6.14
Cloud or Self Hosted
Self Hosted (Source)
Steps to reproduce
The input variable in the http node in the workflow does not have the result of the knowledge_retrieval node.
✔️ Expected Behavior
There should be this option knowledge retrieval result Array[Object]
❌ Actual Behavior
No response