Skip to content

Commit

Permalink
Fix bug when updating prompts in ai ext
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclarke committed Oct 30, 2024
1 parent a9c9bce commit 8624418
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions shared/studio/tabs/ai/state/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export class AIAdminState extends Model({

const messages = Object.values(newPromptDraft._messages).map((m) => ({
role: m.participant_role,
name: m.participant_name,
name: m.participant_name?.trim() || null,
content: m.content,
}));

Expand Down Expand Up @@ -883,7 +883,7 @@ export class AIPromptDraft extends Model({
this._messages[id] = {
id,
participant_role: "System",
participant_name: "",
participant_name: null,
content: null,
};
}
Expand Down Expand Up @@ -983,10 +983,15 @@ export class AIPromptDraft extends Model({
filter .id = <uuid>$messageId
set {
participant_role := <str>$participant_role,
participant_name := <str>$participant_name,
participant_name := <optional str>$participant_name,
content := <str>$content
}`,
{messageId, participant_role, participant_name, content},
{
messageId,
participant_role,
participant_name: participant_name?.trim() || null,
content,
},
{ignoreSessionConfig: true}
);

Expand All @@ -1006,7 +1011,7 @@ export class AIPromptDraft extends Model({
newMessage := (
insert ext::ai::ChatPromptMessage {
participant_role := <str>$participant_role,
participant_name := <str>$participant_name,
participant_name := <optional str>$participant_name,
content := <str>$content
}
)
Expand All @@ -1015,7 +1020,12 @@ export class AIPromptDraft extends Model({
set {
messages += newMessage
}`,
{promptId: this.id, participant_role, participant_name, content},
{
promptId: this.id,
participant_role,
participant_name: participant_name?.trim() || null,
content,
},
{ignoreSessionConfig: true}
);

Expand Down

0 comments on commit 8624418

Please sign in to comment.