-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Make it easier and show how to add custom skills * Add 'managed' col in skills table * Update skills model, add migration file, update skills service to support new cols in skills table * Update init db to handle updating or deletion of managed skills * Update SkillsOut and SkillOut model * Add routes to create, update and delete skills. Update read_skills route to show managed skills aside from user owned skills * Add skills page, update sidebar and navbar to incorporate skills page. * Fix navigate route to not use backticks. Format code. * - Add GraphSkill pydantic model used by GraphMember to store skill info and provide its BaseTool instance. - Add dynamic_api_tool to create api tool from tool definitions. - Rename all_skills to managed_skills. * Fix query to invalidate after skill is edited * Update DeleteAlert component to handle skill deletion * - Set skill description and definition as required when creating or editing skill. - Set default for skill definition when creating skill. - Rename 'Pre-fill' button. * Order skills, teams in descending id. Order threads in descending order of updated at. * Set a maxWidth for name and description cols for skills and teams table * Refactor code * Fix lint issues * Update readme to include info about creating skills * Update readme to include boolean as possible param type * Fix validation error in api tool when optional field is not included in params. * Make mypy verbose * Disable mypy incremental mode * Use python 3.12 for github test action * Checking memory usage in github actions * Remove memory usage check in test.yml. Track memory usage in linting stage * Try running mypy on a small portion of code * Try using swap space * Show traceback when running mypy * Track if docker containers are up * Revert linting stage to original and remove swap space from github test action. * Fix migration script to add superuser if it doesnt exist * Change coverage threshold to 70 * Update skills test * Fix lint issues * Fix skill tests * Fix unauthorised error in skill test * Fix read_skill route not using user authorisation * Fix skill test * Update dynamic_api_tool to validate tool_definition * Add tests for dynamic_api_tool * Fix lint errors * Removed unused import * Add endpoint to validate skill's tool_definition * Validate tool_definition before adding or updating skill, if invalid restrict from submitting * Fix update form to reset isDirty check after submitting * validate tool_definition in create_skill and update_skill too * Fix validate_tool_definition should return tool definition * Update skill tests * Fix skill tests * fix skill test
- Loading branch information
1 parent
92bc29a
commit 9b1c73f
Showing
48 changed files
with
2,292 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
backend/app/alembic/versions/a8fff9df0a02_add_managed_col_in_skills_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
"""Add managed col in skills table | ||
Revision ID: a8fff9df0a02 | ||
Revises: 6fa42be09dd2 | ||
Create Date: 2024-06-13 12:17:08.622973 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'a8fff9df0a02' | ||
down_revision = '6fa42be09dd2' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.add_column('skill', sa.Column('managed', sa.Boolean(), nullable=False, server_default=sa.sql.expression.true())) | ||
# ### end Alembic commands ### | ||
|
||
# Remove server default after setting the initial values | ||
op.alter_column('skill', 'managed', server_default=None) | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_column('skill', 'managed') | ||
# ### end Alembic commands ### |
73 changes: 73 additions & 0 deletions
73
backend/app/alembic/versions/c1acf65d4731_update_skills_table.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
"""Update skills table | ||
Revision ID: c1acf65d4731 | ||
Revises: a8fff9df0a02 | ||
Create Date: 2024-06-13 16:09:19.067502 | ||
""" | ||
from alembic import op | ||
from app.core.security import get_password_hash | ||
import sqlalchemy as sa | ||
from sqlalchemy.sql import table, column, select | ||
from sqlalchemy import String, Integer, insert | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'c1acf65d4731' | ||
down_revision = 'a8fff9df0a02' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
# Add tool_definition column | ||
op.add_column('skill', sa.Column('tool_definition', sa.JSON(), nullable=True)) | ||
|
||
# Import the settings to get the FIRST_SUPERUSER email | ||
from app.core.config import settings | ||
|
||
# Use raw SQL to find the user ID for the superuser | ||
connection = op.get_bind() | ||
user_table = table('user', | ||
column('id', Integer), | ||
column('email', String), | ||
column('hashed_password', String), | ||
column('is_superuser', sa.Boolean), | ||
column('is_active', sa.Boolean)) | ||
superuser_email = settings.FIRST_SUPERUSER | ||
|
||
# Correct the query to properly select the user ID | ||
superuser_id = connection.execute( | ||
select(user_table.c.id).where(user_table.c.email == superuser_email) | ||
).scalar() | ||
|
||
if superuser_id is None: | ||
# Insert the superuser if it does not exist | ||
connection.execute( | ||
insert(user_table).values( | ||
email=superuser_email, | ||
hashed_password=get_password_hash(settings.FIRST_SUPERUSER_PASSWORD), | ||
is_superuser=True, | ||
is_active=True | ||
) | ||
) | ||
# Fetch the superuser ID after insertion | ||
superuser_id = connection.execute( | ||
select(user_table.c.id).where(user_table.c.email == superuser_email) | ||
).scalar() | ||
|
||
# Add owner_id column with the superuser ID as default for existing rows | ||
op.add_column('skill', sa.Column('owner_id', sa.Integer(), nullable=False, server_default=str(superuser_id))) | ||
op.alter_column('skill', 'description', existing_type=sa.VARCHAR(), nullable=False) | ||
op.create_foreign_key(None, 'skill', 'user', ['owner_id'], ['id']) | ||
|
||
# Remove the server default after setting the initial values | ||
op.alter_column('skill', 'owner_id', server_default=None) | ||
# ### end Alembic commands ### | ||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_constraint(None, 'skill', type_='foreignkey') | ||
op.alter_column('skill', 'description', existing_type=sa.VARCHAR(), nullable=True) | ||
op.drop_column('skill', 'owner_id') | ||
op.drop_column('skill', 'tool_definition') | ||
# ### end Alembic commands ### |
Oops, something went wrong.