From d6185b90e8f9541be64c2609f1ca6fed6657d3c1 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Fri, 6 Dec 2024 09:57:50 -0800 Subject: [PATCH 1/2] add observer_thought_id to artifacts table --- ...46e9_add_observer_thought_id_column_to_.py | 39 +++++++++++++++++++ skyvern/forge/sdk/db/models.py | 1 + 2 files changed, 40 insertions(+) create mode 100644 alembic/versions/2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py diff --git a/alembic/versions/2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py b/alembic/versions/2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py new file mode 100644 index 0000000000..a9d4b76b2f --- /dev/null +++ b/alembic/versions/2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py @@ -0,0 +1,39 @@ +"""Add observer_thought_id column to artifacts table + +Revision ID: b2b7b23646e9 +Revises: 4d51ed4719d5 +Create Date: 2024-12-06 17:51:28.372085+00:00 + +""" + +from typing import Sequence, Union + +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision: str = "b2b7b23646e9" +down_revision: Union[str, None] = "4d51ed4719d5" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column("artifacts", sa.Column("observer_thought_id", sa.String(), nullable=True)) + op.create_foreign_key( + "artifacts_observer_thought_id_fkey", + "artifacts", + "observer_thoughts", + ["observer_thought_id"], + ["observer_thought_id"], + ) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint("artifacts_observer_thought_id_fkey", "artifacts", type_="foreignkey") + op.drop_column("artifacts", "observer_thought_id") + # ### end Alembic commands ### diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py index c3523d524a..7fca903740 100644 --- a/skyvern/forge/sdk/db/models.py +++ b/skyvern/forge/sdk/db/models.py @@ -169,6 +169,7 @@ class ArtifactModel(Base): workflow_run_id = Column(String, ForeignKey("workflow_runs.workflow_run_id")) workflow_run_block_id = Column(String, ForeignKey("workflow_run_blocks.workflow_run_block_id")) observer_cruise_id = Column(String, ForeignKey("observer_cruises.observer_cruise_id")) + observer_thought_id = Column(String, ForeignKey("observer_thoughts.observer_thought_id")) task_id = Column(String, ForeignKey("tasks.task_id")) step_id = Column(String, ForeignKey("steps.step_id"), index=True) artifact_type = Column(String) From 24b78381e1c066b0a0900098b8f11807faf9f1c5 Mon Sep 17 00:00:00 2001 From: Shuchang Zheng Date: Fri, 6 Dec 2024 10:19:47 -0800 Subject: [PATCH 2/2] add observer_thought_id to artifacts table & user_input, observation to ObserverThought --- ...49b59d836c_add_observer_thought_id_column_to_.py} | 12 ++++++++---- skyvern/forge/sdk/db/models.py | 2 ++ 2 files changed, 10 insertions(+), 4 deletions(-) rename alembic/versions/{2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py => 2024_12_06_1819-fe49b59d836c_add_observer_thought_id_column_to_.py} (66%) diff --git a/alembic/versions/2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py b/alembic/versions/2024_12_06_1819-fe49b59d836c_add_observer_thought_id_column_to_.py similarity index 66% rename from alembic/versions/2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py rename to alembic/versions/2024_12_06_1819-fe49b59d836c_add_observer_thought_id_column_to_.py index a9d4b76b2f..6207a24cab 100644 --- a/alembic/versions/2024_12_06_1751-b2b7b23646e9_add_observer_thought_id_column_to_.py +++ b/alembic/versions/2024_12_06_1819-fe49b59d836c_add_observer_thought_id_column_to_.py @@ -1,8 +1,8 @@ -"""Add observer_thought_id column to artifacts table +"""Add observer_thought_id column to artifacts table. Add user_input, observation to ObserverThoughts -Revision ID: b2b7b23646e9 +Revision ID: fe49b59d836c Revises: 4d51ed4719d5 -Create Date: 2024-12-06 17:51:28.372085+00:00 +Create Date: 2024-12-06 18:19:23.286827+00:00 """ @@ -13,7 +13,7 @@ from alembic import op # revision identifiers, used by Alembic. -revision: str = "b2b7b23646e9" +revision: str = "fe49b59d836c" down_revision: Union[str, None] = "4d51ed4719d5" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None @@ -29,11 +29,15 @@ def upgrade() -> None: ["observer_thought_id"], ["observer_thought_id"], ) + op.add_column("observer_thoughts", sa.Column("user_input", sa.UnicodeText(), nullable=True)) + op.add_column("observer_thoughts", sa.Column("observation", sa.String(), nullable=True)) # ### end Alembic commands ### def downgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### + op.drop_column("observer_thoughts", "observation") + op.drop_column("observer_thoughts", "user_input") op.drop_constraint("artifacts_observer_thought_id_fkey", "artifacts", type_="foreignkey") op.drop_column("artifacts", "observer_thought_id") # ### end Alembic commands ### diff --git a/skyvern/forge/sdk/db/models.py b/skyvern/forge/sdk/db/models.py index 7fca903740..2edc5702e9 100644 --- a/skyvern/forge/sdk/db/models.py +++ b/skyvern/forge/sdk/db/models.py @@ -525,5 +525,7 @@ class ObserverThought(Base): workflow_run_id = Column(String, ForeignKey("workflow_runs.workflow_run_id"), nullable=True) workflow_run_block_id = Column(String, ForeignKey("workflow_run_blocks.workflow_run_block_id"), nullable=True) workflow_id = Column(String, ForeignKey("workflows.workflow_id"), nullable=True) + user_input = Column(UnicodeText, nullable=True) + observation = Column(String, nullable=True) thought = Column(String, nullable=True) answer = Column(String, nullable=True)