-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* General css for strategies * Attack box * Slightly better strategy styling * Fixed attack id * Attack mechanism no longer highlighted on hover * TypeScript attacks * TypeScript AttackBox * Removed JS DefenceBox
- Loading branch information
1 parent
a09c06c
commit b11314f
Showing
10 changed files
with
130 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { ATTACK_TYPES, AttackInfo } from "./models/attack"; | ||
|
||
const ATTACKS: AttackInfo[] = [ | ||
{ | ||
id: ATTACK_TYPES.JAILBREAK_PROMPT, | ||
name: "jailbreak prompt", | ||
info: "using prompt injection, get the chat bot in a state where it no longer follows its original instructions.", | ||
}, | ||
]; | ||
|
||
export default ATTACKS; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import "../StrategyBox/StrategyBox.css"; | ||
import AttackMechanism from "./AttackMechanism"; | ||
import ATTACKS from "../../Attacks"; | ||
|
||
function AttackBox() { | ||
return ( | ||
<div id="strategy-box"> | ||
{ATTACKS.map((attack, index) => { | ||
return <AttackMechanism key={attack.id} attack={attack} />; | ||
})} | ||
</div> | ||
); | ||
} | ||
|
||
export default AttackBox; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { AttackInfo } from "../../models/attack"; | ||
import "../StrategyBox/StrategyMechanism.css"; | ||
import React from "react"; | ||
|
||
function DefenceMechanism({ attack }: { attack: AttackInfo }) { | ||
const [isInfoBoxVisible, setIsInfoBoxVisible] = React.useState(false); | ||
|
||
return ( | ||
<span> | ||
<div className="strategy-mechanism"> | ||
<div className="strategy-mechanism-header"> | ||
<span>{attack.name}</span> | ||
<span | ||
className="strategy-mechanism-info" | ||
onMouseOver={() => { | ||
setIsInfoBoxVisible(true); | ||
}} | ||
onMouseLeave={() => { | ||
setIsInfoBoxVisible(false); | ||
}} | ||
> | ||
<span>?</span> | ||
</span> | ||
</div> | ||
{isInfoBoxVisible ? ( | ||
<div className="strategy-mechanism-info-box">{attack.info}</div> | ||
) : null} | ||
</div> | ||
</span> | ||
); | ||
} | ||
|
||
export default DefenceMechanism; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../src/components/DefenceBox/DefenceBox.css → ...rc/components/StrategyBox/StrategyBox.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#defence-box { | ||
#strategy-box { | ||
padding: 16px 32px; | ||
position: relative; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
.strategy-mechanism { | ||
border-color: #ccc; | ||
border-radius: 8px; | ||
border-style: solid; | ||
border-width: 1px; | ||
padding: 6px; | ||
margin: 1px; | ||
margin-bottom: 8px; | ||
cursor: default; | ||
} | ||
|
||
.strategy-mechanism-header { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
|
||
.strategy-mechanism-info { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
border-color: #ccc; | ||
border-radius: 10px; | ||
border-style: solid; | ||
border-width: 1px; | ||
height: 20px; | ||
width: 20px; | ||
background-color: #ddd; | ||
color: #444; | ||
} | ||
|
||
.strategy-mechanism-info span { | ||
position: relative; | ||
bottom: 1px; | ||
} | ||
|
||
.strategy-mechanism-info-box { | ||
border-color: #ccc; | ||
border-style: solid; | ||
border-width: 1px 0 0 0; | ||
font-size: 14px; | ||
margin-top: 4px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
enum ATTACK_TYPES { | ||
JAILBREAK_PROMPT = "JAILBREAK_PROMPT", | ||
} | ||
|
||
interface AttackInfo { | ||
id: ATTACK_TYPES; | ||
name: string; | ||
info: string; | ||
} | ||
|
||
export { ATTACK_TYPES }; | ||
export type { AttackInfo }; |