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

fix: error in agent mode while using models not supporting tools #5057

Closed
wants to merge 2 commits into from

Conversation

sinomoe
Copy link
Contributor

@sinomoe sinomoe commented Jun 10, 2024

Description

In the "ReAct Agent" mode, after executing a tool, a "ToolPromptMessage" is saved. Since the model in "ReAct" mode definitely does not support function calling, it is unable to calculate the token count of the "ToolPromptMessage." The fix is to determine whether to calculate the token count of the "ToolPromptMessage" based on whether the model's feature supports "tool calling."

Fixes #5055

Type of Change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update, included: Dify Document
  • Improvement, including but not limited to code refactoring, performance optimization, and UI/UX improvement
  • Dependency upgrade

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • manual test

Suggested Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
  • optional I have made corresponding changes to the documentation
  • optional I have added tests that prove my fix is effective or that my feature works
  • optional New and existing unit tests pass locally with my changes

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working labels Jun 10, 2024
@sinomoe
Copy link
Contributor Author

sinomoe commented Jun 11, 2024

It seems like that this is a common issue in models which do not support tools calling. there is the same issue with volcengine maas models. Perhaps we should avoid calculating the tool prompt's token count in agent mode while using models that do not support tools calling?

@sinomoe sinomoe marked this pull request as draft June 11, 2024 11:56
@sinomoe sinomoe changed the title fix: ollama generates error in agent mode while using tools fix: error in agent mode while using models not supporting tools Jun 11, 2024
@sinomoe sinomoe force-pushed the fix/cast-ollama-prompt branch from ca92c26 to 07a414f Compare June 11, 2024 16:20
@sinomoe sinomoe marked this pull request as ready for review June 11, 2024 16:22
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 11, 2024
@sinomoe sinomoe force-pushed the fix/cast-ollama-prompt branch from 8dcc8a9 to bc1979b Compare June 11, 2024 16:38
@sinomoe sinomoe marked this pull request as draft June 11, 2024 17:09
@sinomoe
Copy link
Contributor Author

sinomoe commented Jun 15, 2024

found another way to fix the issue, refer to #5245

@sinomoe sinomoe closed this Jun 15, 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 size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using the jinareader tool, BUG in multi-round conversations
1 participant