Last active
June 25, 2023 17:36
-
-
Save Yankzy/e2d5927f70685ef085d2187c13878b05 to your computer and use it in GitHub Desktop.
Control shatGPT with system role
This file contains hidden or 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
| interface ChatMessage { | |
| role: string; | |
| content: string; | |
| } | |
| export const chatOrchestrator = ( | |
| chatHistory: ChatMessage[], | |
| setChatList: (chatList: ChatMessage[]) => void | |
| ): void => { | |
| const steps = ['introduction', 'specific goals', 'timeframe', 'metrics', 'action plan']; | |
| const msg = (step: string) => ` | |
| Your next step is: ${step}. | |
| Do not skip it and do not overwhelm the user with 2 steps at a time.`; | |
| internalChat([ | |
| ...chatHistory, | |
| { role: "system", content: 'Which step number are you now?' } | |
| ]).then((res) => { | |
| for (let i = 0; i < steps.length; i++) { | |
| if (res.toLowerCase().includes(steps[i]) || res.includes((i+1).toString())) { | |
| setChatList([...chatHistory, { role: "system", content: msg(steps[i+1]) }]) | |
| break; | |
| } | |
| } | |
| }).catch((err) => { | |
| Logger('chatOrchestrator', err); | |
| }); | |
| }; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment