Closed heatherlogan-scottlogic closed 9 months ago
One thing that goes hand-in-hand with immutability is avoiding let
declarations wherever possible. Sometimes it doesn't seem possible, if we have conditional statements that might or might not overwrite that value, but such cases are often a sign that the function needs to be split. In any case, this is a strong start, and the rest we can tackle as we go.
Really appreciate the thorough PR description ⭐
Nothing else from me. Aside from Peter's open questions (and the merge conflict) this looks good to go.
@pmarsh-scottlogic Would you like to take this one, and I'll handle George's PR?
@chriswilty I was about to suggest exactly the same thing :)
chatGptSendMessage(...)
@pmarsh-scottlogic I'm very happy with this now, good work. The linter rule is small beans, remove it if you wish - doesn't stop me approving.
Description
Refactor of functions inside chatController.ts and openAI.ts to reduce mutation. ChatResponse, chatHistroy, sentEmails, should not be mutated across different functions - instead changes should be returned by the using functions either as
Notes
openai.ts
chatGptCallFunction()
performToolCalls()
getFinalReplyAfterToolCalls()
pushCompletionToHistory()
chatGptChatCompletion()
chatGptSendMessage()
chatController.ts
handleLowLevelChat()
handleHigherLevelChat()
handleChatError()
handleErrorGettingReply()
handleChatToGPT()
Concerns
Checklist
Have you done the following?