Subsequent nodes cannot set Google tool output variables, and Google search does not seem to work in existing examples #4668

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

Originally created by @wj1017090777 on GitHub (Jul 18, 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).
  • 请务必使用英文提交 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 (Docker)

Steps to reproduce

image
In the SEO blog generation workflow, I noticed that there is a Google search tool, but the variables of the Google search tool are not passed in the subsequent nodes, and the answer results are not answered according to the results of Google search.
And I tried to add variables, but the Google search variable only has text, and the results are actually stored in json. Please help me check, thank you.
image

✔️ Expected Behavior

Correct use of Google search tools

Actual Behavior

Subsequent nodes cannot set Google tool output variables, and Google search does not seem to work in existing examples

Originally created by @wj1017090777 on GitHub (Jul 18, 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] 请务必使用英文提交 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 (Docker) ### Steps to reproduce ![image](https://github.com/user-attachments/assets/ddb99488-28b1-487f-b225-dbb852357ff1) In the SEO blog generation workflow, I noticed that there is a Google search tool, but the variables of the Google search tool are not passed in the subsequent nodes, and the answer results are not answered according to the results of Google search. And I tried to add variables, but the Google search variable only has text, and the results are actually stored in json. Please help me check, thank you. ![image](https://github.com/user-attachments/assets/acdeddfa-2191-418f-9c7f-240943f06346) ### ✔️ Expected Behavior Correct use of Google search tools ### ❌ Actual Behavior Subsequent nodes cannot set Google tool output variables, and Google search does not seem to work in existing examples
yindo added the 🌊 feat:workflow label 2026-02-21 18:07:29 -05:00
yindo closed this issue 2026-02-21 18:07:29 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 18, 2024):

To resolve the issue with the SEO blog generation workflow in Dify version 0.6.14, where the Google search tool's output variables are not being passed to subsequent nodes, you need to ensure that the Google search tool is correctly configured to output its results in a format that can be utilized by the subsequent LLM node.

Here is a step-by-step guide to ensure the correct configuration:

  1. Check the Google Search Tool Configuration:
    Ensure that the google_search.yaml file is correctly configured to output the results in the desired format.

    identity: # Basic information of the tool
      name: google_search # Tool name, unique, no duplication with other tools
      author: Dify # Author
      label: # Label for frontend display
        en_US: GoogleSearch # English label
        zh_Hans: 谷歌搜索 # Chinese label
    description: # Description for frontend display
      human: # Introduction for frontend display, supports multiple languages
        en_US: A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query.
        zh_Hans: 一个用于执行 Google SERP 搜索并提取片段和网页的工具。输入应该是一个搜索查询。
      llm: A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query. # Introduction passed to LLM, in order to make LLM better understand this tool, we suggest to write as detailed information about this tool as possible here, so that LLM can understand and use this tool
    parameters: # Parameter list
      - name: query # Parameter name
        type: string # Parameter type
        required: true # Required or not
        label: # Parameter label
          en_US: Query string # English label
          zh_Hans: 查询语句 # Chinese label
        human_description: # Introduction for frontend display, supports multiple languages
          en_US: used for searching
          zh_Hans: 用于搜索网页内容
        llm_description: key words for searching # Introduction passed to LLM, similarly, in order to make LLM better understand this parameter, we suggest to write as detailed information about this parameter as possible here, so that LLM can understand this parameter
        form: llm # Form type, llm means this parameter needs to be inferred by Agent, the frontend will not display this parameter
      - name: result_type
        type: select # Parameter type
        required: true
        options: # Drop-down box options
          - value: text
            label:
              en_US: text
              zh_Hans: 文本
          - value: link
            label:
              en_US: link
              zh_Hans: 链接
        default: link
        label:
          en_US: Result type
          zh_Hans: 结果类型
        human_description:
          en_US: used for selecting the result type, text or link
          zh_Hans: 用于选择结果类型,使用文本还是链接进行展示
        form: form # Form type, form means this parameter needs to be filled in by the user on the frontend before the conversation starts
    
  2. Modify the Google Search Tool Code:
    Ensure that the google_search.py file correctly processes the results and formats them as needed.

    from core.tools.tool.builtin_tool import BuiltinTool
    from core.tools.entities.tool_entities import ToolInvokeMessage
    
    from typing import Any, Dict, List, Union
    
    class GoogleSearchTool(BuiltinTool):
        def _invoke(self, 
                    user_id: str,
                    tool_parameters: Dict[str, Any], 
            ) -> Union[ToolInvokeMessage, List[ToolInvokeMessage]]:
            """
                invoke tools
            """
            query = tool_parameters['query']
            result_type = tool_parameters['result_type']
            api_key = self.runtime.credentials['serpapi_api_key']
            # TODO: search with serpapi
            result = SerpAPI(api_key).run(query, result_type=result_type)
    
            if result_type == 'text':
                return self.create_text_message(text=result)
            return self.create_link_message(link=result)
    
  3. Ensure Correct Output Handling:
    Make sure that the output from the Google search tool is correctly passed to the subsequent LLM node. If the results are in JSON format, you might need to parse them before passing them to the LLM node.

    from core.tools.tool.builtin_tool import BuiltinTool
    from core.tools.entities.tool_entities import ToolInvokeMessage
    
    from typing import Any, Dict, List, Union
    import json
    
    class GoogleSearchTool(BuiltinTool):
        def _invoke(self, 
                    user_id: str,
                    tool_parameters: Dict[str, Any], 
            ) -> Union[ToolInvokeMessage, List[ToolInvokeMessage]]:
            """
                invoke tools
            """
            query = tool_parameters['query']
            result_type = tool_parameters['result_type']
            api_key = self.runtime.credentials['serpapi_api_key']
            # TODO: search with serpapi
            result = SerpAPI(api_key).run(query, result_type=result_type)
    
            if result_type == 'text':
                result_text = json.dumps(result)  # Convert JSON to text
                return self.create_text_message(text=result_text)
            return self.create_link_message(link=result)
    

