-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
300 streamline frontend refresh network calls (#836)
* adds placeholder levelState endpoint * fill out handleGetLevelState * adds reminder comment * remove valid models and system roles from level state endpoint * add service to get levelSTate in frontend * adds leveStateService to index * corrects levelState url in frontend * further corrects levelState url in frontend * fixes typo in comment * renames levelState to handleStart * adds models and system roles back to start request * updates frontend service with changed name and added models and system roles * replace models and system roles front end calls with the start endpoint * erases all trace of system role endpoint * erases all trace of valid model endpoint * renames models to availableModels * removes helth check from frontend and adds catch to the handshake request which does the same thing as the health check * fix names from levelState to getStart in backend * only loads level info after first mount * separate logic for processing new level data from fetching it * remove some comments * moves main body key to App component * Revert "moves main body key to App component" This reverts commit 6e29718. * moves loadBackend data to maincoomponent * simplifies args to processBackendLevelData * converts chatMessageDTOs to chatMessages before returning from the service * moves messages state back to MainComponent * moves System roles state and openHandbook to mainComponent * removes redundant try catch and moves console log * puts startResponse in new models file combined.ts * removes comment * uses object destructuring to shorten declaration * renames to getValidOpenAIModels() * refactors loadBackendData * adds list of defences to show in level 3 by id * small rename * Revert "small rename" This reverts commit 60440bb. * Revert "adds list of defences to show in level 3 by id" This reverts commit a17d13b. * dinstinguishes between Defence and DefenceDTO. converts DTO to defence in the frontend service * fixes console log * remove defences_shown_level3 * clarifies nonModelDefences * renames ALL_DEFENCES to DEFAULT_DEFENCES * replaces a some with an includes * uses object destructuring to simplify startService * renames history to chatHistory in startResponse * fix mocking for getValidOpenAIModels * fixes different instance of same mocking problem * moves isFirstRender logic out of hook * sets isFirstRender at the the right place
- Loading branch information
1 parent
9a95a5e
commit 73e8d8e
Showing
26 changed files
with
253 additions
and
224 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,30 @@ | ||
import { Response } from 'express'; | ||
|
||
import { GetStartRequest } from '@src/models/api/getStartRequest'; | ||
import { LEVEL_NAMES } from '@src/models/level'; | ||
import { getValidOpenAIModels } from '@src/openai'; | ||
import { | ||
systemRoleLevel1, | ||
systemRoleLevel2, | ||
systemRoleLevel3, | ||
} from '@src/promptTemplates'; | ||
|
||
function handleStart(req: GetStartRequest, res: Response) { | ||
const { level } = req.query; | ||
|
||
const systemRoles = [ | ||
{ level: LEVEL_NAMES.LEVEL_1, systemRole: systemRoleLevel1 }, | ||
{ level: LEVEL_NAMES.LEVEL_2, systemRole: systemRoleLevel2 }, | ||
{ level: LEVEL_NAMES.LEVEL_3, systemRole: systemRoleLevel3 }, | ||
]; | ||
|
||
res.send({ | ||
emails: req.session.levelState[level].sentEmails, | ||
chatHistory: req.session.levelState[level].chatHistory, | ||
defences: req.session.levelState[level].defences, | ||
availableModels: getValidOpenAIModels(), | ||
systemRoles, | ||
}); | ||
} | ||
|
||
export { handleStart }; |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Request } from 'express'; | ||
|
||
import { ChatMessage } from '@src/models/chatMessage'; | ||
import { Defence } from '@src/models/defence'; | ||
import { EmailInfo } from '@src/models/email'; | ||
import { LEVEL_NAMES } from '@src/models/level'; | ||
|
||
export type GetStartRequest = Request< | ||
never, | ||
{ | ||
emails: EmailInfo[]; | ||
chatHistory: ChatMessage[]; | ||
defences: Defence[]; | ||
availableModels: string[]; | ||
systemRoles: string[]; | ||
}, | ||
never, | ||
{ | ||
level: LEVEL_NAMES; | ||
} | ||
>; |
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 was deleted.
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
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.