diff --git a/.gitignore b/.gitignore index e079e0c2..0218a68c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,164 +1,166 @@ -# ALL -*.dev - -# for server -server/models/* -!server/models/download.sh -!server/models/download.ps1 -server/logs/ -server/models_dev -server/public/* -!server/public/examples/ -server/public/examples/* -!server/public/examples/a.jpg -!server/public/examples/b.jpg -!server/public/examples/c.jpg -!server/public/examples/d.jpg -!server/public/examples/e.jpg -!server/public/examples/f.jpg -!server/public/examples/g.jpg - -# docker -Dockerfile -docker-compose.yml - -# for gradio -# server/run_gradio.py - -# for web -web/node_modules -web/package-lock.json -web/dist -web/electron-dist -web/yarn.lock - -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ - +# ALL +*.dev + +# for server +server/models/* +!server/models/download.sh +!server/models/download.ps1 +server/logs/ +server/models_dev +server/public/* +!server/public/examples/ +server/public/examples/* +!server/public/examples/a.jpg +!server/public/examples/b.jpg +!server/public/examples/c.jpg +!server/public/examples/d.jpg +!server/public/examples/e.jpg +!server/public/examples/f.jpg +!server/public/examples/g.jpg + +# docker +Dockerfile +docker-compose.yml + +# for gradio +# server/run_gradio.py + +# for web +web/node_modules +web/package-lock.json +web/dist +web/electron-dist +web/yarn.lock + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + + +.fake \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..826e6d83 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,29 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "intelliSenseMode": "windows-msvc-x64" + }, + { + "name": "addto", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "intelliSenseMode": "windows-msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..2aecb365 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,13 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations. + // Extension identifier format: ${publisher}.${name}. Example: vscode.csharp + + // List of extensions which should be recommended for users of this workspace. + "recommendations": [ + "ms-python.python" + ], + // List of extensions recommended by VS Code that should not be recommended for users of this workspace. + "unwantedRecommendations": [ + + ] +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..bbe5f28e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,21 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + configurations + version + aiquickfix + 9yDfO4XT9GIEG6MlGGviT3BlbkFJgUscuenOlN8oaC5eRgDu + { + "type": "bmasm", + "request": "launch", + "name": "Debug Application", + "program": "${workspaceFolder}/${command:AskForProgramName}", + "stopOnEntry": true, + "debugArgs": [], + "cwd": "${workspaceRoot}" + } + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..42798c5e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "cmake", + "label": "CMake: clean", + "command": "clean", + "problemMatcher": [], + "detail": "CMake template clean task", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/server/.vscode/c_cpp_properties.json b/server/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..cea4d3f4 --- /dev/null +++ b/server/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "windows-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/server/.vscode/launch.json b/server/.vscode/launch.json new file mode 100644 index 00000000..67491359 --- /dev/null +++ b/server/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": "c:/Users/mindy/OneDrive/build/JARVIS/server", + "program": "c:/Users/mindy/OneDrive/build/JARVIS/server/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/server/.vscode/settings.json b/server/.vscode/settings.json new file mode 100644 index 00000000..65c81b62 --- /dev/null +++ b/server/.vscode/settings.json @@ -0,0 +1,38 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wconversion", + "-Wnull-dereference", + "-Wsign-conversion" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false +} \ No newline at end of file diff --git a/web - Shortcut.lnk b/web - Shortcut.lnk new file mode 100644 index 00000000..cfaacfb7 Binary files /dev/null and b/web - Shortcut.lnk differ diff --git a/web/electron/.vscode/c_cpp_properties.json b/web/electron/.vscode/c_cpp_properties.json new file mode 100644 index 00000000..cea4d3f4 --- /dev/null +++ b/web/electron/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "windows-gcc-x64", + "includePath": [ + "${workspaceFolder}/**" + ], + "compilerPath": "gcc", + "cStandard": "${default}", + "cppStandard": "${default}", + "intelliSenseMode": "windows-gcc-x64", + "compilerArgs": [ + "" + ] + } + ], + "version": 4 +} \ No newline at end of file diff --git a/web/electron/.vscode/launch.json b/web/electron/.vscode/launch.json new file mode 100644 index 00000000..2d97bb34 --- /dev/null +++ b/web/electron/.vscode/launch.json @@ -0,0 +1,46 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Remote Attach", + "type": "python", + "request": "attach", + "connect": { + "host": "localhost", + "port": 5678 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "." + } + ], + "justMyCode": true + },all right you guys we'll go work on this shed OK go work on the shed if he cries too much I'll come grab { + "type": "java", + "name": "Attach to Remote Program", + "request": "attach", + "hostName": "", + "port": "" + }, + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": "c:/Users/mindy/OneDrive/build/JARVIS/web/electron", + "program": "c:/Users/mindy/OneDrive/build/JARVIS/web/electron/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/web/electron/.vscode/settings.json b/web/electron/.vscode/settings.json new file mode 100644 index 00000000..a9632062 --- /dev/null +++ b/web/electron/.vscode/settings.json @@ -0,0 +1,41 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "main" + ], + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wconversion", + "-Wnull-dereference", + "-Wsign-conversion" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false +} \ No newline at end of file diff --git a/web/src/views/home.vue b/web/src/views/home.vue index 2a8336ce..a99c13e5 100644 --- a/web/src/views/home.vue +++ b/web/src/views/home.vue @@ -44,7 +44,7 @@ async function sendChatMessage() { ) clearMessageContent(); - const clean_messages: CleanChatMessage[] = [] + var clean_messages: CleanChatMessage[] = [] for (let message of messageList.value) { if (message.first && message.role != "system") { clean_messages.push({role: message.role, content: message.content}) @@ -53,11 +53,12 @@ async function sendChatMessage() { messageList.value.push( { role: "assistant", content: "", type: "text", first: true}, ) + if (isChatgpt.value) { + var { status, data } = await chatgpt(clean_messages, loadConfig(), dev.value); + } else { + var { status, data } = await hugginggpt(clean_messages, loadConfig(), dev.value); + } - const { status, data, message } = isChatgpt.value - ? await chatgpt(clean_messages, loadConfig(), dev.value) - : await hugginggpt(clean_messages, loadConfig(), dev.value); - messageList.value.pop() if (status === "success" ) { if (data) { @@ -79,25 +80,28 @@ async function sendChatMessage() { const messageListMM = computed(() => { - const messageListMM: ChatMessage[] = [] - for (let i = 0; i < messageList.value.length; i++) { - let message = messageList.value[i] + var messageListMM: ChatMessage[] = [] + for (var i = 0; i < messageList.value.length; i++) { + var message = messageList.value[i] if (message.type != "text") { messageListMM.push(message) continue } - let { role, content } = message; + var content = message.content + var role = message.role - const image_urls = content.match(/(http(s?):|\/)([/|.|\S||\w|:|-])*?\.(?:jpg|jpeg|tiff|gif|png)/g) - const image_reg = new RegExp(/(http(s?):|\/)([/|.|\S|\w|:|-])*?\.(?:jpg|jpeg|tiff|gif|png)/g) + var image_urls = content.match(/(http(s?):|\/)([/|.|\S||\w|:|-])*?\.(?:jpg|jpeg|tiff|gif|png)/g) + var image_reg = new RegExp(/(http(s?):|\/)([/|.|\S|\w|:|-])*?\.(?:jpg|jpeg|tiff|gif|png)/g) - let orig_content = content - let image_seq_added_accum = 0 + var orig_content = content + var seq_added_accum = 0 if (image_urls){ - for (let j = 0; j < image_urls.length; j++) { + for (var j = 0; j < image_urls.length; j++) { // @ts-ignore - let start = image_reg.exec(orig_content).index + image_seq_added_accum - let end = start + image_urls[j].length + image_seq_added_accum + var start = image_reg.exec(orig_content).index + var end = start + image_urls[j].length + start += seq_added_accum + end += seq_added_accum const replace_str = ` @@ -105,7 +109,7 @@ const messageListMM = computed(() => { ` const rep_length = replace_str.length - image_seq_added_accum += (rep_length - image_urls[j].length) + seq_added_accum += (rep_length - image_urls[j].length) content = content.slice(0, start) + replace_str + content.slice(end) if(!image_urls[j].startsWith("http")){ @@ -115,15 +119,17 @@ const messageListMM = computed(() => { } orig_content = content - const audio_urls = content.match(/(http(s?):|\/)([/|.|\w|\S|:|-])*?\.(?:flac|wav)/g) - const audio_reg = new RegExp(/(http(s?):|\/)([/|.|\w|\S|:|-])*?\.(?:flac|wav)/g) + var audio_urls = content.match(/(http(s?):|\/)([/|.|\w|\S|:|-])*?\.(?:flac|wav)/g) + var audio_reg = new RegExp(/(http(s?):|\/)([/|.|\w|\S|:|-])*?\.(?:flac|wav)/g) - let audio_seq_added_accum = 0 - if (audio_urls) { - for (let j = 0; j < audio_urls.length; j++) { + var seq_added_accum = 0 + if (audio_urls){ + for (var j = 0; j < audio_urls.length; j++) { // @ts-ignore - let start = audio_reg.exec(orig_content).index + audio_seq_added_accum - let end = start + audio_urls[j].length + audio_seq_added_accum + var start = audio_reg.exec(orig_content).index + var end = start + audio_urls[j].length + start += seq_added_accum + end += seq_added_accum const replace_str = ` @@ -131,7 +137,7 @@ const messageListMM = computed(() => { ` const rep_length = replace_str.length - audio_seq_added_accum += (rep_length - audio_urls[j].length) + seq_added_accum += (rep_length - audio_urls[j].length) content = content.slice(0, start) + replace_str + content.slice(end) if(!audio_urls[j].startsWith("http")){ @@ -141,17 +147,17 @@ const messageListMM = computed(() => { } orig_content = content - const video_urls = content.match(/(http(s?):|\/)([/|.|\w|\s|:|-])*?\.(?:mp4)/g) - const video_reg = new RegExp(/(http(s?):|\/)([/|.|\w|\s|:|-])*?\.(?:mp4)/g) + var video_urls = content.match(/(http(s?):|\/)([/|.|\w|\s|:|-])*?\.(?:mp4)/g) + var video_reg = new RegExp(/(http(s?):|\/)([/|.|\w|\s|:|-])*?\.(?:mp4)/g) - let video_seq_added_accum = 0 + var seq_added_accum = 0 if (video_urls){ - for (let j = 0; j < video_urls.length; j++) { + for (var j = 0; j < video_urls.length; j++) { // @ts-ignore - let start = video_reg.exec(orig_content).index - let end = start + video_urls[j].length - start += video_seq_added_accum - end += video_seq_added_accum + var start = video_reg.exec(orig_content).index + var end = start + video_urls[j].length + start += seq_added_accum + end += seq_added_accum const replace_str = ` @@ -159,7 +165,7 @@ const messageListMM = computed(() => { ` const rep_length = replace_str.length - video_seq_added_accum += (rep_length - video_urls[j].length) + seq_added_accum += (rep_length - video_urls[j].length) content = content.slice(0, start) + replace_str + content.slice(end) if(!video_urls[j].startsWith("http")){ @@ -178,22 +184,23 @@ const messageListMM = computed(() => { // @ts-ignore video_urls = [...new Set(video_urls)] if (image_urls) { - for (let j = 0; j < image_urls.length; j++) { + + for (var j = 0; j < image_urls.length; j++) { messageListMM.push({role: role, content: image_urls[j], type: "image", first: false}) } } if (audio_urls) { - for (let j = 0; j < audio_urls.length; j++) { + for (var j = 0; j < audio_urls.length; j++) { messageListMM.push({role: role, content: audio_urls[j], type: "audio", first: false}) } } if (video_urls) { - for (let j = 0; j < video_urls.length; j++) { + for (var j = 0; j < video_urls.length; j++) { messageListMM.push({role: role, content: video_urls[j], type: "video", first: false}) } } // if (code_blocks){ - // for (let j = 0; j < code_blocks.length; j++) { + // for (var j = 0; j < code_blocks.length; j++) { // messageListMM.push({role: role, content: code_blocks[j], type: "code", first: false}) // } // }