Skip to content
New issue

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

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

Already on GitHub? # to your account

ENG-1392: SQL tool in Agents #400

Merged
merged 8 commits into from
Feb 17, 2025
Merged

ENG-1392: SQL tool in Agents #400

merged 8 commits into from
Feb 17, 2025

Conversation

thiago-aixplain
Copy link
Collaborator

@thiago-aixplain thiago-aixplain commented Feb 12, 2025

from aixplain.factories import AgentFactory

with open("thiago.db", "w") as f:
    f.write("")

agent = AgentFactory.create(
    name="Teste",
    description="You are a test agent that search for employees in a database",
    tools=[
        AgentFactory.create_sql_tool(
            description="Execute an SQL query and return the result",
            database="thiago.db",
            enable_commit=True,
        )
    ],
)

agent = AgentFactory.get(agent_id=agent.id)

try:
    response = agent.run("Create a table called Person with the following columns: id, name, age, salary, department")
    print(response.data)
    response = agent.run("Insert the following data into the Person table: 1, John, 30, 50000, Sales")
    print(response.data)
    response = agent.run("What is the name of the employee with the highest salary?")
    print(response.data)
except Exception as e:
    print(e)

Copy link
Member

@ahmetgunduz ahmetgunduz left a comment

Choose a reason for hiding this comment

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

Please check my review comments in agentification repo and then we can update here: https://github.com/aixplain/agentification/pull/222/files

description: Text,
database: Text,
schema: Text,
table: Optional[Text] = None,
Copy link
Member

Choose a reason for hiding this comment

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

tables?

Copy link
Member

Choose a reason for hiding this comment

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

Also can we support csv uploading. Please check my comment in agentification pr.

Copy link
Member

Choose a reason for hiding this comment

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

enable_commit is missing

Copy link
Member

@ahmetgunduz ahmetgunduz left a comment

Choose a reason for hiding this comment

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

Please check my comment

return AgentFactory.create_custom_python_code_tool(code=code, description=description)

@classmethod
def create_sql_tool(cls, description: str, database: str, schema: str, table: Optional[str] = None) -> "SQLTool":
Copy link
Member

Choose a reason for hiding this comment

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

This should have tables as well:
tables: Optional[List[Text]]

@thiago-aixplain thiago-aixplain merged commit b7d3538 into development Feb 17, 2025
@thiago-aixplain thiago-aixplain deleted the ENG-1392-sqllite branch February 17, 2025 17:36
@ahmetgunduz ahmetgunduz restored the ENG-1392-sqllite branch March 5, 2025 04:54
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants