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

Use the tool with the highest similarity instead of the first one over 75% #3100

Merged
merged 1 commit into from May 10, 2023
Merged

Use the tool with the highest similarity instead of the first one over 75% #3100

merged 1 commit into from May 10, 2023

Conversation

someone13574
Copy link
Contributor

No description provided.

@@ -162,12 +162,17 @@ def prepare_json(json_str: str) -> str:


def use_tool(tool_name: str, tool_input: str, tools: list) -> str:
best_match = None
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code could just be something like:

    best_match, best_similarity = max(
        ((tool, similarity(tool.name, tool_name)) for tool in tools),
        key=lambda x: x[1], 
        default=(None, 0),
    )

@olliestanley olliestanley merged commit e662a8a into LAION-AI:main May 10, 2023
1 check passed
@someone13574 someone13574 deleted the better-tool-selection branch May 30, 2023 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants