Add Sidepanel Settings Body component and update button styles in EmptySidePanel component

This commit is contained in:
n4ze3m
2024-02-04 00:56:42 +05:30
parent be3a4ed256
commit 5958e10354
9 changed files with 271 additions and 32 deletions

View File

@@ -7,6 +7,11 @@ const storage = new Storage()
const DEFAULT_OLLAMA_URL = "http://127.0.0.1:11434"
const DEFAULT_ASK_FOR_MODEL_SELECTION_EVERY_TIME = true
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:`
export const getOllamaURL = async () => {
const ollamaURL = await storage.get("ollamaURL")
if (!ollamaURL || ollamaURL.length === 0) {
@@ -83,3 +88,36 @@ export const systemPromptForNonRag = async () => {
const prompt = await storage.get("systemPromptForNonRag")
return prompt
}
export const promptForRag = async () => {
const prompt = await storage.get("systemPromptForRag")
const questionPrompt = await storage.get("questionPromptForRag")
let ragPrompt = prompt
let ragQuestionPrompt = questionPrompt
if (!ragPrompt || ragPrompt.length === 0) {
ragPrompt = DEFAUTL_RAG_SYSTEM_PROMPT
}
if (!ragQuestionPrompt || ragQuestionPrompt.length === 0) {
ragQuestionPrompt = DEFAULT_RAG_QUESTION_PROMPT
}
return {
ragPrompt,
ragQuestionPrompt
}
}
export const setSystemPromptForNonRag = async (prompt: string) => {
await storage.set("systemPromptForNonRag", prompt)
}
export const setPromptForRag = async (
prompt: string,
questionPrompt: string
) => {
await storage.set("systemPromptForRag", prompt)
await storage.set("questionPromptForRag", questionPrompt)
}