By ensuring that the Google search tool is correctly configured and that its output is properly formatted and passed to the subsequent nodes, you should be able to resolve the issue with the SEO blog generation workflow [1].

To continue talking to Dosu, mention @dosu.

@dosubot[bot] commented on GitHub (Jul 18, 2024): <!-- Answer --> To resolve the issue with the SEO blog generation workflow in Dify version 0.6.14, where the Google search tool's output variables are not being passed to subsequent nodes, you need to ensure that the Google search tool is correctly configured to output its results in a format that can be utilized by the subsequent LLM node. Here is a step-by-step guide to ensure the correct configuration: 1. **Check the Google Search Tool Configuration:** Ensure that the `google_search.yaml` file is correctly configured to output the results in the desired format. ```yaml identity: # Basic information of the tool name: google_search # Tool name, unique, no duplication with other tools author: Dify # Author label: # Label for frontend display en_US: GoogleSearch # English label zh_Hans: 谷歌搜索 # Chinese label description: # Description for frontend display human: # Introduction for frontend display, supports multiple languages en_US: A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query. zh_Hans: 一个用于执行 Google SERP 搜索并提取片段和网页的工具。输入应该是一个搜索查询。 llm: A tool for performing a Google SERP search and extracting snippets and webpages.Input should be a search query. # Introduction passed to LLM, in order to make LLM better understand this tool, we suggest to write as detailed information about this tool as possible here, so that LLM can understand and use this tool parameters: # Parameter list - name: query # Parameter name type: string # Parameter type required: true # Required or not label: # Parameter label en_US: Query string # English label zh_Hans: 查询语句 # Chinese label human_description: # Introduction for frontend display, supports multiple languages en_US: used for searching zh_Hans: 用于搜索网页内容 llm_description: key words for searching # Introduction passed to LLM, similarly, in order to make LLM better understand this parameter, we suggest to write as detailed information about this parameter as possible here, so that LLM can understand this parameter form: llm # Form type, llm means this parameter needs to be inferred by Agent, the frontend will not display this parameter - name: result_type type: select # Parameter type required: true options: # Drop-down box options - value: text label: en_US: text zh_Hans: 文本 - value: link label: en_US: link zh_Hans: 链接 default: link label: en_US: Result type zh_Hans: 结果类型 human_description: en_US: used for selecting the result type, text or link zh_Hans: 用于选择结果类型,使用文本还是链接进行展示 form: form # Form type, form means this parameter needs to be filled in by the user on the frontend before the conversation starts ``` 2. **Modify the Google Search Tool Code:** Ensure that the `google_search.py` file correctly processes the results and formats them as needed. ```python from core.tools.tool.builtin_tool import BuiltinTool from core.tools.entities.tool_entities import ToolInvokeMessage from typing import Any, Dict, List, Union class GoogleSearchTool(BuiltinTool): def _invoke(self, user_id: str, tool_parameters: Dict[str, Any], ) -> Union[ToolInvokeMessage, List[ToolInvokeMessage]]: """ invoke tools """ query = tool_parameters['query'] result_type = tool_parameters['result_type'] api_key = self.runtime.credentials['serpapi_api_key'] # TODO: search with serpapi result = SerpAPI(api_key).run(query, result_type=result_type) if result_type == 'text': return self.create_text_message(text=result) return self.create_link_message(link=result) ``` 3. **Ensure Correct Output Handling:** Make sure that the output from the Google search tool is correctly passed to the subsequent LLM node. If the results are in JSON format, you might need to parse them before passing them to the LLM node. ```python from core.tools.tool.builtin_tool import BuiltinTool from core.tools.entities.tool_entities import ToolInvokeMessage from typing import Any, Dict, List, Union import json class GoogleSearchTool(BuiltinTool): def _invoke(self, user_id: str, tool_parameters: Dict[str, Any], ) -> Union[ToolInvokeMessage, List[ToolInvokeMessage]]: """ invoke tools """ query = tool_parameters['query'] result_type = tool_parameters['result_type'] api_key = self.runtime.credentials['serpapi_api_key'] # TODO: search with serpapi result = SerpAPI(api_key).run(query, result_type=result_type) if result_type == 'text': result_text = json.dumps(result) # Convert JSON to text return self.create_text_message(text=result_text) return self.create_link_message(link=result) ``` By ensuring that the Google search tool is correctly configured and that its output is properly formatted and passed to the subsequent nodes, you should be able to resolve the issue with the SEO blog generation workflow <sup>[[1]](https://github.com/langgenius/dify/blob/main/api/core/tools/docs/en_US/tool_scale_out.md)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.*
Author
Owner

@crazywoola commented on GitHub (Jul 18, 2024):

Use a jinja template tool or code block to format results from google could solve your problem.

@crazywoola commented on GitHub (Jul 18, 2024): Use a jinja template tool or code block to format results from google could solve your problem.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#4668