Merge branch 'main' into main

This commit is contained in:
Patrick 2024-09-28 11:27:34 +02:00
commit 4669def4b1
7 changed files with 166 additions and 40 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()
}
}
@ -190,20 +197,6 @@ const InputOutputBackend: React.FC = () => {
await ffmpegRef.current.load()
}
}
const convertOggToWav = async (oggFile: File | Blob) => {
await loadFFmpeg()
const ffmpeg = ffmpegRef.current!
await ffmpeg.writeFile("input.ogg", await fetchFile(oggFile))
await ffmpeg.exec(["-i", "input.ogg", "output.wav"])
const wavData = await ffmpeg.readFile("output.wav")
console.log(wavData);
const wavBlob = new Blob([wavData], { type: "audio/wav" })
audioRef.current = URL.createObjectURL(wavBlob)
return wavBlob
}
const stopRecording = () => {
mediaRecorderRef.current?.stop()

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">

130
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "interstellar_ai",
"version": "0.1.0",
"version": "0.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "interstellar_ai",
"version": "0.1.0",
"version": "0.2.0",
"dependencies": {
"@ffmpeg/core-mt": "^0.12.6",
"@ffmpeg/ffmpeg": "^0.12.10",
@ -16,11 +16,16 @@
"axios": "^1.7.7",
"electron": "^32.1.2",
"fs": "^0.0.1-security",
"is-even": "^1.0.0",
"is-odd": "^3.0.1",
"math": "^0.0.3",
"next": "14.2.12",
"ollama": "^0.5.9",
"react": "^18",
"react-dom": "^18",
"react-router-dom": "^6.26.2"
"react-router-dom": "^6.26.2",
"swiss": "^2.4.0",
"weather": "^1.0.4"
},
"devDependencies": {
"@types/node": "^20",
@ -1403,6 +1408,15 @@
],
"license": "CC-BY-4.0"
},
"node_modules/centra": {
"version": "2.7.0",
"resolved": "https://registry.npmjs.org/centra/-/centra-2.7.0.tgz",
"integrity": "sha512-PbFMgMSrmgx6uxCdm57RUos9Tc3fclMvhLSATYN39XsDV29B89zZ3KA89jmY0vwSGazyU+uerqwa6t+KaodPcg==",
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
@ -3310,6 +3324,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-buffer": {
"version": "1.1.6",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
"integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
"license": "MIT"
},
"node_modules/is-bun-module": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/is-bun-module/-/is-bun-module-1.2.1.tgz",
@ -3381,6 +3401,42 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-even": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-even/-/is-even-1.0.0.tgz",
"integrity": "sha512-LEhnkAdJqic4Dbqn58A0y52IXoHWlsueqQkKfMfdEnIYG8A1sm/GHidKkS6yvXlMoRrkM34csHnXQtOqcb+Jzg==",
"license": "MIT",
"dependencies": {
"is-odd": "^0.1.2"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-even/node_modules/is-number": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz",
"integrity": "sha512-4cboCqIpliH+mAvFNegjZQ4kgKc3ZUhQVr3HvWbSh5q3WH2v82ct+T2Y1hdU5Gdtorx/cLifQjqCbL7bpznLTg==",
"license": "MIT",
"dependencies": {
"kind-of": "^3.0.2"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-even/node_modules/is-odd": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/is-odd/-/is-odd-0.1.2.tgz",
"integrity": "sha512-Ri7C2K7o5IrUU9UEI8losXJCCD/UtsaIrkR5sxIcFg4xQ9cRJXlWA5DQvTE0yDc0krvSNLsRGXN11UPS6KyfBw==",
"license": "MIT",
"dependencies": {
"is-number": "^3.0.0"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@ -3495,6 +3551,27 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/is-odd": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/is-odd/-/is-odd-3.0.1.tgz",
"integrity": "sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA==",
"license": "MIT",
"dependencies": {
"is-number": "^6.0.0"
},
"engines": {
"node": ">=4"
}
},
"node_modules/is-odd/node_modules/is-number": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-6.0.0.tgz",
"integrity": "sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-path-inside": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz",
@ -3792,6 +3869,18 @@
"json-buffer": "3.0.1"
}
},
"node_modules/kind-of": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz",
"integrity": "sha512-NOW9QQXMoZGg/oqnVNoNTTIFEIid1627WCffUBJEdMxYApq7mNE7CpzucIPc+ZQg25Phej7IJSmX3hO+oblOtQ==",
"license": "MIT",
"dependencies": {
"is-buffer": "^1.1.5"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/language-subtag-registry": {
"version": "0.3.23",
"resolved": "https://registry.npmjs.org/language-subtag-registry/-/language-subtag-registry-0.3.23.tgz",
@ -3907,6 +3996,14 @@
"node": ">=10"
}
},
"node_modules/math": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/math/-/math-0.0.3.tgz",
"integrity": "sha512-xyNJxsEwpYBabFmCgwg7TFRljf5oGgV2h1TqP0H9RnykScaSKgoVlBaEz+Gov8NOdxFagoTzRg1aEBfayi8qQQ==",
"engines": {
"node": "> 0.0.0"
}
},
"node_modules/merge2": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz",
@ -4405,6 +4502,18 @@
"integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==",
"license": "MIT"
},
"node_modules/phin": {
"version": "3.7.1",
"resolved": "https://registry.npmjs.org/phin/-/phin-3.7.1.tgz",
"integrity": "sha512-GEazpTWwTZaEQ9RhL7Nyz0WwqilbqgLahDM3D0hxWwmVDI52nXEybHqiN6/elwpkJBhcuj+WbBu+QfT0uhPGfQ==",
"license": "MIT",
"dependencies": {
"centra": "^2.7.0"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/picocolors": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz",
@ -5508,6 +5617,12 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/swiss": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/swiss/-/swiss-2.4.0.tgz",
"integrity": "sha512-XGm/tENVKsBr7JvqjIPJX1hYkklkGm5I8IkcvuSW1tWzWOpcxYnFzJdPeaFBS/e9UpV5pMw/NQ7sTBwfieeFQw==",
"license": "MIT"
},
"node_modules/tailwindcss": {
"version": "3.4.12",
"resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.12.tgz",
@ -5803,6 +5918,15 @@
"dev": true,
"license": "MIT"
},
"node_modules/weather": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/weather/-/weather-1.0.4.tgz",
"integrity": "sha512-6K4jGKz0Hr5Lsc0UgencI2218kSJsiPahW0VJ/PzblEA0uTNv4AgNyebQUW8vqy2y+Pm3VHMTCkTCrnSe8PeKQ==",
"license": "GPL-3.0-or-later",
"dependencies": {
"phin": "^3.4.0"
}
},
"node_modules/whatwg-fetch": {
"version": "3.6.20",
"resolved": "https://registry.npmjs.org/whatwg-fetch/-/whatwg-fetch-3.6.20.tgz",

View file

@ -19,11 +19,16 @@
"axios": "^1.7.7",
"electron": "^32.1.2",
"fs": "^0.0.1-security",
"is-even": "^1.0.0",
"is-odd": "^3.0.1",
"math": "^0.0.3",
"next": "14.2.12",
"ollama": "^0.5.9",
"react": "^18",
"react-dom": "^18",
"react-router-dom": "^6.26.2"
"react-router-dom": "^6.26.2",
"swiss": "^2.4.0",
"weather": "^1.0.4"
},
"devDependencies": {
"@types/node": "^20",

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