Skip to content

Commit

Permalink
Adds genai fields to signal definition model (#5229)
Browse files Browse the repository at this point in the history
* Adds genai fields to signal definition model

* adds fields to signalbase pydantic model

* Adds genai fields to signal definition component

* adds runbook field

* bugfix

* removes import
  • Loading branch information
mvilanova authored Sep 19, 2024
1 parent f836872 commit b0cd984
Show file tree
Hide file tree
Showing 4 changed files with 114 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
"""Adds GenAI fields to Signal model
Revision ID: 19c10c121a22
Revises: 47d616802f56
Create Date: 2024-09-19 14:45:53.064341
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = '19c10c121a22'
down_revision = '47d616802f56'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('signal', sa.Column('runbook', sa.String(), nullable=True))
op.add_column('signal', sa.Column('genai_enabled', sa.Boolean(), nullable=True))
op.add_column('signal', sa.Column('genai_model', sa.String(), nullable=True))
op.add_column('signal', sa.Column('genai_system_message', sa.String(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('signal', 'genai_system_message')
op.drop_column('signal', 'genai_model')
op.drop_column('signal', 'genai_enabled')
op.drop_column('signal', 'runbook')
# ### end Alembic commands ###
12 changes: 12 additions & 0 deletions src/dispatch/signal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class SignalFilterAction(DispatchEnum):


class Signal(Base, TimeStampMixin, ProjectMixin):
"""Class that represents a detection and its properties."""
id = Column(Integer, primary_key=True)
name = Column(String)
owner = Column(String)
Expand All @@ -149,6 +150,12 @@ class Signal(Base, TimeStampMixin, ProjectMixin):
conversation_target = Column(String)
default = Column(Boolean, default=False)
lifecycle = Column(String)
runbook = Column(String)

# GenAI specific fields
genai_enabled = Column(Boolean, default=True)
genai_model = Column(String)
genai_system_message = Column(String)

oncall_service_id = Column(Integer, ForeignKey("service.id"))
oncall_service = relationship("Service", foreign_keys=[oncall_service_id])
Expand Down Expand Up @@ -219,6 +226,7 @@ class SignalFilter(Base, ProjectMixin, EvergreenMixin, TimeStampMixin):


class SignalInstance(Base, TimeStampMixin, ProjectMixin):
"""Class that represents a detection alert and its properties."""
id = Column(UUID(as_uuid=True), primary_key=True, default=lambda: str(uuid.uuid4()))
case = relationship("Case", backref="signal_instances")
case_id = Column(Integer, ForeignKey("case.id", ondelete="CASCADE"))
Expand Down Expand Up @@ -313,6 +321,10 @@ class SignalBase(DispatchBase):
source: Optional[SourceBase]
variant: Optional[str]
lifecycle: Optional[str]
runbook: Optional[str]
genai_enabled: Optional[bool] = True
genai_model: Optional[str]
genai_system_message: Optional[str]


class SignalCreate(SignalBase):
Expand Down
65 changes: 65 additions & 0 deletions src/dispatch/static/dispatch/src/signal/NewEditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@
name="Description"
/>
</v-col>
<v-col cols="12">
<v-textarea
v-model="runbook"
label="Runbook"
rows="1"
auto-grow
hint="The runbook for this detection."
persistent-hint
clearable
name="Runbook"
/>
</v-col>
<v-col cols="12">
<v-text-field
v-model="variant"
Expand Down Expand Up @@ -199,6 +211,55 @@
</v-card>
</v-col>

<v-col cols="12">
<v-card flat rounded="0">
<v-toolbar color="transparent">
<v-toolbar-title class="text-subtitle-2"> GenAI Configuration </v-toolbar-title>
<template #append>
<v-tooltip max-width="250px" location="bottom">
<template #activator="{ props }">
<v-icon v-bind="props">mdi-help-circle-outline</v-icon>
</template>
The following options allow you to configure settings related to Dispatch's GenAI
features.
</v-tooltip>
</template>
</v-toolbar>
<v-card-text>
<v-row no-gutters>
<v-col cols="12">
<v-checkbox
v-model="genai_enabled"
label="Enabled"
hint="Determines whether GenAI features are enabled for this detection."
persistent-hint
/>
</v-col>
<v-col cols="12">
<v-text-field
v-model="genai_model"
label="Model"
hint="The model to use for processing."
persistent-hint
name="model"
readonly
/>
</v-col>
<v-col cols="12">
<v-text-field
v-model="genai_system_message"
label="System Message"
hint="The system message to set the behavior of the assistant"
persistent-hint
name="systemMessage"
readonly
/>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-col>

<v-col cols="12">
<v-card flat rounded="0">
<v-toolbar color="transparent">
Expand Down Expand Up @@ -305,6 +366,7 @@ export default {
computed: {
...mapFields("signal", [
"dialogs.showCreateEdit",
"selected.runbook",
"selected",
"selected.case_priority",
"selected.case_type",
Expand All @@ -317,6 +379,9 @@ export default {
"selected.external_id",
"selected.external_url",
"selected.filters",
"selected.genai_enabled",
"selected.genai_model",
"selected.genai_system_message",
"selected.id",
"selected.lifecycle",
"selected.loading",
Expand Down
4 changes: 4 additions & 0 deletions src/dispatch/static/dispatch/src/signal/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@ const getDefaultSelectedState = () => {
external_id: null,
external_url: null,
filters: [],
genai_enabled: false,
genai_model: null,
genai_system_message: null,
id: null,
lifecycle: null,
loading: false,
name: null,
oncall_service: null,
owner: null,
project: null,
runbook: null,
signal_definition: null,
source: null,
tags: [],
Expand Down

0 comments on commit b0cd984

Please sign in to comment.