Skip to content

Commit

Permalink
Add option to delete a LLM response and edit the last reply
Browse files Browse the repository at this point in the history
  • Loading branch information
sedwards2009 committed Jan 13, 2024
1 parent 55cb577 commit 4aea1b7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions frontend/src/responseeditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export function ResponseEditor({response, modelOverview, presetOverview, templat
setReply("");
};

const replyMessages = response.messages.slice(1);
const onDeleteResponseMessageClicked = (replyMessageIndex: number) => {
const replyMessage = replyMessages[replyMessageIndex-1];
setReply(replyMessage.text);
onDeleteMessageClicked(replyMessage.id);
};

let isSendEnabled = false;
let model: Model | null = null;
let supportsContinue = false;
Expand Down Expand Up @@ -108,13 +115,15 @@ export function ResponseEditor({response, modelOverview, presetOverview, templat
onDeleteClicked={null}
/>
}
{response.messages.slice(1).map((m ,i) =>
{replyMessages.map((m, i) =>
<ResponseMessage
key={m.id}
message={m}
onContinueClicked={supportsContinue && isSendEnabled && response.status === "Done" &&
response.messages.length-1 === i+1 ? onContinueClicked : null}
onDeleteClicked={isSendEnabled && response.status === "Done" && m.role == "User"? () => onDeleteMessageClicked(m.id) : null}
onDeleteClicked={isSendEnabled && response.status === "Done"
? (m.role == "User" ? () => onDeleteMessageClicked(m.id) : () => onDeleteResponseMessageClicked(i))
: null}
/>
)}
{isSendEnabled && response.status === "Done" &&
Expand Down

0 comments on commit 4aea1b7

Please sign in to comment.