From 1100bf62480c973c3f6e0068e4682e7ec5d51eda Mon Sep 17 00:00:00 2001 From: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Date: Fri, 20 Sep 2024 15:08:57 -0700 Subject: [PATCH] Adds a new genai field to signal definition model to store the prompt (#5232) --- .../versions/2024-09-20_1f4dc687945d.py | 27 +++++++++++++++++++ src/dispatch/signal/models.py | 2 ++ .../dispatch/src/signal/NewEditDialog.vue | 17 +++++++++++- .../static/dispatch/src/signal/store.js | 1 + 4 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 src/dispatch/database/revisions/tenant/versions/2024-09-20_1f4dc687945d.py diff --git a/src/dispatch/database/revisions/tenant/versions/2024-09-20_1f4dc687945d.py b/src/dispatch/database/revisions/tenant/versions/2024-09-20_1f4dc687945d.py new file mode 100644 index 000000000000..edd02b4eb38f --- /dev/null +++ b/src/dispatch/database/revisions/tenant/versions/2024-09-20_1f4dc687945d.py @@ -0,0 +1,27 @@ +"""Adds new genai prompt column to signal definition model + +Revision ID: 1f4dc687945d +Revises: 19c10c121a22 +Create Date: 2024-09-20 10:49:11.303112 + +""" +from alembic import op +import sqlalchemy as sa + +# revision identifiers, used by Alembic. +revision = '1f4dc687945d' +down_revision = '19c10c121a22' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('signal', sa.Column('genai_prompt', sa.String(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('signal', 'genai_prompt') + # ### end Alembic commands ### diff --git a/src/dispatch/signal/models.py b/src/dispatch/signal/models.py index 0fbaf4fa668f..c3c058362491 100644 --- a/src/dispatch/signal/models.py +++ b/src/dispatch/signal/models.py @@ -156,6 +156,7 @@ class Signal(Base, TimeStampMixin, ProjectMixin): genai_enabled = Column(Boolean, default=True) genai_model = Column(String) genai_system_message = Column(String) + genai_prompt = Column(String) oncall_service_id = Column(Integer, ForeignKey("service.id")) oncall_service = relationship("Service", foreign_keys=[oncall_service_id]) @@ -325,6 +326,7 @@ class SignalBase(DispatchBase): genai_enabled: Optional[bool] = True genai_model: Optional[str] genai_system_message: Optional[str] + genai_prompt: Optional[str] class SignalCreate(SignalBase): diff --git a/src/dispatch/static/dispatch/src/signal/NewEditDialog.vue b/src/dispatch/static/dispatch/src/signal/NewEditDialog.vue index efcc2ecf37b0..adbb1cf96f72 100644 --- a/src/dispatch/static/dispatch/src/signal/NewEditDialog.vue +++ b/src/dispatch/static/dispatch/src/signal/NewEditDialog.vue @@ -246,15 +246,29 @@ /> - + + + @@ -381,6 +395,7 @@ export default { "selected.filters", "selected.genai_enabled", "selected.genai_model", + "selected.genai_prompt", "selected.genai_system_message", "selected.id", "selected.lifecycle", diff --git a/src/dispatch/static/dispatch/src/signal/store.js b/src/dispatch/static/dispatch/src/signal/store.js index 2c33ba3b718b..da260d43e648 100644 --- a/src/dispatch/static/dispatch/src/signal/store.js +++ b/src/dispatch/static/dispatch/src/signal/store.js @@ -20,6 +20,7 @@ const getDefaultSelectedState = () => { filters: [], genai_enabled: false, genai_model: null, + genai_prompt: null, genai_system_message: null, id: null, lifecycle: null,