Skip to content

Commit

Permalink
Add transformChats function to prepend system message in chatGPT temp…
Browse files Browse the repository at this point in the history
…late
  • Loading branch information
ap0k4 committed Nov 7, 2024
1 parent e24320b commit 081389d
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ const logger = getLogger()

Protofy("type", "chatGPT")

function transformChats(prevChats, prompt: string) {
const additionalSystemMessage = {
role: "system",
content: prompt
};
return [additionalSystemMessage, ...prevChats];
}

export default Protofy("code", async (app:Application, context: typeof APIContext) => {
createChatbot(app, '{{codeNameLowerCase}}', async (req, res, chatbot) => {
const {session, token} = getAuth(req)
const { metadata, ...body } = req.body
const { session, token } = getAuth(req)

context.chatGPT.chatGPTPrompt({
...req.body,
...body,
//messages: transformChats(body.messages, metadata.context),
done: (response, message) => {
chatbot.end()
},
Expand Down

0 comments on commit 081389d

Please sign in to comment.