-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
24 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
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,22 @@ | ||
import { createDMessage, DMessage } from '~/common/state/store-chats'; | ||
|
||
|
||
const replyToSystemPrompt = `The user is referring to this in particular: | ||
{{ReplyToText}}`; | ||
|
||
/** | ||
* Adds a system message to the history, explaining the context of the reply | ||
* | ||
* FIXME: HACK - this is a temporary solution to pass the metadata to the execution | ||
* | ||
* Only works with OpenAI and a couple more right now. Fix it by making it vendor-agnostic | ||
*/ | ||
export function updateHistoryForReplyTo(history: DMessage[]) { | ||
if (history?.length < 1) | ||
return; | ||
|
||
const lastMessage = history[history.length - 1]; | ||
|
||
if (lastMessage.role === 'user' && lastMessage.metadata?.inReplyToText) | ||
history.push(createDMessage('system', replyToSystemPrompt.replace('{{ReplyToText}}', lastMessage.metadata.inReplyToText))); | ||
} |