Skip to content
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

Refactor agent mediators to work at experiment level instead of within chat stage #468

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7225b01
Refactor new agent config types
vivtsai Feb 21, 2025
5b248ab
Add ability to create multiple agent mediators in frontend editor
vivtsai Feb 21, 2025
595c1f4
Add experimenter API settings as a panel in experiment editor
vivtsai Feb 21, 2025
d72cd62
Update experimenter data settings UI to show all API settings at once
vivtsai Feb 21, 2025
e905fbb
Add delete button to agent mediator editor
vivtsai Feb 21, 2025
b90f2cd
Add LLM API field to agent editor and fix related endpoint bugs
vivtsai Feb 21, 2025
59474bb
Add private name field to agent mediator config and editor
vivtsai Feb 21, 2025
ed2b719
Show load game button in general experiment editor panel
vivtsai Feb 21, 2025
220392a
Add stage navigation to agent editor
vivtsai Feb 23, 2025
f08518f
Add agent prompt config to agent testing endpoint
vivtsai Feb 23, 2025
6c0f24d
Refactor top-level agent definition to be AgentPersonaConfig
vivtsai Feb 23, 2025
43ba94a
Temporarily add responseConfig to agent chat prompt config
vivtsai Feb 23, 2025
64bb1b0
Create separate endpoints for createExperiment and updateExperiment
vivtsai Feb 23, 2025
b4462c6
Write agents to Firestore on write/update experiment endpoints
vivtsai Feb 23, 2025
2ab19bf
Add agent configs/prompts to data download
vivtsai Feb 24, 2025
449f77a
Temporarily hide agent editor when editing existing experiments
vivtsai Feb 24, 2025
20efbf1
Store prompts in AgentDataObject as records, not lists
vivtsai Feb 24, 2025
e3641f1
Refactor chat trigger for writing agent messages
vivtsai Feb 24, 2025
073f1be
Fix missing parameter in getAgentResponse participant agent calls
vivtsai Feb 24, 2025
b2b1fbf
Add mediators based on relevant agent personas on cohort creation
vivtsai Feb 24, 2025
1041f08
Refactor ChatMessage to unified type for both participants and mediators
vivtsai Feb 24, 2025
dcad16c
Switch chat trigger from old agent calls to new refactored workflow
vivtsai Feb 24, 2025
3a29e9d
Enable users to set agents from stage builder dialog
vivtsai Feb 24, 2025
e952aec
Update Reality TV game config to work with refactored agent mediators
vivtsai Feb 24, 2025
f2fd711
Add snapshot listener for mediators to cohort service
vivtsai Feb 24, 2025
af2d395
Show mediators in chat panel list
vivtsai Feb 24, 2025
1939586
Prevent paused mediators from making API calls
vivtsai Feb 24, 2025
9fa093b
Merge branch 'main' into agent-refactor
vivtsai Feb 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions firestore/firestore.rules
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,28 @@ service cloud.firestore {
allow write: if isExperimenter();
}

match/cohorts/{cohortId} {
match /agents/{agentId} {
allow get: if isExperimenter();
allow list: if isExperimenter();
// Experimenters can use cloud function endpoints
allow write: if false;

match /chatPrompts/{promptId} {
allow read: if isExperimenter();
allow write: if false; // Write using cloud functions
}

match /participantPrompts/{promptId} {
allow read: if isExperimenter();
allow write: if false; // Write using cloud functions
}
}

match /cohorts/{cohortId} {
allow get: if true; // Public read
allow list: if canEditExperiment(experimentId);

// TODO: Experimenters can use cloud function endpoints
// Experimenters can use cloud function endpoints
allow write: if false;

match /publicStageData/{stageId} {
Expand All @@ -130,6 +147,17 @@ service cloud.firestore {
}
}

match /mediators/{mediatorId} {
// TODO: Only allow experimenters to read mediators and use
// triggers to populate mediatorPublicData for participants
// to read
allow get: if true;
allow list: if true;

// Use cloud function endpoints
allow update: if false;
}

match /participants/{participantPrivateId} {
// TODO: Only allow experimenters to read participants and use
// triggers to populate participantPublicData for participants
Expand Down
64 changes: 62 additions & 2 deletions frontend/src/components/experiment_builder/agent_editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,48 @@
@use '../../sass/typescale';

:host {
@include common.flex-row;
height: 100%;
overflow: auto;
}

.agent-nav {
@include common.flex-column;
border-right: 1px solid var(--md-sys-color-outline-variant);
flex-shrink: 0;
gap: common.$spacing-medium;
overflow: auto;
padding: common.$main-content-padding;
width: common.$sidenav-width;
}

.nav-item {
border-radius: common.$spacing-small;
padding: common.$spacing-medium;

&:hover,
&:focus {
background: var(--md-sys-color-surface-variant);
cursor: pointer;
}

&.active,
&.active:hover,
&.active:focus {
background: var(--md-sys-color-secondary-container);
color: var(--md-sys-color-on-secondary-container);
cursor: initial;
}
}

.agent-wrapper {
@include common.flex-column;
align-items: start;
flex-grow: 1;
gap: common.$spacing-xl;
max-width: common.$info-content-max-width;
overflow: auto;
padding: common.$main-content-padding;
}

.section-header {
Expand All @@ -30,6 +63,7 @@
.field {
@include common.flex-column;
gap: common.$spacing-small;
width: 100%;
}

.field-title,
Expand Down Expand Up @@ -72,7 +106,6 @@
}

pr-textarea {
flex-grow: 1;
width: 100%;
}

Expand All @@ -92,6 +125,7 @@ pr-textarea {

.divider {
border-bottom: 1px solid var(--md-sys-color-outline-variant);
width: 100%;
}

.tab {
Expand All @@ -101,5 +135,31 @@ pr-textarea {

.error-message {
font-style: italic;
color: red;
color: var(--md-sys-color-error);
}

.required {
color: var(--md-sys-color-error);
}

.action-buttons {
@include common.flex-row;
flex-wrap: wrap;
gap: common.$spacing-medium;
}

.header {
@include common.flex-row;
justify-content: space-between;
width: 100%;
}

.title {
@include typescale.title-large;
}

.chip {
@include common.chip;
@include typescale.label-small;
width: max-content;
}
Loading