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

[Docs]: Create agent using Python SDK #9376

Closed
ZoranPandovski opened this issue Jun 20, 2024 · 0 comments · Fixed by #9377
Closed

[Docs]: Create agent using Python SDK #9376

ZoranPandovski opened this issue Jun 20, 2024 · 0 comments · Fixed by #9377
Assignees
Labels
documentation Documentation needs to be added or changed

Comments

@ZoranPandovski
Copy link
Member

ZoranPandovski commented Jun 20, 2024

We need a few examples in our docs to showcase how to create agents, add skills, etc., using the Python SDK. Initial example:

import mindsdb_sdk
from uuid import uuid4

con = mindsdb_sdk.connect()

# Now create an agent that will use the model we just created.
agent = con.agents.create(name=f'mindsdb_sql_agent_{uuid4().hex}',
                          model={'model_name':'gpt-4',
                          params={'openai_api_key':'sk-'})

# Set up a Postgres data source with our new agent.
data_source = 'postgres'
connection_args = {
    "user": "demo_user",
    "password": "demo_password",
    "host": "samples.mindsdb.com",
    "port": "5432",
    "database": "demo",
    "schema": "demo_data"
}
description = 'house sales data'
database = con.databases.create(
    f'mindsdb_sql_agent_datasource_{uuid4().hex}',
    data_source,
    connection_args
)

# Actually connect the agent to the datasource.
agent.add_database(database.name, [], description)


print('Ask a question: ')
question = 'What is the average price of homes?'
answer = agent.completion([{'question': question, 'answer': None}])
print(answer.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Documentation needs to be added or changed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants