a6efb66c by RSA

wip

1 parent b22f9a7b
1 OPENAI_API_ORG="org-YgE1xiPAzhVmwwrtZnXIRyiF"
2 OPENAI_API_KEY="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"
3 SERVER_URL="http://localhost:3080"
...\ No newline at end of file ...\ No newline at end of file
...@@ -4863,9 +4863,9 @@ ...@@ -4863,9 +4863,9 @@
4863 } 4863 }
4864 }, 4864 },
4865 "dotenv": { 4865 "dotenv": {
4866 "version": "10.0.0", 4866 "version": "16.0.3",
4867 "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz", 4867 "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
4868 "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==" 4868 "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
4869 }, 4869 },
4870 "dotenv-expand": { 4870 "dotenv-expand": {
4871 "version": "5.1.0", 4871 "version": "5.1.0",
...@@ -5937,6 +5937,11 @@ ...@@ -5937,6 +5937,11 @@
5937 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 5937 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
5938 "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" 5938 "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
5939 }, 5939 },
5940 "fs": {
5941 "version": "0.0.1-security",
5942 "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
5943 "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
5944 },
5940 "fs-extra": { 5945 "fs-extra": {
5941 "version": "10.1.0", 5946 "version": "10.1.0",
5942 "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz", 5947 "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-10.1.0.tgz",
...@@ -9424,6 +9429,15 @@ ...@@ -9424,6 +9429,15 @@
9424 } 9429 }
9425 } 9430 }
9426 }, 9431 },
9432 "path": {
9433 "version": "0.12.7",
9434 "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
9435 "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
9436 "requires": {
9437 "process": "^0.11.1",
9438 "util": "^0.10.3"
9439 }
9440 },
9427 "path-exists": { 9441 "path-exists": {
9428 "version": "4.0.0", 9442 "version": "4.0.0",
9429 "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", 9443 "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
...@@ -10289,6 +10303,11 @@ ...@@ -10289,6 +10303,11 @@
10289 } 10303 }
10290 } 10304 }
10291 }, 10305 },
10306 "process": {
10307 "version": "0.11.10",
10308 "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
10309 "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
10310 },
10292 "process-nextick-args": { 10311 "process-nextick-args": {
10293 "version": "2.0.1", 10312 "version": "2.0.1",
10294 "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", 10313 "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
...@@ -10571,6 +10590,13 @@ ...@@ -10571,6 +10590,13 @@
10571 "webpack-dev-server": "^4.6.0", 10590 "webpack-dev-server": "^4.6.0",
10572 "webpack-manifest-plugin": "^4.0.2", 10591 "webpack-manifest-plugin": "^4.0.2",
10573 "workbox-webpack-plugin": "^6.4.1" 10592 "workbox-webpack-plugin": "^6.4.1"
10593 },
10594 "dependencies": {
10595 "dotenv": {
10596 "version": "10.0.0",
10597 "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-10.0.0.tgz",
10598 "integrity": "sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q=="
10599 }
10574 } 10600 }
10575 }, 10601 },
10576 "read-cache": { 10602 "read-cache": {
...@@ -11899,6 +11925,21 @@ ...@@ -11899,6 +11925,21 @@
11899 "requires-port": "^1.0.0" 11925 "requires-port": "^1.0.0"
11900 } 11926 }
11901 }, 11927 },
11928 "util": {
11929 "version": "0.10.4",
11930 "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
11931 "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
11932 "requires": {
11933 "inherits": "2.0.3"
11934 },
11935 "dependencies": {
11936 "inherits": {
11937 "version": "2.0.3",
11938 "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
11939 "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw=="
11940 }
11941 }
11942 },
11902 "util-deprecate": { 11943 "util-deprecate": {
11903 "version": "1.0.2", 11944 "version": "1.0.2",
11904 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 11945 "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
......
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
6 "@testing-library/jest-dom": "^5.16.5", 6 "@testing-library/jest-dom": "^5.16.5",
7 "@testing-library/react": "^13.4.0", 7 "@testing-library/react": "^13.4.0",
8 "@testing-library/user-event": "^13.5.0", 8 "@testing-library/user-event": "^13.5.0",
9 "dotenv": "^16.0.3",
10 "fs": "0.0.1-security",
11 "path": "^0.12.7",
9 "react": "^18.2.0", 12 "react": "^18.2.0",
10 "react-dom": "^18.2.0", 13 "react-dom": "^18.2.0",
11 "react-scripts": "5.0.1", 14 "react-scripts": "5.0.1",
......
...@@ -10,7 +10,8 @@ function App() { ...@@ -10,7 +10,8 @@ function App() {
10 useEffect(() => { 10 useEffect(() => {
11 getEngines(); 11 getEngines();
12 }, []) 12 }, [])
13 13 const [env, setEnv] = useState({});
14 console.log(env.SERVER_URL)
14 const [chatInput, setChatInput] = useState(""); 15 const [chatInput, setChatInput] = useState("");
15 const [models, setModels] = useState([]); 16 const [models, setModels] = useState([]);
16 const [temperature, setTemperature] = useState(0.7); 17 const [temperature, setTemperature] = useState(0.7);
...@@ -26,7 +27,9 @@ function App() { ...@@ -26,7 +27,9 @@ function App() {
26 } 27 }
27 28
28 function getEngines(){ 29 function getEngines(){
29 fetch(process.env.SERVER_URL + "/models") 30
31
32 fetch(env.SERVER_URL + "models")
30 .then(res => res.json()) 33 .then(res => res.json())
31 .then(data => { 34 .then(data => {
32 console.log(data.models.data) 35 console.log(data.models.data)
......
...@@ -2,8 +2,10 @@ const { Configuration, OpenAIApi } = require("openai"); ...@@ -2,8 +2,10 @@ const { Configuration, OpenAIApi } = require("openai");
2 const express = require('express') 2 const express = require('express')
3 const bodyParser = require('body-parser') 3 const bodyParser = require('body-parser')
4 const cors = require('cors') 4 const cors = require('cors')
5 require('dotenv').config()
5 6
6 // Open AI Configuration 7 // Open AI Configuration
8
7 const configuration = new Configuration({ 9 const configuration = new Configuration({
8 organization: process.env.OPENAI_API_ORG, 10 organization: process.env.OPENAI_API_ORG,
9 apiKey: process.env.OPENAI_API_KEY, 11 apiKey: process.env.OPENAI_API_KEY,
...@@ -19,10 +21,16 @@ app.use(cors()) ...@@ -19,10 +21,16 @@ app.use(cors())
19 app.use(require('morgan')('dev')) 21 app.use(require('morgan')('dev'))
20 22
21 23
24 app.get('/env', (req, res) => {
25 res.send({
26 SERVER_URL: process.env.SERVER_URL,
27 });
28 });
29
22 // Routing 30 // Routing
23 31
24 // Primary Open AI Route 32 // Primary Open AI Route
25 app.post('/api', async (req, res) => { 33 app.post('/', async (req, res) => {
26 const { message, currentModel, temperature } = req.body; 34 const { message, currentModel, temperature } = req.body;
27 const response = await openai.createCompletion({ 35 const response = await openai.createCompletion({
28 model: `${currentModel}`,// "text-davinci-003", 36 model: `${currentModel}`,// "text-davinci-003",
......
...@@ -142,6 +142,11 @@ ...@@ -142,6 +142,11 @@
142 "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", 142 "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
143 "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" 143 "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg=="
144 }, 144 },
145 "dotenv": {
146 "version": "16.0.3",
147 "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz",
148 "integrity": "sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ=="
149 },
145 "ee-first": { 150 "ee-first": {
146 "version": "1.1.1", 151 "version": "1.1.1",
147 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 152 "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
...@@ -239,6 +244,11 @@ ...@@ -239,6 +244,11 @@
239 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 244 "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
240 "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" 245 "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q=="
241 }, 246 },
247 "fs": {
248 "version": "0.0.1-security",
249 "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
250 "integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w=="
251 },
242 "function-bind": { 252 "function-bind": {
243 "version": "1.1.1", 253 "version": "1.1.1",
244 "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", 254 "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
...@@ -399,11 +409,25 @@ ...@@ -399,11 +409,25 @@
399 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 409 "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
400 "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" 410 "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ=="
401 }, 411 },
412 "path": {
413 "version": "0.12.7",
414 "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
415 "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
416 "requires": {
417 "process": "^0.11.1",
418 "util": "^0.10.3"
419 }
420 },
402 "path-to-regexp": { 421 "path-to-regexp": {
403 "version": "0.1.7", 422 "version": "0.1.7",
404 "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 423 "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
405 "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" 424 "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
406 }, 425 },
426 "process": {
427 "version": "0.11.10",
428 "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
429 "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A=="
430 },
407 "proxy-addr": { 431 "proxy-addr": {
408 "version": "2.0.7", 432 "version": "2.0.7",
409 "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", 433 "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
...@@ -524,6 +548,21 @@ ...@@ -524,6 +548,21 @@
524 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 548 "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
525 "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==" 549 "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ=="
526 }, 550 },
551 "util": {
552 "version": "0.10.4",
553 "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
554 "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
555 "requires": {
556 "inherits": "2.0.3"
557 },
558 "dependencies": {
559 "inherits": {
560 "version": "2.0.3",
561 "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
562 "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw=="
563 }
564 }
565 },
527 "utils-merge": { 566 "utils-merge": {
528 "version": "1.0.1", 567 "version": "1.0.1",
529 "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 568 "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
......
...@@ -11,8 +11,11 @@ ...@@ -11,8 +11,11 @@
11 "dependencies": { 11 "dependencies": {
12 "body-parser": "^1.20.1", 12 "body-parser": "^1.20.1",
13 "cors": "^2.8.5", 13 "cors": "^2.8.5",
14 "dotenv": "^16.0.3",
14 "express": "^4.18.2", 15 "express": "^4.18.2",
16 "fs": "0.0.1-security",
15 "morgan": "^1.10.0", 17 "morgan": "^1.10.0",
16 "openai": "^3.1.0" 18 "openai": "^3.1.0",
19 "path": "^0.12.7"
17 } 20 }
18 } 21 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!