-
Notifications
You must be signed in to change notification settings - Fork 19
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
Conversation
@@ -28,6 +28,30 @@ | |||
from aixplain.modules.model import Model | |||
|
|||
|
|||
def set_tool_name(function: Function, supplier: Supplier = None, model: Model = None) -> Text: |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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() == "": |
There was a problem hiding this comment.
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
if self.name.strip() == "": | |
if self.name.strip() == "": |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
aixplain/modules/agent/__init__.py
Outdated
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." |
There was a problem hiding this comment.
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.
- Create tool list of names
- Check duplications
- If there exists any, assert with all of them in error message
There was a problem hiding this comment.
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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
aixplain/v2/agent.py
Outdated
There was a problem hiding this comment.
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", "") |
There was a problem hiding this comment.
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")
No description provided.