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

[backend] adding tools for agents, filter tools by agent_id #204

Merged
merged 9 commits into from
Jun 13, 2024

Conversation

scott-cohere
Copy link
Contributor

@scott-cohere scott-cohere commented Jun 12, 2024

Eventually we would want to map tools to a DB table. However, for v1 we can just store tools as a list of tool names as users cannot actually delete,add,update tools in the application itself (must be done in the code). For v1 we also do not have the notion of different organizations yet.

Also adding query param on GET /v1/tools -> GET /v1/tools?agent_id=... to filter tool by agent id

  • Add tests and docs: Please include testing and documentation for your changes
  • Lint and test: Run make lint and make run-tests

AI Description

This PR introduces a new tools field to the Agent model, allowing for a list of associated tools. This change is reflected in the database schema, test suites, and API endpoints.

  • The Agent model in src/backend/database_models/agent.py now includes a tools field, which is a list of ToolName enums.
  • The upgrade and downgrade functions in src/backend/alembic/versions/922e874930bf_.py have been updated to add and remove the tools column from the agents table, respectively.
  • The create_agent function in src/backend/routers/agent.py now includes the tools parameter, which is passed to the create_agent function in the agent_crud module.
  • The list_tools API endpoint in src/backend/routers/tool.py has been modified to accept an optional agent_id parameter. It now returns a list of tools associated with the specified agent, if provided.
  • The Agent class in src/backend/schemas/agent.py now includes a tools field, which is a list of ToolName.
  • The test_create_agent and test_update_agent functions in src/backend/tests/crud/test_agent.py have been updated to include the tools field in the agent creation and update requests.
  • The Agent factory in src/backend/tests/factories/agent.py now includes a tools field, which is a list of random ToolName enums.
  • The test_create_agent function in src/backend/tests/routers/test_agent.py has been updated to include the tools field in the agent creation request.
  • The test_list_tools function in src/backend/tests/routers/test_tool.py has been modified to test the listing of tools associated with a specific agent.

@scott-cohere scott-cohere changed the title [backend] adding tools for agents [backend] adding tools for agents, filter tools by agent_id Jun 12, 2024
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 98.59155% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (main@5155eee). Learn more about missing BASE report.

Files Patch % Lines
src/backend/alembic/versions/922e874930bf_.py 91.66% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #204   +/-   ##
=======================================
  Coverage        ?   88.22%           
=======================================
  Files           ?      137           
  Lines           ?     4551           
  Branches        ?        0           
=======================================
  Hits            ?     4015           
  Misses          ?      536           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@lusmoura lusmoura left a comment

Choose a reason for hiding this comment

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

LGTM!

@scott-cohere scott-cohere merged commit 60f25d9 into main Jun 13, 2024
4 checks passed
@scott-cohere scott-cohere deleted the scott/agents-api-tools branch June 13, 2024 16:59
ClaytonSmith pushed a commit to MiniMap-ai/cohere-toolkit that referenced this pull request Jun 13, 2024
…i#204)

* changes

* lint

* filter tools by agent

* lint

* update tests

* lint and squash migrations

* fix alembic migration err

* lint
ClaytonSmith added a commit to MiniMap-ai/cohere-toolkit that referenced this pull request Jun 17, 2024
* [coral-web] rename schema fields and update openapi client (cohere-ai#189)

* update

* update client

* Add use agents view env variable.  (cohere-ai#192)

* Change

* Format

* [backend] api_key not set for class methods (cohere-ai#191)

* fix

* easier fix

* perf: downgrade rehype-highlight and generate once blob url (cohere-ai#193)

* perf: downgrade rehype-highlight and generate once blob url

* fix: replace code blocks to iframe in conversation history

* refactor: run format

* refactor: pr feedback

* Add OIDC auth strategy, add Blacklist scaffolding (model/schema/crud) (cohere-ai#190)

* add oidc, blacklist logic

* Add auth

* Add logic for GET /auth

* Mods

* fix: html preview with citations (cohere-ai#200)

* [backend] adding tools for agents, filter tools by agent_id (cohere-ai#204)

* changes

* lint

* filter tools by agent

* lint

* update tests

* lint and squash migrations

* fix alembic migration err

* lint

* merge (#3)


* [backend] make deployment field optional in API and DB (cohere-ai#213)

---------

Co-authored-by: Tianjing Li <[email protected]>
Co-authored-by: Tomeu <[email protected]>
Co-authored-by: Scott <[email protected]>
Co-authored-by: Beatrix De Wilde <[email protected]>

* pulling from main

* cleaned backend docker image push

* syncing with main (conflicts)

---------

Co-authored-by: Scott <[email protected]>
Co-authored-by: Beatrix De Wilde <[email protected]>
Co-authored-by: Tomeu <[email protected]>
Co-authored-by: Tianjing Li <[email protected]>
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.

3 participants