opensource
Showing
5 changed files
with
92 additions
and
6 deletions
This diff is collapsed.
Click to expand it.
| ... | @@ -28,9 +28,12 @@ function App() { | ... | @@ -28,9 +28,12 @@ function App() { |
| 28 | const [chatLogTurbo, setChatLogTurbo] = useState(defaultChatLogTurbo); | 28 | const [chatLogTurbo, setChatLogTurbo] = useState(defaultChatLogTurbo); |
| 29 | // | 29 | // |
| 30 | 30 | ||
| 31 | const [chatLogOpenSource, setChatLogOpenSource] = useState([]); | ||
| 32 | |||
| 31 | function clearChat(){ | 33 | function clearChat(){ |
| 32 | setChatLog([]); | 34 | setChatLog([]); |
| 33 | setChatLogTurbo(defaultChatLogTurbo); | 35 | setChatLogTurbo(defaultChatLogTurbo); |
| 36 | setChatLogOpenSource([]); | ||
| 34 | setChatInput(""); | 37 | setChatInput(""); |
| 35 | setStartedInteraction(false); | 38 | setStartedInteraction(false); |
| 36 | } | 39 | } |
| ... | @@ -94,12 +97,20 @@ function App() { | ... | @@ -94,12 +97,20 @@ function App() { |
| 94 | setChatLog(prevChatLog => [...prevChatLog, userMessage]); | 97 | setChatLog(prevChatLog => [...prevChatLog, userMessage]); |
| 95 | 98 | ||
| 96 | var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n") | 99 | var messages = chatLogNew.map((message) => { if(message.user !== 'me') return message.message }).join("\n") |
| 97 | if(currentModel == GPTTurbo || currentModel == GPTTurbo0301) { | 100 | if(currentModel === GPTTurbo || currentModel === GPTTurbo0301) { |
| 98 | // "gpt-3.5-turbo" | 101 | // "gpt-3.5-turbo" |
| 99 | let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }]; | 102 | let chatLogTurboNew = [...chatLogTurbo, { role: "user", content: chatInput }]; |
| 100 | setChatLogTurbo(chatLogTurboNew); | 103 | setChatLogTurbo(chatLogTurboNew); |
| 101 | messages = JSON.stringify(chatLogTurboNew); | 104 | messages = JSON.stringify(chatLogTurboNew); |
| 102 | } | 105 | } |
| 106 | |||
| 107 | if(currentModel === "openchat_3.5-GPTQ" || currentModel === "zephyr-7B-beta-GPTQ") { | ||
| 108 | // "gpt-3.5-turbo" | ||
| 109 | let chatLogOpenSourceNew = [...chatLogOpenSource, { role: "user", content: chatInput }]; | ||
| 110 | setChatLogOpenSource(chatLogOpenSourceNew); | ||
| 111 | messages = JSON.stringify(chatLogOpenSourceNew); | ||
| 112 | } | ||
| 113 | |||
| 103 | let intervalId = startInterval(); | 114 | let intervalId = startInterval(); |
| 104 | try { | 115 | try { |
| 105 | const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", { | 116 | const response = await fetch(process.env.REACT_APP_SERVER_URL + "/api", { |
| ... | @@ -117,6 +128,7 @@ function App() { | ... | @@ -117,6 +128,7 @@ function App() { |
| 117 | const parsedData = data.message.trim(); | 128 | const parsedData = data.message.trim(); |
| 118 | // "gpt-3.5-turbo" | 129 | // "gpt-3.5-turbo" |
| 119 | let chatLogTurboNew = chatLogTurbo; | 130 | let chatLogTurboNew = chatLogTurbo; |
| 131 | let chatLogOpenSourceNew = chatLogOpenSource; | ||
| 120 | if(data.success === false) { | 132 | if(data.success === false) { |
| 121 | setChatLog(prevChatLog => { | 133 | setChatLog(prevChatLog => { |
| 122 | const lastMsg = prevChatLog[prevChatLog.length - 2]; | 134 | const lastMsg = prevChatLog[prevChatLog.length - 2]; |
| ... | @@ -129,7 +141,11 @@ function App() { | ... | @@ -129,7 +141,11 @@ function App() { |
| 129 | } | 141 | } |
| 130 | chatLogTurboNew.push({ role: "user", content: userModifiedInput }); | 142 | chatLogTurboNew.push({ role: "user", content: userModifiedInput }); |
| 131 | chatLogTurboNew.push({ role: "assistant", content: parsedData }); | 143 | chatLogTurboNew.push({ role: "assistant", content: parsedData }); |
| 144 | |||
| 145 | chatLogOpenSourceNew.push({ role: "user", content: userModifiedInput }); | ||
| 146 | chatLogOpenSourceNew.push({ role: "assistant", content: parsedData }); | ||
| 132 | setChatLogTurbo(chatLogTurboNew); | 147 | setChatLogTurbo(chatLogTurboNew); |
| 148 | setChatLogOpenSource(chatLogOpenSourceNew); | ||
| 133 | // | 149 | // |
| 134 | clearInterval(intervalId); | 150 | clearInterval(intervalId); |
| 135 | const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; | 151 | const programmingKeywords = ['code', 'application', 'controller', 'rails' , 'PHP', 'java', 'javascript', 'script', 'console', 'python', 'programming', 'table']; | ... | ... |
| 1 | OPENAI_API_ORG= | 1 | OPENAI_API_ORG= |
| 2 | OPENAI_API_KEY= | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 2 | OPENAI_API_KEY= | ||
| 3 | |||
| 4 | |||
| 5 | OPENSOURCE_MODELS="openchat_3.5-GPTQ,zephyr-7B-beta-GPTQ" | ||
| 6 | OPENSOURCE_ENDPOINTS={"openchat_3.5-GPTQ": "https://openchat.llm.ai-pro.org/v1", "zephyr-7B-beta-GPTQ": "https://zephyr.llm.ai-pro.org/v1"} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed.
Click to expand it.
| ... | @@ -10,11 +10,15 @@ | ... | @@ -10,11 +10,15 @@ |
| 10 | "license": "ISC", | 10 | "license": "ISC", |
| 11 | "dependencies": { | 11 | "dependencies": { |
| 12 | "anchorme": "^2.1.2", | 12 | "anchorme": "^2.1.2", |
| 13 | "axios": "^1.5.1", | ||
| 13 | "body-parser": "^1.20.1", | 14 | "body-parser": "^1.20.1", |
| 15 | "cookie": "0.5.0", | ||
| 16 | "cookie-parser": "1.4.6", | ||
| 14 | "cors": "^2.8.5", | 17 | "cors": "^2.8.5", |
| 15 | "dotenv": "^16.0.3", | 18 | "dotenv": "^16.0.3", |
| 16 | "express": "^4.18.2", | 19 | "express": "^4.18.2", |
| 17 | "express-rate-limit": "^6.7.0", | 20 | "express-rate-limit": "^6.7.0", |
| 21 | "js-tiktoken": "1.0.7", | ||
| 18 | "morgan": "^1.10.0", | 22 | "morgan": "^1.10.0", |
| 19 | "openai": "^3.2.0" | 23 | "openai": "^3.2.0" |
| 20 | } | 24 | } |
| ... | @@ -47,13 +51,34 @@ | ... | @@ -47,13 +51,34 @@ |
| 47 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" | 51 | "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" |
| 48 | }, | 52 | }, |
| 49 | "node_modules/axios": { | 53 | "node_modules/axios": { |
| 50 | "version": "0.26.1", | 54 | "version": "1.6.2", |
| 51 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", | 55 | "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.2.tgz", |
| 52 | "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", | 56 | "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", |
| 53 | "dependencies": { | 57 | "dependencies": { |
| 54 | "follow-redirects": "^1.14.8" | 58 | "follow-redirects": "^1.15.0", |
| 59 | "form-data": "^4.0.0", | ||
| 60 | "proxy-from-env": "^1.1.0" | ||
| 55 | } | 61 | } |
| 56 | }, | 62 | }, |
| 63 | "node_modules/base64-js": { | ||
| 64 | "version": "1.5.1", | ||
| 65 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", | ||
| 66 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", | ||
| 67 | "funding": [ | ||
| 68 | { | ||
| 69 | "type": "github", | ||
| 70 | "url": "https://github.com/sponsors/feross" | ||
| 71 | }, | ||
| 72 | { | ||
| 73 | "type": "patreon", | ||
| 74 | "url": "https://www.patreon.com/feross" | ||
| 75 | }, | ||
| 76 | { | ||
| 77 | "type": "consulting", | ||
| 78 | "url": "https://feross.org/support" | ||
| 79 | } | ||
| 80 | ] | ||
| 81 | }, | ||
| 57 | "node_modules/basic-auth": { | 82 | "node_modules/basic-auth": { |
| 58 | "version": "2.0.1", | 83 | "version": "2.0.1", |
| 59 | "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", | 84 | "resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz", |
| ... | @@ -151,6 +176,26 @@ | ... | @@ -151,6 +176,26 @@ |
| 151 | "node": ">= 0.6" | 176 | "node": ">= 0.6" |
| 152 | } | 177 | } |
| 153 | }, | 178 | }, |
| 179 | "node_modules/cookie-parser": { | ||
| 180 | "version": "1.4.6", | ||
| 181 | "resolved": "https://registry.npmjs.org/cookie-parser/-/cookie-parser-1.4.6.tgz", | ||
| 182 | "integrity": "sha512-z3IzaNjdwUC2olLIB5/ITd0/setiaFMLYiZJle7xg5Fe9KWAceil7xszYfHHBtDFYLSgJduS2Ty0P1uJdPDJeA==", | ||
| 183 | "dependencies": { | ||
| 184 | "cookie": "0.4.1", | ||
| 185 | "cookie-signature": "1.0.6" | ||
| 186 | }, | ||
| 187 | "engines": { | ||
| 188 | "node": ">= 0.8.0" | ||
| 189 | } | ||
| 190 | }, | ||
| 191 | "node_modules/cookie-parser/node_modules/cookie": { | ||
| 192 | "version": "0.4.1", | ||
| 193 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.1.tgz", | ||
| 194 | "integrity": "sha512-ZwrFkGJxUR3EIoXtO+yVE69Eb7KlixbaeAWfBQB9vVsNn/o+Yw69gBWSSDK825hQNdN+wF8zELf3dFNl/kxkUA==", | ||
| 195 | "engines": { | ||
| 196 | "node": ">= 0.6" | ||
| 197 | } | ||
| 198 | }, | ||
| 154 | "node_modules/cookie-signature": { | 199 | "node_modules/cookie-signature": { |
| 155 | "version": "1.0.6", | 200 | "version": "1.0.6", |
| 156 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", | 201 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", |
| ... | @@ -431,6 +476,14 @@ | ... | @@ -431,6 +476,14 @@ |
| 431 | "node": ">= 0.10" | 476 | "node": ">= 0.10" |
| 432 | } | 477 | } |
| 433 | }, | 478 | }, |
| 479 | "node_modules/js-tiktoken": { | ||
| 480 | "version": "1.0.7", | ||
| 481 | "resolved": "https://registry.npmjs.org/js-tiktoken/-/js-tiktoken-1.0.7.tgz", | ||
| 482 | "integrity": "sha512-biba8u/clw7iesNEWLOLwrNGoBP2lA+hTaBLs/D45pJdUPFXyxD6nhcDVtADChghv4GgyAiMKYMiRx7x6h7Biw==", | ||
| 483 | "dependencies": { | ||
| 484 | "base64-js": "^1.5.1" | ||
| 485 | } | ||
| 486 | }, | ||
| 434 | "node_modules/media-typer": { | 487 | "node_modules/media-typer": { |
| 435 | "version": "0.3.0", | 488 | "version": "0.3.0", |
| 436 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", | 489 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", |
| ... | @@ -565,6 +618,14 @@ | ... | @@ -565,6 +618,14 @@ |
| 565 | "form-data": "^4.0.0" | 618 | "form-data": "^4.0.0" |
| 566 | } | 619 | } |
| 567 | }, | 620 | }, |
| 621 | "node_modules/openai/node_modules/axios": { | ||
| 622 | "version": "0.26.1", | ||
| 623 | "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", | ||
| 624 | "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", | ||
| 625 | "dependencies": { | ||
| 626 | "follow-redirects": "^1.14.8" | ||
| 627 | } | ||
| 628 | }, | ||
| 568 | "node_modules/parseurl": { | 629 | "node_modules/parseurl": { |
| 569 | "version": "1.3.3", | 630 | "version": "1.3.3", |
| 570 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", | 631 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", |
| ... | @@ -590,6 +651,11 @@ | ... | @@ -590,6 +651,11 @@ |
| 590 | "node": ">= 0.10" | 651 | "node": ">= 0.10" |
| 591 | } | 652 | } |
| 592 | }, | 653 | }, |
| 654 | "node_modules/proxy-from-env": { | ||
| 655 | "version": "1.1.0", | ||
| 656 | "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", | ||
| 657 | "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" | ||
| 658 | }, | ||
| 593 | "node_modules/qs": { | 659 | "node_modules/qs": { |
| 594 | "version": "6.11.0", | 660 | "version": "6.11.0", |
| 595 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", | 661 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", | ... | ... |
-
Please register or sign in to post a comment