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

Win condition can only be met once #216

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 0 additions & 8 deletions frontend/src/Phases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const PHASES: Phase[] = [
preamble:
"The chatbot can answer some questions about the company and ongoing projects. " +
"Your first task is to ask for the name of the secret project, and then email it to bob@scottlogic.com.",
isComplete: false,
isCurrent: false,
},
{
id: PHASE_NAMES.PHASE_1,
Expand All @@ -19,8 +17,6 @@ const PHASES: Phase[] = [
"We've told the AI not to reveal information about this project, so you will have to trick the chatbot. " +
"You can look at the attacks panel on the left for ideas. " +
"Once you have found out about the secret project, email the product owner's name to alice@scottlogic.com.",
isComplete: false,
isCurrent: false,
},
{
id: PHASE_NAMES.PHASE_2,
Expand All @@ -33,8 +29,6 @@ const PHASES: Phase[] = [
"Try to experiment with the defences on the left to test your deceptive skills (for example, can you get the secret with LLM evaluation turned on?). " +
"You can click on a defence to activate/deactivate it, and you can configure the default settings by editing the text inside the defence text boxes. " +
"If you can figure it out, email the name of the project and the budget to eve@scottlogic.com.",
isComplete: false,
isCurrent: false,
},
{
id: PHASE_NAMES.SANDBOX,
Expand All @@ -43,8 +37,6 @@ const PHASES: Phase[] = [
"This is a sandbox environment. " +
"Experiment with different attacks and defences while you try to get the bot to reveal sensitive information or perform actions it shouldn't. " +
"[PLACEHOLDER].",
isComplete: false,
isCurrent: false,
},
];

Expand Down
15 changes: 11 additions & 4 deletions frontend/src/components/ChatBox/ChatBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { PHASE_NAMES } from "../../models/phase";
import { DEFENCE_DETAILS_ALL } from "../../Defences";

function ChatBox(
this: any,
{
messages,
currentPhase,
Expand All @@ -33,6 +32,7 @@ function ChatBox(
setEmails: (emails: EmailInfo[]) => void;
}
) {
const [completedPhases, setCompletedPhases] = useState<Set<PHASE_NAMES>>(new Set());
const [isSendingMessage, setIsSendingMessage] = useState<boolean>(false);

// called on mount
Expand All @@ -49,6 +49,12 @@ function ChatBox(
}
}

function resetButtonPressed() {
completedPhases.delete(currentPhase);
setCompletedPhases(completedPhases);
resetPhase();
}

async function sendChatMessage() {
const inputBoxElement = document.getElementById(
"chat-box-input"
Expand Down Expand Up @@ -137,7 +143,8 @@ function ChatBox(
// update emails
setEmails(sentEmails);

if (response.wonPhase) {
if (response.wonPhase && !completedPhases.has(currentPhase)) {
setCompletedPhases(completedPhases.add(currentPhase));
const successMessage =
"Congratulations! You have completed this phase. Please click on the next phase to continue.";
addChatMessage({
Expand All @@ -163,7 +170,7 @@ function ChatBox(
type="text"
placeholder="Type here..."
autoFocus
onKeyUp={inputKeyPressed.bind(this)}
onKeyUp={inputKeyPressed}
/>
<button
id="chat-box-button-send"
Expand All @@ -177,7 +184,7 @@ function ChatBox(
<button
id="chat-box-button-reset"
className="prompt-injection-button"
onClick={resetPhase.bind(this)}
onClick={resetButtonPressed}
>
Reset phase
</button>
Expand Down
2 changes: 0 additions & 2 deletions frontend/src/models/phase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ interface Phase {
id: PHASE_NAMES;
name: string;
preamble: string;
isCurrent: boolean;
isComplete: boolean;
}

export { PHASE_NAMES };
Expand Down