-
Notifications
You must be signed in to change notification settings - Fork 12
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
705 refactor handlechattogpt to remove mutation #743
Merged
pmarsh-scottlogic
merged 33 commits into
dev
from
705-refactor-handlechattogpt-to-remove-mutation
Jan 23, 2024
Merged
Changes from 23 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
d6939b4
refactor chatGptCallFunction
heatherlogan-scottlogic a75cdef
pass history/email vars through openAI functions
heatherlogan-scottlogic 5c06e23
remove chatResponse from tool call functions
heatherlogan-scottlogic 2270d13
start refactor on chatGptSendMessage
heatherlogan-scottlogic 904d74a
begin to remove mutations from controller functions
heatherlogan-scottlogic b9bd1bb
merge dev
heatherlogan-scottlogic 237b657
dont return defences from chatGptSendMessage
heatherlogan-scottlogic 06cc5de
rebase
heatherlogan-scottlogic b704fcb
update tests
heatherlogan-scottlogic d450106
rebase frontend changes & tidy up
heatherlogan-scottlogic ac428ed
fix alerted defences showing
heatherlogan-scottlogic 644e1e2
fix user message added to history when transformed
heatherlogan-scottlogic 1f289dc
set chatHistory to gptreply.chatHistory in getFinalReplyAfterAllToolC…
heatherlogan-scottlogic bc6bcef
Address some PR comments
heatherlogan-scottlogic df7ae2c
remove blocked and defence report from handleChatError as it is not used
heatherlogan-scottlogic e6e8150
save chat history to session on error
heatherlogan-scottlogic c9d1ccd
address PR comments
heatherlogan-scottlogic 8438fe1
remove defenceReport from ChatResponse returned by openai
heatherlogan-scottlogic c84b24e
merge dev
pmarsh-scottlogic 5968b84
removes defenceReport from LevelHandlerResponse interface
pmarsh-scottlogic 45e2a41
Merge branch 'dev' into 705-refactor-handlechattogpt-to-remove-mutation
pmarsh-scottlogic b2f1a42
708 move logic for detecting output defence bot filtering (#740)
gsproston-scottlogic 32fcc94
adds imports to test files to fix linting
pmarsh-scottlogic 32c2c56
improve comment
pmarsh-scottlogic 9e5ad27
update name from high or low level chat to chat with or without defen…
pmarsh-scottlogic 1c0a15d
removes stale comments
pmarsh-scottlogic 350ae26
moves sentEmails out of LevelHandlerResponse and uses the property in…
pmarsh-scottlogic 1cdff7b
changed an if to an else if
pmarsh-scottlogic 737dabb
unspread that spread
pmarsh-scottlogic 9723a0a
return combined report without declaring const first
pmarsh-scottlogic 404a86c
makes chatResponse decleration more concise with buttery spreads
pmarsh-scottlogic 7142e47
updates comment
pmarsh-scottlogic ae17a08
remove linter rule about uninitialised let statements. changed the le…
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
Large diffs are not rendered by default.
Oops, something went wrong.
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.
Currently, this function is only ever called with blocked=true. Do you foresee cases where blocked would be false?
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.
Hmm true i think at one point we did use distinguish between blocked messages and error messages for styling, but i don't think we need this defence information here now.
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.
@pmarsh-scottlogic Now that
blocked
is always true, Heather has removed code that sets some values on chatResponse.defenceReport. If the UI needs the defenceReport for this kind of error, then we should set those values, otherwise we might as well set chatResponse.defenceReport to null to save on payload size.Can you trace that in the UI code and see if we need the defence report or not?
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 suppose you mean
isError
is always true, when we've sent the response viahandleChatError
.Anyway, luckily not much tracing to do, all you need to do is look at
processChatResponse
in ChatBox.tsx. Yes, whenisError
is true, thedefenceReport
is irrelevant. But thedefenceReport
is relevant ifisError
is false. And in the frontend, we don't know ahead of time whether sending a message will cause an error or not, therefore we still needisError
anddefenceReport
inChatHttpResponse
.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 just checking the removed code now. Ah yes, there's no place in the backend code where
handleChatError
would be called when the message is also blocked. This is a good semantic improvement!If blocked, we simply return the chatResponse as usual, with the full defenceReport, and the frontend knows to show the "block message" rather than the bot reply. Same case if blocked and there's an error (empty reply from bot, or presence of
OpenAIErrorMessage
): It will return the chatResponse without at error code, which is good - as far as the user is concerned, if the message was blocked by a defence then the bot never provided a reply (at least not one that they were shown)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.
Does this mean we could send null / undefined for defenceReport when we have a chat error? If so, then
defenceReport
inChatHttpResponse
would need to be optional, which is maybe not great for type-safety. In that case, maybe we could split the response into two types: ChatHttpResponse and ChatHttpErrorResponse.That might be one to think about for future improvements though!
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
defenceReport
in the response is necessarily not null/undefined! It just might be "empty", that is it might have a nullblockedReason
, or an emptytriggeredDefences
list. Which means the response is bigger than it needs to be when defences are not active, but It's fine for now