Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tool node extract_tool_response_text add empty elements to list #10987

Closed
5 tasks done
PedroGomes02 opened this issue Nov 22, 2024 · 1 comment · Fixed by #10988
Closed
5 tasks done

Tool node extract_tool_response_text add empty elements to list #10987

PedroGomes02 opened this issue Nov 22, 2024 · 1 comment · Fixed by #10988
Labels
🐞 bug Something isn't working

Comments

@PedroGomes02
Copy link
Contributor

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

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Use a tool that outputs only more than one ToolInvokeMessage.MessageType.JSON.
Check tool output on tracing. Only the "json" output should be filled, the "text" output should be empty or an empty string.

✔️ Expected Behavior

Only the "json" output should be filled, the "text" output should be empty or an empty string.

❌ Actual Behavior

The "json" output should is filled, but the "text" output is an list of "\n".

Copy link

dosubot bot commented Nov 22, 2024

The issue you're experiencing with the extract_tool_response_text function is due to the way the list comprehension is structured in the _extract_tool_response_text method. Specifically, it adds an empty string "" for any ToolInvokeMessage that is not of type TEXT or LINK. This results in a list of empty strings, which when joined with "\n", produces a string of newline characters.

Here's the relevant part of the code:

def _extract_tool_response_text(self, tool_response: list[ToolInvokeMessage]) -> str:
    return "\n".join(
        [
            f"{message.message}"
            if message.type == ToolInvokeMessage.MessageType.TEXT
            else f"Link: {message.message}"
            if message.type == ToolInvokeMessage.MessageType.LINK
            else ""
            for message in tool_response
        ]
    )

The else "" part is responsible for adding empty strings for message types that are neither TEXT nor LINK [1].

To continue talking to Dosu, mention @dosu.

@dosubot dosubot bot added the 🐞 bug Something isn't working label Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant