Skip to content

ENG-1836: Set name of tools on the SDK #501

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

Merged
merged 7 commits into from
Apr 28, 2025

Conversation

thiago-aixplain
Copy link
Contributor

No description provided.

@@ -28,6 +28,30 @@
from aixplain.modules.model import Model


def set_tool_name(function: Function, supplier: Supplier = None, model: Model = None) -> Text:
Copy link
Member

Choose a reason for hiding this comment

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

what will the name will be if it is an utility ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it will be the model name, since in this case model won't be None

"""Custom Python Code Tool"""
super().__init__(name="Custom Python Code", description=description, **additional_info)
super().__init__(name=name or "", description=description, **additional_info)
Copy link
Member

@ahmetgunduz ahmetgunduz Apr 25, 2025

Choose a reason for hiding this comment

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

Default tool name should not be empty string
name = name or "Custom Python Code Tool"
super().init(name=name, description=description, **additional_info)

Copy link
Contributor Author

@thiago-aixplain thiago-aixplain Apr 25, 2025

Choose a reason for hiding this comment

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

I am now validating in the initialization of the custom code class.

f"Pipeline Tool Unavailable. Make sure Pipeline '{self.pipeline}' exists or you have access to it."
)

if self.name.strip() == "":
Copy link
Member

@ahmetgunduz ahmetgunduz Apr 25, 2025

Choose a reason for hiding this comment

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

Following can be a cleaner code

Suggested change
if self.name.strip() == "":
if self.name.strip() == "":

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed for:

self.name = self.name if self.name else set_tool_name(self.function, self.supplier, self.model)

Copy link
Member

Choose a reason for hiding this comment

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

lets add a name param to thi tool as well to keep the same structure even though it is internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am calling it "Python Interpreter" now.

tool_name = tool.name
assert (
tool_name not in tool_names
), f"Agent Creation Error: Tool name '{tool_name}' is already used by another tool. Make sure all tool names are unique."
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this check for all the list and then do assert for the non unique ones for the whole list of tools? Current way will do check on by one and if I have multiple uplicated pairs I will have to to multiple iteration of error-fix-error-fix etc.

Following can be better.

  1. Create tool list of names
  2. Check duplications
  3. If there exists any, assert with all of them in error message

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

"""Create a new custom python code tool."""
return CustomPythonCodeTool(description=description, code=code)
return CustomPythonCodeTool(name=name, description=description, code=code)

@classmethod
def create_sql_tool(
Copy link
Member

Choose a reason for hiding this comment

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

why not have a name for sql as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Member

Choose a reason for hiding this comment

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

I would put name as the first parameter for all the functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am afraid to break old versions

Copy link
Member

Choose a reason for hiding this comment

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

same comments as for AgentFactory ones

@@ -60,14 +60,20 @@ def build_tool(tool: Dict):
else:
tool = PythonInterpreterTool()
elif tool["type"] == "sql":
name = tool.get("name", "")
Copy link
Member

@ahmetgunduz ahmetgunduz Apr 28, 2025

Choose a reason for hiding this comment

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

Lets have default name for any tool not empty string but a proper name. Since we do not do validate here, it might end up as an empty name?
For example, here it can be name = tool.get("name", "SQLTool")

@thiago-aixplain thiago-aixplain merged commit 268cc1a into development Apr 28, 2025
@thiago-aixplain thiago-aixplain deleted the ENG-1836-toolNames branch April 28, 2025 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants