-
Notifications
You must be signed in to change notification settings - Fork 11
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
Stop sending full defences on low levels #844
Merged
pmarsh-scottlogic
merged 43 commits into
dev
from
stop-sending-full-defences-on-low-leevels
Mar 12, 2024
Merged
Changes from 3 commits
Commits
Show all changes
43 commits
Select commit
Hold shift + click to select a range
7bedff7
defences undefined for levels 1 and 2
pmarsh-scottlogic 7e86ae4
fixes tests
pmarsh-scottlogic b0a4823
propoerly undefines defences on level 1 and 2
pmarsh-scottlogic 4e45d90
moves variable declarations to destructureing
pmarsh-scottlogic d92314c
missed one
pmarsh-scottlogic 74d8fb4
undo error swallow
pmarsh-scottlogic 1237cca
merge dev
pmarsh-scottlogic dc66ffb
remove bad type guards
pmarsh-scottlogic c442d04
improve validation for configureDefence
pmarsh-scottlogic aa8f672
last bit of validation
pmarsh-scottlogic aa0c576
update tests for handleConfigureDefence
pmarsh-scottlogic d6b6455
new folder for defence controller unit tests and wrote first handleD…
pmarsh-scottlogic 294de45
adds test for defence activation
pmarsh-scottlogic 4785161
adds tests for defence deactivation
pmarsh-scottlogic 66cdd2e
moves tests all back into one file again
pmarsh-scottlogic e74a26f
adds tests for handleResetSingleDefence
pmarsh-scottlogic 663b22e
improve validation on handleGetDefenceStatus
pmarsh-scottlogic 8429bfd
removes extraneous stuff from test objects
pmarsh-scottlogic ebba951
adds tests to make sure defences aren't chngeable for level 1
pmarsh-scottlogic 107e453
add loop to test levels 1 and 2 with same code
pmarsh-scottlogic 373e0b7
adds remaining tests for defence controller integration
pmarsh-scottlogic 8293a4a
handleResetSingleDefence takes level parameter now
pmarsh-scottlogic ae5e746
adds level to frontend call to reset defence config item. Types all t…
pmarsh-scottlogic a336617
some renamings and fill in gaps in tests
pmarsh-scottlogic 23771d9
adds another missing test
pmarsh-scottlogic 2aab5f7
tweaks
pmarsh-scottlogic a04ca87
merge dev
pmarsh-scottlogic 24b7c04
fix test suite
pmarsh-scottlogic 2fc5a6f
replace defence search with defences.some and replace cuurrentDefence…
pmarsh-scottlogic e907b04
change defenceId for generic falsy check
pmarsh-scottlogic f56383f
improve guards for level and config
pmarsh-scottlogic 65b5644
improve guards for level and config
pmarsh-scottlogic b45cce9
correct test for configuring a config item
pmarsh-scottlogic d670f00
updates error message when not allowed to activate or modify defences
pmarsh-scottlogic 095ad15
rescturecure defence controller integration tests
pmarsh-scottlogic 0d02968
change other tests to use test.each rather than foreach
pmarsh-scottlogic 9f9d628
uses isValidLevel
pmarsh-scottlogic dec9904
improve validateFilterConfig
pmarsh-scottlogic e98c251
just pass qa defence rather than all defences
pmarsh-scottlogic b0e17d0
fix tests
pmarsh-scottlogic 360c30c
uses type intersection to define QaLlmDefence
pmarsh-scottlogic 600dc65
Merge branch 'dev' into stop-sending-full-defences-on-low-leevels
pmarsh-scottlogic 8ec48c7
only gedDefencesFrDTOs if it is defined
pmarsh-scottlogic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering why we want to define defences here (other than the system role) for levels 1 and 2, which leads me to wonder why handleChatWithoutDefenceDetection needs to receive the defences at all...
If you follow the passing of defences through handleChatWithoutDefenceDetection and beyond, you end up at
handleAskQuestionFunction
in src/openai.ts, which simply checks if the Q&A LLM defence is active. If we don't have any defences, then surely we can assume it's not active. Plus, it feels overly complex to be passing all the defences through so many calls, when all we need is the QA_LLM defence.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you suggest? pass undefined through the calls instead? Make new methods for the whole call chain for getting a response without defences? I vote the former
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we don't pass defences into either handleChat function. The entire function call chain is self-contained, i.e. all functions are only invoked within this single call chain, so why not simply look up the defences from local storage in handleAskQuestionFunction? The currentLevel is passed all the way down so it's a trivial lookup. No need to pass defences down at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The answer is: to get something from the session, we need access to the
req
objectThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, silly me! As discussed, let's try passing just the Q&A LLM defence down the call chain, but also have it optional so we don't need it for levels 1 and 2.