diff --git a/src/components/Option/Settings/prompt.tsx b/src/components/Option/Settings/prompt.tsx
index f0cbbc2..499011c 100644
--- a/src/components/Option/Settings/prompt.tsx
+++ b/src/components/Option/Settings/prompt.tsx
@@ -1,5 +1,5 @@
import { useQuery, useQueryClient } from "@tanstack/react-query"
-import { Skeleton, Radio, Form, Alert } from "antd"
+import { Skeleton, Radio, Form, Input } from "antd"
import React from "react"
import { useTranslation } from "react-i18next"
import { SaveButton } from "~/components/Common/SaveButton"
@@ -8,15 +8,15 @@ import {
setSystemPromptForNonRagOption,
systemPromptForNonRagOption,
geWebSearchFollowUpPrompt,
- setWebPrompts
+ setWebPrompts,
+ promptForRag,
+ setPromptForRag
} from "~/services/ollama"
export const SettingPrompt = () => {
const { t } = useTranslation("settings")
- const [selectedValue, setSelectedValue] = React.useState<"normal" | "web">(
- "web"
- )
+ const [selectedValue, setSelectedValue] = React.useState<"web" | "rag">("rag")
const queryClient = useQueryClient()
@@ -25,7 +25,7 @@ export const SettingPrompt = () => {
queryFn: async () => {
const [prompt, webSearchPrompt, webSearchFollowUpPrompt] =
await Promise.all([
- systemPromptForNonRagOption(),
+ promptForRag(),
getWebSearchPrompt(),
geWebSearchFollowUpPrompt()
])
@@ -48,46 +48,60 @@ export const SettingPrompt = () => {
setSelectedValue(e.target.value)}>
-
- {t("ollamaSettings.settings.prompt.option1")}
-
+ RAG
{t("ollamaSettings.settings.prompt.option2")}
- {selectedValue === "normal" && (
+ {selectedValue === "rag" && (
-
+
-
@@ -126,32 +140,36 @@ export const SettingPrompt = () => {
)
}
]}>
-
-
diff --git a/src/services/ollama.ts b/src/services/ollama.ts
index e8e65b1..0e785d0 100644
--- a/src/services/ollama.ts
+++ b/src/services/ollama.ts
@@ -11,8 +11,7 @@ const DEFAULT_PAGE_SHARE_URL = "https://pageassist.xyz"
const DEFAULT_RAG_QUESTION_PROMPT =
"Given the following conversation and a follow up question, rephrase the follow up question to be a standalone question. Chat History: {chat_history} Follow Up Input: {question} Standalone question:"
-const DEFAUTL_RAG_SYSTEM_PROMPT = `You are a helpful AI assistant. Use the following pieces of context to answer the question at the end. If you don't know the answer, just say you don't know. DO NOT try to make up an answer. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context. {context} Question: {question} Helpful answer in markdown:`
-
+const DEFAUTL_RAG_SYSTEM_PROMPT = `You are a helpful AI assistant. Use the following pieces of context to answer the question at the end. If you don't know the answer, just say you don't know. DO NOT try to make up an answer. If the question is not related to the context, politely respond that you are tuned to only answer questions that are related to the context. {context} Question: {question} Helpful answer:`
const DEFAULT_WEBSEARCH_PROMP = `You are a helpful assistant that can answer any questions. You can use the following search results in case you want to answer questions about anything in real-time. The current date and time are {current_date_time}.
@@ -61,7 +60,11 @@ export const isOllamaRunning = async () => {
}
}
-export const getAllModels = async ({ returnEmpty = false }: { returnEmpty?: boolean }) => {
+export const getAllModels = async ({
+ returnEmpty = false
+}: {
+ returnEmpty?: boolean
+}) => {
try {
const baseUrl = await getOllamaURL()
const response = await fetch(`${cleanUrl(baseUrl)}/api/tags`)
@@ -264,7 +267,6 @@ export const saveForRag = async (
await setDefaultEmbeddingChunkOverlap(overlap)
}
-
export const getWebSearchPrompt = async () => {
const prompt = await storage.get("webSearchPrompt")
if (!prompt || prompt.length === 0) {
@@ -280,23 +282,20 @@ export const setWebSearchPrompt = async (prompt: string) => {
export const geWebSearchFollowUpPrompt = async () => {
const prompt = await storage.get("webSearchFollowUpPrompt")
if (!prompt || prompt.length === 0) {
- return DEFAULT_RAG_QUESTION_PROMPT;
+ return DEFAULT_RAG_QUESTION_PROMPT
}
return prompt
}
-
export const setWebSearchFollowUpPrompt = async (prompt: string) => {
await storage.set("webSearchFollowUpPrompt", prompt)
}
-
export const setWebPrompts = async (prompt: string, followUpPrompt: string) => {
await setWebSearchPrompt(prompt)
await setWebSearchFollowUpPrompt(followUpPrompt)
}
-
export const getPageShareUrl = async () => {
const pageShareUrl = await storage.get("pageShareUrl")
if (!pageShareUrl || pageShareUrl.length === 0) {
@@ -305,7 +304,6 @@ export const getPageShareUrl = async () => {
return pageShareUrl
}
-
export const setPageShareUrl = async (pageShareUrl: string) => {
await storage.set("pageShareUrl", pageShareUrl)
-}
\ No newline at end of file
+}