Skip to content

[backend/db] setting up agents in db #175

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

Merged
merged 11 commits into from
Jun 6, 2024
Merged

[backend/db] setting up agents in db #175

merged 11 commits into from
Jun 6, 2024

Conversation

scott-cohere
Copy link
Contributor

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

Thank you for contributing to the Cohere Toolkit!

  • PR title: "area: description"
    • Where "area" is whichever of interface, frontend, model, tools, backend, etc. is being modified. Use "docs: ..." for purely docs changes, "infra: ..." for CI changes.
    • Example: "deployment: add Azure model option"

This is the first PR in a series where we introduce agents to toolkit!

This PR adds DB changes to accomodate agents in the API. This PR is purely focused on DB migration, CRUD operations on the new DB table, and tests.

Follow ups:

  • Migration to have relationship between tools/agents and deployments/agents

  • The API route logic for agents

  • 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 Agent model and its associated CRUD operations.

The Agent model represents a new entity with the following attributes:

  • version: An integer representing the version of the agent.
  • name: A string containing the name of the agent.
  • description: A string providing a description of the agent.
  • preamble: A string containing additional information about the agent.
  • temperature: A float value associated with the agent.
  • model: A string indicating the model type of the agent, with possible values including "COMMAND_R", "COMMAND_R_PLUS", "COMMAND_LIGHT", and "COMMAND".
  • deployment: A string specifying the deployment type of the agent, with possible values such as "COHERE_PLATFORM", "SAGE_MAKER", "AZURE", and "BEDROCK".
  • user_id: A string representing the ID of the user associated with the agent.
  • id: A unique identifier for the agent.
  • created_at and updated_at: Datetime values indicating when the agent was created and last updated.

The following changes have been made:

  • Added a new Agent class in src/backend/database_models/agent.py to define the structure of the Agent model, including its attributes and their data types.
  • Created CRUD (Create, Read, Update, Delete) functions for the Agent model in src/backend/crud/agent.py:
    • create_agent: Creates a new agent and returns it.
    • get_agent: Retrieves an agent by its ID.
    • get_agents: Fetches all agents for a user, with optional pagination using offset and limit.
    • update_agent: Updates an existing agent with new data.
    • delete_agent: Deletes an agent by its ID.
  • Introduced tests for the CRUD operations in src/backend/tests/crud/test_agent.py to ensure their functionality and integrity constraints.
  • Added necessary imports and adjustments in related files to accommodate the new Agent model and its operations.

@scott-cohere scott-cohere changed the title Agent DB Migration [backend] setting up agents Jun 5, 2024
@scott-cohere scott-cohere changed the title [backend] setting up agents [backend] setting up agents db Jun 5, 2024
@scott-cohere scott-cohere changed the title [backend] setting up agents db [backend/db] setting up agents in db Jun 5, 2024
@scott-cohere scott-cohere marked this pull request as ready for review June 5, 2024 19:57
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 98.30508% with 3 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@17a67df). Learn more about missing BASE report.

Files Patch % Lines
src/backend/routers/agent.py 0.00% 2 Missing ⚠️
src/backend/alembic/versions/3247f8fd3f71_.py 90.90% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #175   +/-   ##
=======================================
  Coverage        ?   88.38%           
=======================================
  Files           ?      121           
  Lines           ?     3839           
  Branches        ?        0           
=======================================
  Hits            ?     3393           
  Misses          ?      446           
  Partials        ?        0           

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

@scott-cohere scott-cohere merged commit d0459af into main Jun 6, 2024
2 checks passed
@scott-cohere scott-cohere deleted the scott/agents-db branch June 6, 2024 16:01
@scott-cohere scott-cohere mentioned this pull request Jun 7, 2024
3 tasks
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.

4 participants