The settings are now changing the system prompt

This commit is contained in:
sageTheDM 2024-09-27 16:51:44 +02:00
parent deb1745788
commit 75f735e50a
5 changed files with 33 additions and 22 deletions

View file

@ -16,11 +16,25 @@ const InputOutputBackend: React.FC = () => {
content: string
}
/* Variables for System-prompt */
const [preferredCurrency, setPreferredCurrency] = useState(localStorage.getItem("preferredCurrency") || "")
const [preferredLanguage, setPreferredLanguage] = useState(localStorage.getItem("preferredLanguage") || "")
const [timeFormat, setTimeFormat] = useState(localStorage.getItem("timeFormat") || "")
const [preferredMeasurement, setPreferredMeasurement] = useState(localStorage.getItem("preferredMeasurement") || "")
const [timeZone, setTimeZone] = useState(localStorage.getItem("timeZone") || "")
const [dateFormat, setDateFormat] = useState(localStorage.getItem("dateFormat") || "")
const [copyClicked, setCopyClicked] = useState(false)
const [accessToken, setAccessToken] = useState("")
const postWorkerRef = useRef<Worker | null>(null)
const getWorkerRef = useRef<Worker | null>(null)
const [messages, setMessages] = useState<Message[]>([{ role: "assistant", content: "Hello! How can I help you?" }])
const [messages, setMessages] = useState<Message[]>([{ role: "system",
content: `You are in the timezone: ${timeZone}.
You use the time format ${timeFormat}.
You use the date format ${dateFormat} for all references of dates.
You use the ${preferredMeasurement} system. You use the currency ${preferredCurrency}.
You will anwser in ${preferredLanguage}.`
},{ role: "assistant", content: "Hello! How can I help you?" }])
const [liveMessage, setLiveMessage] = useState("")
const [inputMessage, setInputMessage] = useState<string>("")
const [inputDisabled, setInputDisabled] = useState(false)
@ -127,13 +141,6 @@ const InputOutputBackend: React.FC = () => {
});
};
/* Variables for System-prompt */
const [preferredCurrency, setPreferredCurrency] = useState(localStorage.getItem("preferredCurrency") || "")
const [preferredLanguage, setPreferredLanguage] = useState(localStorage.getItem("preferredLanguage") || "")
const [timeFormat, setTimeFormat] = useState(localStorage.getItem("timeFormat") || "")
const [preferredMeasurement, setPreferredMeasurement] = useState(localStorage.getItem("preferredMeasurement") || "")
const [timeZone, setTimeZone] = useState(localStorage.getItem("timeZone") || "")
const [dateFormat, setDateFormat] = useState(localStorage.getItem("dateFormat") || "")
useEffect(() => {
@ -149,7 +156,7 @@ const InputOutputBackend: React.FC = () => {
if (postWorkerRef.current) {
addMessage("user", inputValue)
console.log("input:", inputValue);
postWorkerRef.current.postMessage({ messages: [...messages, { role: "user", content: inputValue }], ai_model: "phi3.5", access_token: accessToken })
postWorkerRef.current.postMessage({ messages: [...messages, { role: "user", content: inputValue }], ai_model: "llama3.2", access_token: accessToken })
startGetWorker()
}
}

View file

@ -1,12 +1,12 @@
import axios from "axios";
onmessage = (e) => {
const { messages = [{ role: "assistant", content: "Hello! How can I help you?" }], ai_model = "phi3.5", access_token } = e.data
messages.unshift({ role: "system", content: "You are a Helpful assistant. you give short answers" })
const { messages, ai_model = "llama3.2", access_token } = e.data
const Message = {
messages: messages,
ai_model: "phi3.5",
ai_model: "llama3.2",
model_type: "local",
access_token: access_token
}

View file

@ -37,15 +37,19 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
if (message.role == "user") {
isUserMessage = message
}
return (
<div
key={index}
className={isUserMessage ? 'user-message' : 'ai-message'}
>
<p> {message.content}</p>
</div>
);
if (index >= 1){
return (
<div
key={index}
className={isUserMessage ? 'user-message' : 'ai-message'}
>
<p> {message.content}</p>
</div>
);
}
})}
{/* Dummy div to mark the end of the conversation for auto-scrolling */}
<div ref={endOfMessagesRef} />
<div className="button-container">

View file

@ -7,7 +7,7 @@ from db import DB
from weather import Weather
from voice import VoiceRecognition
from tts import TTS
class API:
def __init__(self):

View file

@ -13,6 +13,6 @@ python-weather
pycouchdb
pyttsx3
pip-licenses
openai-whisper
faster-whisper
pydub
ffmpeg