The input variable in the http node in the workflow does not have the result of the knowledge_retrieval node #4943

Closed
opened 2026-02-21 18:08:42 -05:00 by yindo · 2 comments
Owner

Originally created by @youqugit on GitHub (Aug 7, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

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.
image

✔️ Expected Behavior

There should be this option knowledge retrieval
result
Array[Object]
image

Actual Behavior

No response

Originally created by @youqugit on GitHub (Aug 7, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### 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. ![image](https://github.com/user-attachments/assets/82e1174d-33f5-407c-88eb-f7ff2a832966) ### ✔️ Expected Behavior There should be this option knowledge retrieval result Array[Object] ![image](https://github.com/user-attachments/assets/2b41b2a1-df65-4ced-b533-c0445f96eeb5) ### ❌ Actual Behavior _No response_
yindo closed this issue 2026-02-21 18:08:42 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Aug 7, 2024):

@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:

  1. Configure the Knowledge Retrieval Node:

    • Ensure that the knowledge_retrieval node is set up to retrieve relevant text segments from the knowledge base using the query variable (e.g., sys.query).
    • The output variable result will contain the retrieved text segments.
  2. Pass the Output to the HTTP Node:

    • Configure the HTTP node to receive the 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:

  • The knowledge_retrieval node retrieves the relevant text segments and stores them in the result variable.
  • The 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.

@dosubot[bot] commented on GitHub (Aug 7, 2024): <!-- Greeting --> @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. <!-- Answer --> 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: 1. **Configure the Knowledge Retrieval Node:** - Ensure that the `knowledge_retrieval` node is set up to retrieve relevant text segments from the knowledge base using the query variable (e.g., `sys.query`). - The output variable `result` will contain the retrieved text segments. 2. **Pass the Output to the HTTP Node:** - Configure the HTTP node to receive the `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: ```yaml 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: - The `knowledge_retrieval` node retrieves the relevant text segments and stores them in the `result` variable. - The `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: ```python 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 <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/zh_CN/guides/workflow/node/knowledge_retrieval.md)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py)</sup><sup>[[3]](https://github.com/langgenius/dify-docs/blob/main/en/guides/workflow/node/knowledge-retrieval.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Aug 7, 2024):

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.

@crazywoola commented on GitHub (Aug 7, 2024): 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4943