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

Add Support for Querying Agents via SQL #8856

Merged
merged 21 commits into from Mar 22, 2024
Merged

Add Support for Querying Agents via SQL #8856

merged 21 commits into from Mar 22, 2024

Conversation

tmichaeldb
Copy link
Contributor

Description

Related to #8821

This PR adds support for querying agents using MindsDB SQL. Example:

CREATE AGENT my_agent ...
...
...;

SELECT answer FROM my_agent WHERE input = 'Hello!';

Type of change

  • ⚡ New feature (non-breaking change which adds functionality)

Verification Process

To ensure the changes are working as expected:

  • Test Location: ./tests/interfaces/agents/test_agents_controller.py
  • Verification Steps: Run mindsdb locally, create an agent, and query using SQL

Additional Media:

  • I have attached a brief loom video or screenshots showcasing the new functionality or change.

Checklist:

  • My code follows the style guidelines(PEP 8) of MindsDB.
  • I have appropriately commented on my code, especially in complex areas.
  • Necessary documentation updates are either made or tracked in issues.
  • Relevant unit and integration tests are updated or added.

@tmichaeldb tmichaeldb self-assigned this Feb 29, 2024
@tmichaeldb tmichaeldb added the enhancement New feature or request label Feb 29, 2024
@tmichaeldb tmichaeldb changed the base branch from agents-api to staging March 4, 2024 18:24
@tmichaeldb tmichaeldb requested a review from paxcema March 4, 2024 18:30
@@ -63,6 +67,52 @@ def predict(self, model_name: str, data, version=None, params=None):
ml_handler = self.integration_controller.get_ml_handler(model_metadata['engine_name'])
return ml_handler.predict(model_name, data, project_name=self.project.name, version=version, params=params)

def _query_agent(self, query: ast.ASTNode, existing_agent: db.Agents, session):
Copy link
Contributor

@ea-rus ea-rus Mar 5, 2024

Choose a reason for hiding this comment

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

maybe move this function to agent controller? it is about how agent works

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 would prefer to keep it here since there are a good amount of SQL operations. IMO would be best to keep filtering SQL targets, filtering conditions, etc out of agents_controller. Open to more discussion if you feel strongly though

@ea-rus
Copy link
Contributor

ea-rus commented Mar 15, 2024

Also I think for better design this function (or the whole class) should be moved to agent controller:

  • agent calls model:
  • when you select from agent
  • or when chatbot uses agent

@tmichaeldb
Copy link
Contributor Author

Also I think for better design this function (or the whole class) should be moved to agent controller:

  • agent calls model:
  • when you select from agent
  • or when chatbot uses agent

100% agree that we should have a more central location for agent completions such as agents_controller. Can we agree that it's outside the scope of this PR? Would be more appropriate to do alongside a chatbot refactor since it would be fairly involved.

@tmichaeldb tmichaeldb requested a review from ea-rus March 22, 2024 02:15
Copy link
Contributor

@dusvyat dusvyat left a comment

Choose a reason for hiding this comment

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

Nice work 🚀, LGTM

* agent behaves as model

* flake8

* don't add one more line to response
@tmichaeldb tmichaeldb merged commit c316612 into staging Mar 22, 2024
9 of 12 checks passed
@StpMax StpMax mentioned this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants