ai works again?

This commit is contained in:
YasinOnm08 2024-09-20 09:58:13 +02:00
parent 44cd249421
commit f9d3a1f235
2 changed files with 20 additions and 29 deletions

View file

@ -31,15 +31,14 @@ const InputOutputBackend: React.FC = () => {
role: string
content: string
}
type SystemPrompt = {
}
const handleSendClick = (message:string) => {
var system:Message = {role:"system" ,content:"You are a helpful assistant that gives short answers."}
var system:Message = {role:"system" ,content:"You are a helpful assistant."}
addMessage("user",message);
HandlePostRequest(messages, "phi3.5", system)
addMessage("user", message);
console.log("added User Message")
HandlePostRequest([...messages, { role: "user", content: message }], "phi3.5", system);
};
const [messages, setMessages] = useState([
@ -65,21 +64,12 @@ const InputOutputBackend: React.FC = () => {
}
}
},[])
const HandleGetRequest = (messages: Message[], ai_model: string, system_prompt: Message) => {
if (workerRef.current) {
workerRef.current.postMessage({ functionName: "getResponse", access_token: accessToken, messages: messages, ai_model: ai_model, system_prompt: system_prompt })
workerRef.current.onmessage = (e) => {
addMessage("assistant",e.data)
}
}
}
const HandlePostRequest = (messages: Message[], ai_model: string, system_prompt: Message) => {
if (workerRef.current) {
const HandlePostRequest = (messages: Message[], ai_model: string, system_prompt: Message) => {
if (workerRef.current) {
workerRef.current.postMessage({ functionName: "postRequest", access_token: accessToken, messages: messages, ai_model: ai_model, system_prompt: system_prompt })
workerRef.current.onmessage = (e) => {
HandleGetRequest(messages,ai_model,system_prompt)
addMessage("assistant",e.data)
}
}
}