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 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 [copyClicked, setCopyClicked] = useState(false)
const [accessToken, setAccessToken] = useState("") const [accessToken, setAccessToken] = useState("")
const postWorkerRef = useRef<Worker | null>(null) const postWorkerRef = useRef<Worker | null>(null)
const getWorkerRef = 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 [liveMessage, setLiveMessage] = useState("")
const [inputMessage, setInputMessage] = useState<string>("") const [inputMessage, setInputMessage] = useState<string>("")
const [inputDisabled, setInputDisabled] = useState(false) 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(() => { useEffect(() => {
@ -149,7 +156,7 @@ const InputOutputBackend: React.FC = () => {
if (postWorkerRef.current) { if (postWorkerRef.current) {
addMessage("user", inputValue) addMessage("user", inputValue)
console.log("input:", 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() startGetWorker()
} }
} }

View file

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

View file

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

View file

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