forked from React-Group/interstellar_ai
Compare commits
No commits in common. "5cdea21cea5aff753f9f3ccdb2eeef356ab5247f" and "f8e2706d33739e516cba8eeb42d235177d7ee80f" have entirely different histories.
5cdea21cea
...
f8e2706d33
7 changed files with 156 additions and 197 deletions
|
@ -1,13 +1,13 @@
|
||||||
import React, { ForwardedRef, useState, useEffect, useRef } from 'react';
|
import React, { ForwardedRef, useState, useEffect, useRef } from 'react';
|
||||||
import Markdown from 'react-markdown';
|
import Markdown from 'react-markdown'
|
||||||
import rehypeRaw from 'rehype-raw';
|
import rehypeRaw from 'rehype-raw';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
import { useChatHistory } from '../hooks/useChatHistory';
|
import { useChatHistory } from '../hooks/useChatHistory';
|
||||||
|
|
||||||
type Message = {
|
type Message = {
|
||||||
role: string;
|
role: string
|
||||||
content: string;
|
content: string
|
||||||
};
|
}
|
||||||
|
|
||||||
interface ConversationProps {
|
interface ConversationProps {
|
||||||
messages: Message[];
|
messages: Message[];
|
||||||
|
@ -15,7 +15,7 @@ interface ConversationProps {
|
||||||
onResendClick: () => void;
|
onResendClick: () => void;
|
||||||
onEditClick: () => void;
|
onEditClick: () => void;
|
||||||
onCopyClick: () => void;
|
onCopyClick: () => void;
|
||||||
isClicked: boolean;
|
isClicked: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>(
|
const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>(
|
||||||
|
@ -28,14 +28,16 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
|
||||||
const observer = new IntersectionObserver(
|
const observer = new IntersectionObserver(
|
||||||
(entries) => {
|
(entries) => {
|
||||||
if (entries[0].isIntersecting) {
|
if (entries[0].isIntersecting) {
|
||||||
|
console.log('End of messages reached');
|
||||||
setIsScrolling(true);
|
setIsScrolling(true);
|
||||||
} else {
|
} else {
|
||||||
|
console.log('End of messages not reached');
|
||||||
setIsScrolling(false);
|
setIsScrolling(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
root: document.querySelector('.output'),
|
root: document.querySelector('.output'),
|
||||||
threshold: 1.0,
|
threshold: 1.0, // Ensure the whole element is visible
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -51,6 +53,7 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
|
||||||
};
|
};
|
||||||
}, [messages]);
|
}, [messages]);
|
||||||
|
|
||||||
|
// Scroll to bottom when new messages arrive
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isScrolling) {
|
if (isScrolling) {
|
||||||
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
messagesEndRef.current?.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
@ -62,6 +65,7 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
|
||||||
<div className="conversation resize" id="conversation">
|
<div className="conversation resize" id="conversation">
|
||||||
{chatHistory.chats[chatHistory.selectedIndex].messages.map((message, index) => {
|
{chatHistory.chats[chatHistory.selectedIndex].messages.map((message, index) => {
|
||||||
if (index >= 1) {
|
if (index >= 1) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
|
@ -73,9 +77,8 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return null; // Ensure to return null for the first message or if condition is not met
|
|
||||||
})}
|
})}
|
||||||
<div ref={messagesEndRef} />
|
|
||||||
<div className="button-container">
|
<div className="button-container">
|
||||||
<div className="tooltip">
|
<div className="tooltip">
|
||||||
<button type="button" onClick={onStopClick}>
|
<button type="button" onClick={onStopClick}>
|
||||||
|
@ -107,7 +110,6 @@ const ConversationFrontend = React.forwardRef<HTMLDivElement, ConversationProps>
|
||||||
<svg style={{ fill: "var(--text-color)" }} viewBox="0 0 384 512" height={30}><path d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" /></svg>
|
<svg style={{ fill: "var(--text-color)" }} viewBox="0 0 384 512" height={30}><path d="M169.4 470.6c12.5 12.5 32.8 12.5 45.3 0l160-160c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L224 370.8 224 64c0-17.7-14.3-32-32-32s-32 14.3-32 32l0 306.7L54.6 265.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l160 160z" /></svg>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -125,5 +125,4 @@ header {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left: 10vw;
|
left: 10vw;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
padding: 10px;
|
|
||||||
}
|
}
|
|
@ -35,7 +35,6 @@
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
max-width: 75%;
|
max-width: 75%;
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
overflow-wrap: break-word;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.user-message {
|
.user-message {
|
||||||
|
@ -55,20 +54,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.ai-message table{
|
.ai-message table{
|
||||||
display: block; /* Treat the table as a block element */
|
|
||||||
position: relative;
|
|
||||||
overflow-x: auto; /* Allow horizontal scrolling */
|
|
||||||
white-space: nowrap; /* Prevent table content from wrapping */
|
|
||||||
border: 1px solid var(--ai-message-text-color);
|
border: 1px solid var(--ai-message-text-color);
|
||||||
border-collapse: collapse;
|
border-collapse: collapse;
|
||||||
background-color: var(--conversation-background-color);
|
background-color: var(--conversation-background-color);
|
||||||
max-width: 100%; /* Ensure the table doesn't exceed the container width */
|
|
||||||
padding: 10px; /* Optional: Add padding similar to pre/code */
|
|
||||||
border-radius: 4px; /* Optional: Add border radius similar to pre/code */
|
|
||||||
margin-top: 5px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.ai-message th{
|
.ai-message th{
|
||||||
background-color: var(--user-message-background-color);
|
background-color: var(--user-message-background-color);
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
@ -92,14 +82,9 @@
|
||||||
margin-left: 1em;
|
margin-left: 1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ai-message code, .ai-message pre {
|
.ai-message code{
|
||||||
overflow-x: auto;
|
width: 100%;
|
||||||
white-space: pre;
|
overflow: scroll;
|
||||||
display: block;
|
|
||||||
max-width: 100%;
|
|
||||||
padding: 10px;
|
|
||||||
background-color: var(--code-background-color);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Button Container */
|
/* Button Container */
|
||||||
|
@ -138,12 +123,17 @@
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
font-size: calc(var(--font-size)*0.8);
|
font-size: calc(var(--font-size)*0.8);
|
||||||
|
|
||||||
|
/* Position the tooltip */
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 100%;
|
top: 100%;
|
||||||
|
/* Adjusts tooltip to be below the button */
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
|
/* Center the tooltip */
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
/* Prevent line breaks */
|
||||||
|
|
||||||
|
/* Add smooth transition */
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: all 0.3s;
|
transition: all 0.3s;
|
||||||
}
|
}
|
||||||
|
@ -152,6 +142,7 @@
|
||||||
content: "";
|
content: "";
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 100%;
|
bottom: 100%;
|
||||||
|
/* Arrow on top of tooltip */
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translateX(-50%);
|
transform: translateX(-50%);
|
||||||
border-width: 5px;
|
border-width: 5px;
|
||||||
|
@ -159,6 +150,7 @@
|
||||||
border-color: transparent transparent var(--user-message-background-color) transparent;
|
border-color: transparent transparent var(--user-message-background-color) transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Show the tooltip on hover */
|
||||||
.tooltip:hover .tooltiptext {
|
.tooltip:hover .tooltiptext {
|
||||||
visibility: visible;
|
visibility: visible;
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
You will need to make three folders:
|
You will need to make three folders:
|
||||||
|
|
||||||
node-bin - contains nodejs portable
|
node-bin - contains nodejs portable
|
||||||
python-bin - contains python3 portable - don't forget to add the .pth file and adjust it accordingly, because import site is normally missing. -- also put your python files in here too, else it will not run!
|
python-bin - contains python3 portable - don't forget to add the .pth file and adjust it accordingly, because import site is normally missing.
|
||||||
ollama.bin - contains ollama portable
|
ollama.bin - contains ollama portable
|
||||||
|
|
||||||
you also need vc redist 2019
|
you also need vc redist 2019
|
|
@ -1,4 +1,4 @@
|
||||||
python312.zip
|
python313.zip
|
||||||
.
|
.
|
||||||
|
|
||||||
# Uncomment to run site.main() automatically
|
# Uncomment to run site.main() automatically
|
133
package-lock.json
generated
133
package-lock.json
generated
|
@ -685,9 +685,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "20.16.11",
|
"version": "20.16.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.11.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.16.10.tgz",
|
||||||
"integrity": "sha512-y+cTCACu92FyA5fgQSAI8A1H429g7aSK2HsO7K4XYUWc4dY5IUz55JSDIYT6/VsOLfGy8vmvQYC2hfb0iF16Uw==",
|
"integrity": "sha512-vQUKgWTjEIRFCvK6CyriPH3MZYiYlNy0fKiEYHWbcoWLEgs4opurGGKlebrTLqdSMIbXImH6XExNiIyNUv3WpA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~6.19.2"
|
"undici-types": "~6.19.2"
|
||||||
|
@ -700,9 +700,9 @@
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@types/react": {
|
"node_modules/@types/react": {
|
||||||
"version": "18.3.11",
|
"version": "18.3.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.11.tgz",
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.10.tgz",
|
||||||
"integrity": "sha512-r6QZ069rFTjrEYgFdOck1gK7FLVsgJE7tTz0pQBczlBNUhBNk0MQH4UbnFSwjpQLMkLzgqvBBa+qGpLje16eTQ==",
|
"integrity": "sha512-02sAAlBnP39JgXwkAq3PeU9DVaaGpZyF3MGcC0MKgQVkZor5IiiDAipVaxQHtDJAmO4GIy/rVBy/LzVj76Cyqg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/prop-types": "*",
|
"@types/prop-types": "*",
|
||||||
|
@ -745,17 +745,17 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.8.0.tgz",
|
||||||
"integrity": "sha512-xfvdgA8AP/vxHgtgU310+WBnLB4uJQ9XdyP17RebG26rLtDrQJV3ZYrcopX91GrHmMoH8bdSwMRh2a//TiJ1jQ==",
|
"integrity": "sha512-wORFWjU30B2WJ/aXBfOm1LX9v9nyt9D3jsSOxC3cCaTQGCW5k4jNpmjFv3U7p/7s4yvdjHzwtv2Sd2dOyhjS0A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/regexpp": "^4.10.0",
|
"@eslint-community/regexpp": "^4.10.0",
|
||||||
"@typescript-eslint/scope-manager": "8.8.1",
|
"@typescript-eslint/scope-manager": "8.8.0",
|
||||||
"@typescript-eslint/type-utils": "8.8.1",
|
"@typescript-eslint/type-utils": "8.8.0",
|
||||||
"@typescript-eslint/utils": "8.8.1",
|
"@typescript-eslint/utils": "8.8.0",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1",
|
"@typescript-eslint/visitor-keys": "8.8.0",
|
||||||
"graphemer": "^1.4.0",
|
"graphemer": "^1.4.0",
|
||||||
"ignore": "^5.3.1",
|
"ignore": "^5.3.1",
|
||||||
"natural-compare": "^1.4.0",
|
"natural-compare": "^1.4.0",
|
||||||
|
@ -779,16 +779,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/parser": {
|
"node_modules/@typescript-eslint/parser": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.8.0.tgz",
|
||||||
"integrity": "sha512-hQUVn2Lij2NAxVFEdvIGxT9gP1tq2yM83m+by3whWFsWC+1y8pxxxHUFE1UqDu2VsGi2i6RLcv4QvouM84U+ow==",
|
"integrity": "sha512-uEFUsgR+tl8GmzmLjRqz+VrDv4eoaMqMXW7ruXfgThaAShO9JTciKpEsB+TvnfFfbg5IpujgMXVV36gOJRLtZg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/scope-manager": "8.8.1",
|
"@typescript-eslint/scope-manager": "8.8.0",
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.8.0",
|
||||||
"@typescript-eslint/typescript-estree": "8.8.1",
|
"@typescript-eslint/typescript-estree": "8.8.0",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1",
|
"@typescript-eslint/visitor-keys": "8.8.0",
|
||||||
"debug": "^4.3.4"
|
"debug": "^4.3.4"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -808,14 +808,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/scope-manager": {
|
"node_modules/@typescript-eslint/scope-manager": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.8.0.tgz",
|
||||||
"integrity": "sha512-X4JdU+66Mazev/J0gfXlcC/dV6JI37h+93W9BRYXrSn0hrE64IoWgVkO9MSJgEzoWkxONgaQpICWg8vAN74wlA==",
|
"integrity": "sha512-EL8eaGC6gx3jDd8GwEFEV091210U97J0jeEHrAYvIYosmEGet4wJ+g0SYmLu+oRiAwbSA5AVrt6DxLHfdd+bUg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.8.0",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1"
|
"@typescript-eslint/visitor-keys": "8.8.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
@ -826,14 +826,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/type-utils": {
|
"node_modules/@typescript-eslint/type-utils": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.8.0.tgz",
|
||||||
"integrity": "sha512-qSVnpcbLP8CALORf0za+vjLYj1Wp8HSoiI8zYU5tHxRVj30702Z1Yw4cLwfNKhTPWp5+P+k1pjmD5Zd1nhxiZA==",
|
"integrity": "sha512-IKwJSS7bCqyCeG4NVGxnOP6lLT9Okc3Zj8hLO96bpMkJab+10HIfJbMouLrlpyOr3yrQ1cA413YPFiGd1mW9/Q==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/typescript-estree": "8.8.1",
|
"@typescript-eslint/typescript-estree": "8.8.0",
|
||||||
"@typescript-eslint/utils": "8.8.1",
|
"@typescript-eslint/utils": "8.8.0",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"ts-api-utils": "^1.3.0"
|
"ts-api-utils": "^1.3.0"
|
||||||
},
|
},
|
||||||
|
@ -851,9 +851,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/types": {
|
"node_modules/@typescript-eslint/types": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.8.0.tgz",
|
||||||
"integrity": "sha512-WCcTP4SDXzMd23N27u66zTKMuEevH4uzU8C9jf0RO4E04yVHgQgW+r+TeVTNnO1KIfrL8ebgVVYYMMO3+jC55Q==",
|
"integrity": "sha512-QJwc50hRCgBd/k12sTykOJbESe1RrzmX6COk8Y525C9l7oweZ+1lw9JiU56im7Amm8swlz00DRIlxMYLizr2Vw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -865,14 +865,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/typescript-estree": {
|
"node_modules/@typescript-eslint/typescript-estree": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.8.0.tgz",
|
||||||
"integrity": "sha512-A5d1R9p+X+1js4JogdNilDuuq+EHZdsH9MjTVxXOdVFfTJXunKJR/v+fNNyO4TnoOn5HqobzfRlc70NC6HTcdg==",
|
"integrity": "sha512-ZaMJwc/0ckLz5DaAZ+pNLmHv8AMVGtfWxZe/x2JVEkD5LnmhWiQMMcYT7IY7gkdJuzJ9P14fRy28lUrlDSWYdw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.8.0",
|
||||||
"@typescript-eslint/visitor-keys": "8.8.1",
|
"@typescript-eslint/visitor-keys": "8.8.0",
|
||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"fast-glob": "^3.3.2",
|
"fast-glob": "^3.3.2",
|
||||||
"is-glob": "^4.0.3",
|
"is-glob": "^4.0.3",
|
||||||
|
@ -933,16 +933,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/utils": {
|
"node_modules/@typescript-eslint/utils": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.8.0.tgz",
|
||||||
"integrity": "sha512-/QkNJDbV0bdL7H7d0/y0qBbV2HTtf0TIyjSDTvvmQEzeVx8jEImEbLuOA4EsvE8gIgqMitns0ifb5uQhMj8d9w==",
|
"integrity": "sha512-QE2MgfOTem00qrlPgyByaCHay9yb1+9BjnMFnSFkUKQfu7adBXDTnCAivURnuPPAG/qiB+kzKkZKmKfaMT0zVg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint-community/eslint-utils": "^4.4.0",
|
"@eslint-community/eslint-utils": "^4.4.0",
|
||||||
"@typescript-eslint/scope-manager": "8.8.1",
|
"@typescript-eslint/scope-manager": "8.8.0",
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.8.0",
|
||||||
"@typescript-eslint/typescript-estree": "8.8.1"
|
"@typescript-eslint/typescript-estree": "8.8.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
|
||||||
|
@ -956,13 +956,13 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@typescript-eslint/visitor-keys": {
|
"node_modules/@typescript-eslint/visitor-keys": {
|
||||||
"version": "8.8.1",
|
"version": "8.8.0",
|
||||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.8.0.tgz",
|
||||||
"integrity": "sha512-0/TdC3aeRAsW7MDvYRwEc1Uwm0TIBfzjPFgg60UU2Haj5qsCs9cc3zNgY71edqE3LbWfF/WoZQd3lJoDXFQpag==",
|
"integrity": "sha512-8mq51Lx6Hpmd7HnA2fcHQo3YgfX1qbccxQOgZcb4tvasu//zXRaA1j5ZRFeCw/VRAdFi4mRM9DnZw0Nu0Q2d1g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@typescript-eslint/types": "8.8.1",
|
"@typescript-eslint/types": "8.8.0",
|
||||||
"eslint-visitor-keys": "^3.4.3"
|
"eslint-visitor-keys": "^3.4.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
@ -1457,9 +1457,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/caniuse-lite": {
|
"node_modules/caniuse-lite": {
|
||||||
"version": "1.0.30001667",
|
"version": "1.0.30001664",
|
||||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001667.tgz",
|
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001664.tgz",
|
||||||
"integrity": "sha512-7LTwJjcRkzKFmtqGsibMeuXmvFDfZq/nzIjnmgCGzKKRVzjD72selLDK1oPF/Oxzmt4fNcPvTDvGqSDG4tCALw==",
|
"integrity": "sha512-AmE7k4dXiNKQipgn7a2xg558IRqPN3jMQY/rOsbxDhrd0tyChwbITBfiwtnqz8bi2M5mIWbxAYBvk7W7QBUS2g==",
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
"type": "opencollective",
|
"type": "opencollective",
|
||||||
|
@ -2256,7 +2256,6 @@
|
||||||
"version": "8.57.1",
|
"version": "8.57.1",
|
||||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.57.1.tgz",
|
||||||
"integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==",
|
"integrity": "sha512-ypowyDxpVSYpkXr9WPv2PAZCtNip1Mv5KTW0SCurXv/9iOpcrH9PaqUElksqEB6pChqHGDRCFTyrZlGhnLNGiA==",
|
||||||
"deprecated": "This version is no longer supported. Please see https://eslint.org/version-support for other options.",
|
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -2424,9 +2423,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-import": {
|
"node_modules/eslint-plugin-import": {
|
||||||
"version": "2.31.0",
|
"version": "2.30.0",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.31.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.30.0.tgz",
|
||||||
"integrity": "sha512-ixmkI62Rbc2/w8Vfxyh1jQRTdRTF52VxwRVHl/ykPAmqG+Nb7/kNn+byLP0LxPgI7zWA16Jt82SybJInmMia3A==",
|
"integrity": "sha512-/mHNE9jINJfiD2EKkg1BKyPyUk4zdnT54YgbOgfjSakWT5oyX/qQLVNTkehyfpcMxZXMy1zyonZ2v7hZTX43Yw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -2438,7 +2437,7 @@
|
||||||
"debug": "^3.2.7",
|
"debug": "^3.2.7",
|
||||||
"doctrine": "^2.1.0",
|
"doctrine": "^2.1.0",
|
||||||
"eslint-import-resolver-node": "^0.3.9",
|
"eslint-import-resolver-node": "^0.3.9",
|
||||||
"eslint-module-utils": "^2.12.0",
|
"eslint-module-utils": "^2.9.0",
|
||||||
"hasown": "^2.0.2",
|
"hasown": "^2.0.2",
|
||||||
"is-core-module": "^2.15.1",
|
"is-core-module": "^2.15.1",
|
||||||
"is-glob": "^4.0.3",
|
"is-glob": "^4.0.3",
|
||||||
|
@ -2447,14 +2446,13 @@
|
||||||
"object.groupby": "^1.0.3",
|
"object.groupby": "^1.0.3",
|
||||||
"object.values": "^1.2.0",
|
"object.values": "^1.2.0",
|
||||||
"semver": "^6.3.1",
|
"semver": "^6.3.1",
|
||||||
"string.prototype.trimend": "^1.0.8",
|
|
||||||
"tsconfig-paths": "^3.15.0"
|
"tsconfig-paths": "^3.15.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=4"
|
"node": ">=4"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8 || ^9"
|
"eslint": "^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-plugin-import/node_modules/debug": {
|
"node_modules/eslint-plugin-import/node_modules/debug": {
|
||||||
|
@ -4138,9 +4136,9 @@
|
||||||
"license": "ISC"
|
"license": "ISC"
|
||||||
},
|
},
|
||||||
"node_modules/iterator.prototype": {
|
"node_modules/iterator.prototype": {
|
||||||
"version": "1.1.3",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/iterator.prototype/-/iterator.prototype-1.1.2.tgz",
|
||||||
"integrity": "sha512-FW5iMbeQ6rBGm/oKgzq2aW4KvAGpxPzYES8N4g4xNXUKpL1mclMvOe+76AcLDTvD+Ze+sOpVhgdAQEKF4L9iGQ==",
|
"integrity": "sha512-DR33HMMr8EzwuRL8Y9D3u2BMj8+RqSE850jfGu59kS7tbmPLzGkZmVSfyCFSDxuZiEY6Rzt3T2NA/qU+NwVj1w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -4149,9 +4147,6 @@
|
||||||
"has-symbols": "^1.0.3",
|
"has-symbols": "^1.0.3",
|
||||||
"reflect.getprototypeof": "^1.0.4",
|
"reflect.getprototypeof": "^1.0.4",
|
||||||
"set-function-name": "^2.0.1"
|
"set-function-name": "^2.0.1"
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 0.4"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jackspeak": {
|
"node_modules/jackspeak": {
|
||||||
|
@ -6299,16 +6294,16 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/regexp.prototype.flags": {
|
"node_modules/regexp.prototype.flags": {
|
||||||
"version": "1.5.3",
|
"version": "1.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.3.tgz",
|
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.2.tgz",
|
||||||
"integrity": "sha512-vqlC04+RQoFalODCbCumG2xIOvapzVMHwsyIGM/SIE8fRhFFsXeH8/QQ+s0T0kDAhKc4k30s73/0ydkHQz6HlQ==",
|
"integrity": "sha512-NcDiDkTLuPR+++OCKB0nWafEmhg/Da8aUPLPMQbK+bxKKCm1/S5he+AqYa4PlMCVBalb4/yxIRub6qkEx5yJbw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"call-bind": "^1.0.7",
|
"call-bind": "^1.0.6",
|
||||||
"define-properties": "^1.2.1",
|
"define-properties": "^1.2.1",
|
||||||
"es-errors": "^1.3.0",
|
"es-errors": "^1.3.0",
|
||||||
"set-function-name": "^2.0.2"
|
"set-function-name": "^2.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">= 0.4"
|
"node": ">= 0.4"
|
||||||
|
|
141
py/api.py
141
py/api.py
|
@ -13,7 +13,7 @@ from tts import TTS
|
||||||
|
|
||||||
class API:
|
class API:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.crypt_size = 64
|
self.crypt_size = 4096
|
||||||
self.app = Flask(__name__)
|
self.app = Flask(__name__)
|
||||||
self.ai_response = {}
|
self.ai_response = {}
|
||||||
self.ai = AI()
|
self.ai = AI()
|
||||||
|
@ -26,7 +26,7 @@ class API:
|
||||||
CORS(self.app)
|
CORS(self.app)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
@self.app.route("/interstellar_ai/api/ai_create", methods=["GET"])
|
@self.app.route('/interstellar_ai/api/ai_create', methods=['GET'])
|
||||||
def create_ai():
|
def create_ai():
|
||||||
access_token = secrets.token_urlsafe(self.crypt_size)
|
access_token = secrets.token_urlsafe(self.crypt_size)
|
||||||
|
|
||||||
|
@ -34,141 +34,112 @@ class API:
|
||||||
access_token = secrets.token_urlsafe(self.crypt_size)
|
access_token = secrets.token_urlsafe(self.crypt_size)
|
||||||
|
|
||||||
self.ai_response[access_token] = ""
|
self.ai_response[access_token] = ""
|
||||||
return jsonify({"status": 200, "access_token": access_token})
|
return jsonify({'status': 200, 'access_token': access_token})
|
||||||
|
|
||||||
@self.app.route("/interstellar_ai/api/ai_send", methods=["POST"])
|
@self.app.route('/interstellar_ai/api/ai_send', methods=['POST'])
|
||||||
def send_ai():
|
def send_ai():
|
||||||
data = request.get_json()
|
data = request.get_json()
|
||||||
messages = data.get("messages")
|
messages = data.get('messages')
|
||||||
model_type = data.get("model_type")
|
model_type = data.get('model_type')
|
||||||
ai_model = data.get("ai_model")
|
ai_model = data.get('ai_model')
|
||||||
access_token = data.get("access_token")
|
access_token = data.get('access_token')
|
||||||
if access_token not in self.ai_response:
|
if access_token not in self.ai_response:
|
||||||
return jsonify({"status": 401, "error": "Invalid access token"})
|
return jsonify({'status': 401, 'error': 'Invalid access token'})
|
||||||
|
|
||||||
if model_type == "local":
|
if model_type == "local":
|
||||||
thread = threading.Thread(
|
thread = threading.Thread(target=self.ai.process_local, args=(ai_model, messages, self, access_token))
|
||||||
target=self.ai.process_local,
|
|
||||||
args=(ai_model, messages, self, access_token),
|
|
||||||
)
|
|
||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
return jsonify({"status": 200})
|
return jsonify({'status': 200})
|
||||||
elif model_type == "mistral":
|
elif model_type == "mistral":
|
||||||
api_key = data.get("api_key")
|
api_key = data.get('api_key')
|
||||||
thread = threading.Thread(
|
thread = threading.Thread(target=self.ai.process_mistralai,
|
||||||
target=self.ai.process_mistralai,
|
args=(ai_model, messages, self, access_token, api_key))
|
||||||
args=(ai_model, messages, self, access_token, api_key),
|
|
||||||
)
|
|
||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
return jsonify({"status": 200})
|
return jsonify({'status': 200})
|
||||||
elif model_type == "openai":
|
elif model_type == "openai":
|
||||||
api_key = data.get("api_key")
|
api_key = data.get('api_key')
|
||||||
thread = threading.Thread(
|
thread = threading.Thread(target=self.ai.process_openai,
|
||||||
target=self.ai.process_openai,
|
args=(ai_model, messages, self, access_token, api_key))
|
||||||
args=(ai_model, messages, self, access_token, api_key),
|
|
||||||
)
|
|
||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
return jsonify({"status": 200})
|
return jsonify({'status': 200})
|
||||||
elif model_type == "anthropic":
|
elif model_type == "anthropic":
|
||||||
api_key = data.get("api_key")
|
api_key = data.get('api_key')
|
||||||
thread = threading.Thread(
|
thread = threading.Thread(target=self.ai.process_anthropic,
|
||||||
target=self.ai.process_anthropic,
|
args=(ai_model, messages, self, access_token, api_key))
|
||||||
args=(ai_model, messages, self, access_token, api_key),
|
|
||||||
)
|
|
||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
return jsonify({"status": 200})
|
return jsonify({'status': 200})
|
||||||
elif model_type == "google":
|
elif model_type == "google":
|
||||||
api_key = data.get("api_key")
|
api_key = data.get('api_key')
|
||||||
thread = threading.Thread(
|
thread = threading.Thread(target=self.ai.process_google,
|
||||||
target=self.ai.process_google,
|
args=(ai_model, messages, self, access_token, api_key))
|
||||||
args=(ai_model, messages, self, access_token, api_key),
|
|
||||||
)
|
|
||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
return jsonify({"status": 200})
|
return jsonify({'status': 200})
|
||||||
|
|
||||||
return jsonify({"status": 401, "error": "Invalid AI model type"})
|
return jsonify({'status': 401, 'error': 'Invalid AI model type'})
|
||||||
|
|
||||||
@self.app.route("/interstellar_ai/api/ai_get", methods=["GET"])
|
@self.app.route('/interstellar_ai/api/ai_get', methods=['GET'])
|
||||||
def get_ai():
|
def get_ai():
|
||||||
data = request.args.get("access_token")
|
data = request.args.get('access_token')
|
||||||
if data not in self.ai_response:
|
if data not in self.ai_response:
|
||||||
return jsonify({"status": 401, "error": "Invalid access token"})
|
return jsonify({'status': 401, 'error': 'Invalid access token'})
|
||||||
return jsonify({"status": 200, "response": self.ai_response[data]})
|
return jsonify({'status': 200, 'response': self.ai_response[data]})
|
||||||
|
|
||||||
@self.app.route("/interstellar_ai/db", methods=["POST"])
|
@self.app.route('/interstellar_ai/db', methods=['POST'])
|
||||||
def db_manipulate():
|
def db_manipulate():
|
||||||
sent_data = request.get_json()
|
sent_data = request.get_json()
|
||||||
print(sent_data)
|
print(sent_data)
|
||||||
action = sent_data.get("action")
|
action = sent_data.get('action')
|
||||||
if action == "create_account":
|
if action == "create_account":
|
||||||
return jsonify({"status": 200, "response": self.db.add_user(sent_data)})
|
return jsonify({'status': 200, 'response': self.db.add_user(sent_data)})
|
||||||
elif action == "change_password":
|
elif action == "change_password":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.update_password(sent_data)})
|
||||||
{"status": 200, "response": self.db.update_password(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "get_settings":
|
elif action == "get_settings":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.get_settings(sent_data)})
|
||||||
{"status": 200, "response": self.db.get_settings(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "change_settings":
|
elif action == "change_settings":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.change_settings(sent_data)})
|
||||||
{"status": 200, "response": self.db.change_settings(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "get_history":
|
elif action == "get_history":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.get_history(sent_data)})
|
||||||
{"status": 200, "response": self.db.get_history(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "change_history":
|
elif action == "change_history":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.change_history(sent_data)})
|
||||||
{"status": 200, "response": self.db.change_history(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "check_credentials":
|
elif action == "check_credentials":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.check_credentials(sent_data)})
|
||||||
{"status": 200, "response": self.db.check_credentials(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "delete_account":
|
elif action == "delete_account":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.delete_user(sent_data)})
|
||||||
{"status": 200, "response": self.db.delete_user(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "get_email":
|
elif action == "get_email":
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.db.get_email(sent_data)})
|
||||||
{"status": 200, "response": self.db.get_email(sent_data)}
|
|
||||||
)
|
|
||||||
elif action == "get_name":
|
elif action == "get_name":
|
||||||
return jsonify({"status": 200, "response": self.db.get_name(sent_data)})
|
return jsonify({'status': 200, 'response': self.db.get_name(sent_data)})
|
||||||
|
|
||||||
return jsonify({"status": 401, "response": "Invalid action"})
|
return jsonify({'status': 401, 'response': "Invalid action"})
|
||||||
|
|
||||||
@self.app.route("/interstellar_ai/api/voice_recognition", methods=["POST"])
|
@self.app.route('/interstellar_ai/api/voice_recognition', methods=['POST'])
|
||||||
def voice_recognition():
|
def voice_recognition():
|
||||||
audio = request.files.get("audio")
|
audio = request.files.get('audio')
|
||||||
text = self.voice.recognition(audio)
|
text = self.voice.recognition(audio)
|
||||||
return jsonify({"status": 200, "response": text})
|
return jsonify({'status': 200, 'response': text})
|
||||||
|
|
||||||
@self.app.route("/interstellar_ai/api/weather", methods=["POST"])
|
@self.app.route('/interstellar_ai/api/weather', methods=['POST'])
|
||||||
def get_weather():
|
def get_weather():
|
||||||
unit_type = request.args.get("unit_type")
|
unit_type = request.args.get('unit_type')
|
||||||
city = request.args.get("city")
|
city = request.args.get('city')
|
||||||
return jsonify(
|
return jsonify({'status': 200, 'response': self.weather.getweather(unit_type, city)})
|
||||||
{"status": 200, "response": self.weather.getweather(unit_type, city)}
|
|
||||||
)
|
|
||||||
|
|
||||||
self.app.run(debug=True, host="0.0.0.0", port=5000)
|
self.app.run(debug=True, host='0.0.0.0', port=5000)
|
||||||
|
|
||||||
@self.app.route("/interstellar_ai/api/tts", methods=["POST"])
|
@self.app.route('/interstellar_ai/api/tts', methods=['POST'])
|
||||||
def tts():
|
def tts():
|
||||||
text = request.args.get("text")
|
text = request.args.get('text')
|
||||||
return jsonify({"status": 200, "response": self.tts.gen_tts(text)})
|
return jsonify({'status': 200, 'response': self.tts.gen_tts(text)})
|
||||||
|
|
||||||
|
|
||||||
api = API()
|
api = API()
|
||||||
|
|
Loading…
Reference in a new issue