feat: Add system and quick prompts on side panel
This commit is contained in:
@@ -17,6 +17,7 @@ import { ChatHistory } from "@/store/option"
|
||||
import {
|
||||
deleteChatForEdit,
|
||||
generateID,
|
||||
getPromptById,
|
||||
removeMessageUsingHistoryId,
|
||||
updateMessageByIndex
|
||||
} from "@/db"
|
||||
@@ -75,9 +76,18 @@ export const useMessage = () => {
|
||||
setIsEmbedding,
|
||||
isEmbedding,
|
||||
currentURL,
|
||||
setCurrentURL
|
||||
setCurrentURL,
|
||||
selectedQuickPrompt,
|
||||
setSelectedQuickPrompt,
|
||||
selectedSystemPrompt,
|
||||
setSelectedSystemPrompt
|
||||
} = useStoreMessage()
|
||||
|
||||
const [speechToTextLanguage, setSpeechToTextLanguage] = useStorage(
|
||||
"speechToTextLanguage",
|
||||
"en-US"
|
||||
)
|
||||
|
||||
const [keepTrackOfEmbedding, setKeepTrackOfEmbedding] = React.useState<{
|
||||
[key: string]: MemoryVectorStore
|
||||
}>({})
|
||||
@@ -488,6 +498,7 @@ export const useMessage = () => {
|
||||
|
||||
try {
|
||||
const prompt = await systemPromptForNonRag()
|
||||
const selectedPrompt = await getPromptById(selectedSystemPrompt)
|
||||
|
||||
let humanMessage = new HumanMessage({
|
||||
content: [
|
||||
@@ -514,7 +525,7 @@ export const useMessage = () => {
|
||||
|
||||
const applicationChatHistory = generateHistory(history)
|
||||
|
||||
if (prompt) {
|
||||
if (prompt && !selectedPrompt) {
|
||||
applicationChatHistory.unshift(
|
||||
new SystemMessage({
|
||||
content: [
|
||||
@@ -526,6 +537,18 @@ export const useMessage = () => {
|
||||
})
|
||||
)
|
||||
}
|
||||
if (selectedPrompt) {
|
||||
applicationChatHistory.unshift(
|
||||
new SystemMessage({
|
||||
content: [
|
||||
{
|
||||
text: selectedPrompt.content,
|
||||
type: "text"
|
||||
}
|
||||
]
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
const chunks = await ollama.stream(
|
||||
[...applicationChatHistory, humanMessage],
|
||||
@@ -1231,6 +1254,12 @@ export const useMessage = () => {
|
||||
regenerateLastMessage,
|
||||
webSearch,
|
||||
setWebSearch,
|
||||
isSearchingInternet
|
||||
isSearchingInternet,
|
||||
selectedQuickPrompt,
|
||||
setSelectedQuickPrompt,
|
||||
selectedSystemPrompt,
|
||||
setSelectedSystemPrompt,
|
||||
speechToTextLanguage,
|
||||
setSpeechToTextLanguage
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user