mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-09-22 08:12:00 +02:00
reorganize dirs for dockerize
This commit is contained in:
parent
6ae154cc42
commit
fca546af63
38 changed files with 1056 additions and 1970 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -29,6 +29,8 @@ public/main.js.LICENSE.txt
|
|||
# Deployed apps should consider commenting these lines out:
|
||||
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
|
||||
node_modules/
|
||||
api/node_modules/
|
||||
client/node_modules/
|
||||
bower_components/
|
||||
|
||||
# Floobits
|
||||
|
@ -40,7 +42,7 @@ bower_components/
|
|||
# Environment
|
||||
.env
|
||||
cache.json
|
||||
data/
|
||||
api/data/
|
||||
.eslintrc.js
|
||||
|
||||
src/style - official.css
|
12
api/DockerFile
Normal file
12
api/DockerFile
Normal file
|
@ -0,0 +1,12 @@
|
|||
FROM node:latest
|
||||
WORKDIR /api
|
||||
# copy package.json into the container at /api
|
||||
COPY package*.json /api/
|
||||
# install dependencies
|
||||
RUN npm install
|
||||
# Copy the current directory contents into the container at /api
|
||||
COPY . /api/
|
||||
# Make port 80 available to the world outside this container
|
||||
EXPOSE 80
|
||||
# Run the app when the container launches
|
||||
CMD ["npm", "start"]
|
|
@ -10,7 +10,7 @@ const askBing = async ({ text, progressCallback, convo }) => {
|
|||
// If the above doesn't work, provide all your cookies as a string instead
|
||||
// cookies: '',
|
||||
debug: false,
|
||||
store: new KeyvFile({ filename: './data/cache.json' })
|
||||
store: new KeyvFile({ filename: './api/data/cache.json' })
|
||||
});
|
||||
|
||||
let options = {
|
|
@ -12,7 +12,7 @@ const browserClient = async ({ text, progressCallback, convo }) => {
|
|||
const { ChatGPTBrowserClient } = await import('@waylaidwanderer/chatgpt-api');
|
||||
|
||||
const store = {
|
||||
store: new KeyvFile({ filename: './data/cache.json' })
|
||||
store: new KeyvFile({ filename: './api/data/cache.json' })
|
||||
};
|
||||
|
||||
const client = new ChatGPTBrowserClient(clientOptions, store);
|
|
@ -11,7 +11,7 @@ const clientOptions = {
|
|||
const askClient = async ({ text, progressCallback, convo }) => {
|
||||
const ChatGPTClient = (await import('@waylaidwanderer/chatgpt-api')).default;
|
||||
const store = {
|
||||
store: new KeyvFile({ filename: './data/cache.json' })
|
||||
store: new KeyvFile({ filename: './api/data/cache.json' })
|
||||
};
|
||||
|
||||
const client = new ChatGPTClient(process.env.OPENAI_KEY, clientOptions, store);
|
|
@ -11,7 +11,7 @@ const clientOptions = {
|
|||
const customClient = async ({ text, progressCallback, convo, promptPrefix, chatGptLabel }) => {
|
||||
const ChatGPTClient = (await import('@waylaidwanderer/chatgpt-api')).default;
|
||||
const store = {
|
||||
store: new KeyvFile({ filename: './data/cache.json' })
|
||||
store: new KeyvFile({ filename: './api/data/cache.json' })
|
||||
};
|
||||
|
||||
clientOptions.chatGptLabel = chatGptLabel;
|
38
api/package.json
Normal file
38
api/package.json
Normal file
|
@ -0,0 +1,38 @@
|
|||
{
|
||||
"name": "chatgpt-clone",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "server/index.js",
|
||||
"scripts": {
|
||||
"start": "npx node server/index.js",
|
||||
"server-dev": "npx nodemon server/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/danny-avila/chatgpt-clone.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/danny-avila/chatgpt-clone/issues"
|
||||
},
|
||||
"homepage": "https://github.com/danny-avila/chatgpt-clone#readme",
|
||||
"dependencies": {
|
||||
"@keyv/mongo": "^2.1.8",
|
||||
"@waylaidwanderer/chatgpt-api": "^1.15.1",
|
||||
"cors": "^2.8.5",
|
||||
"dotenv": "^16.0.3",
|
||||
"keyv": "^4.5.2",
|
||||
"keyv-file": "^0.2.0",
|
||||
"mongoose": "^6.9.0",
|
||||
"openai": "^3.1.0",
|
||||
"swr": "^2.0.3",
|
||||
"tailwind-merge": "^1.9.1",
|
||||
"tailwindcss-animate": "^1.0.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nodemon": "^2.0.20",
|
||||
"path": "^0.12.7"
|
||||
}
|
||||
}
|
|
@ -4,8 +4,8 @@ const path = require('path');
|
|||
const cors = require('cors');
|
||||
const routes = require('./routes');
|
||||
const app = express();
|
||||
const port = 3050;
|
||||
const projectPath = path.join(__dirname, '..');
|
||||
const port = process.env.PORT || 3050;
|
||||
const projectPath = path.join(__dirname, '..', '..');
|
||||
dbConnect().then(() => console.log('Connected to MongoDB'));
|
||||
|
||||
app.use(cors());
|
2921
package-lock.json
generated
2921
package-lock.json
generated
File diff suppressed because it is too large
Load diff
14
package.json
14
package.json
|
@ -1,27 +1,27 @@
|
|||
{
|
||||
"name": "rpp2210-mvp",
|
||||
"name": "chatgpt-clone",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"start": "webpack-dev-server .",
|
||||
"build": "Webpack .",
|
||||
"server": "npx node server/index.js",
|
||||
"server": "npx node api/server/index.js",
|
||||
"build-dev": "Webpack . --watch",
|
||||
"server-dev": "npx nodemon server/index.js",
|
||||
"server-dev": "npx nodemon api/server/index.js",
|
||||
"test": "test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/danny-avila/rpp2210-mvp.git"
|
||||
"url": "git+https://github.com/danny-avila/chatgpt-clone.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/danny-avila/rpp2210-mvp/issues"
|
||||
"url": "https://github.com/danny-avila/chatgpt-clone/issues"
|
||||
},
|
||||
"homepage": "https://github.com/danny-avila/rpp2210-mvp#readme",
|
||||
"homepage": "https://github.com/danny-avila/chatgpt-clone#readme",
|
||||
"dependencies": {
|
||||
"@keyv/mongo": "^2.1.8",
|
||||
"@radix-ui/react-alert-dialog": "^1.0.2",
|
||||
|
@ -32,7 +32,6 @@
|
|||
"@reduxjs/toolkit": "^1.9.2",
|
||||
"@vscode/vscode-languagedetection": "^1.0.22",
|
||||
"@waylaidwanderer/chatgpt-api": "^1.15.1",
|
||||
"chatgpt": "^4.2.0",
|
||||
"class-variance-authority": "^0.4.0",
|
||||
"clsx": "^1.2.1",
|
||||
"cors": "^2.8.5",
|
||||
|
@ -50,7 +49,6 @@
|
|||
"react-redux": "^8.0.5",
|
||||
"react-textarea-autosize": "^8.4.0",
|
||||
"react-transition-group": "^4.4.5",
|
||||
"remark-supersub": "^1.0.0",
|
||||
"swr": "^2.0.3",
|
||||
"tailwind-merge": "^1.9.1",
|
||||
"tailwindcss-animate": "^1.0.5",
|
||||
|
|
|
@ -23,8 +23,8 @@ export default function Conversation({
|
|||
const { modelMap } = useSelector((state) => state.models);
|
||||
const inputRef = useRef(null);
|
||||
const dispatch = useDispatch();
|
||||
const { trigger } = manualSWR(`http://localhost:3050/messages/${id}`, 'get');
|
||||
const rename = manualSWR(`http://localhost:3050/convos/update`, 'post');
|
||||
const { trigger } = manualSWR(`http://localhost:3080/messages/${id}`, 'get');
|
||||
const rename = manualSWR(`http://localhost:3080/convos/update`, 'post');
|
||||
|
||||
const clickHandler = async () => {
|
||||
if (conversationId === id) {
|
||||
|
|
|
@ -9,7 +9,7 @@ import { setMessages } from '~/store/messageSlice';
|
|||
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
|
||||
const dispatch = useDispatch();
|
||||
const { trigger } = manualSWR(
|
||||
'http://localhost:3050/convos/clear',
|
||||
`http://localhost:3080/convos/clear`,
|
||||
'post',
|
||||
() => {
|
||||
dispatch(setMessages([]));
|
||||
|
|
|
@ -23,7 +23,7 @@ export default function ModelDialog({ mutate, modelMap }) {
|
|||
const [saveText, setSaveText] = useState('Save');
|
||||
const [required, setRequired] = useState(false);
|
||||
const inputRef = useRef(null);
|
||||
const updateCustomGpt = manualSWR('http://localhost:3050/customGpts/', 'post');
|
||||
const updateCustomGpt = manualSWR(`http://localhost:3080/customGpts/`, 'post');
|
||||
|
||||
const submitHandler = (e) => {
|
||||
if (chatGptLabel.length === 0) {
|
||||
|
|
|
@ -25,7 +25,7 @@ export default function ModelMenu() {
|
|||
const dispatch = useDispatch();
|
||||
const { model, customModel } = useSelector((state) => state.submit);
|
||||
const { models, modelMap, initial } = useSelector((state) => state.models);
|
||||
const { trigger } = manualSWR('http://localhost:3050/customGpts', 'get', (res) => {
|
||||
const { trigger } = manualSWR(`http://localhost:3080/customGpts`, 'get', (res) => {
|
||||
console.log('models data (response)', res);
|
||||
if (models.length + res.length === models.length) {
|
||||
return;
|
||||
|
|
|
@ -11,12 +11,12 @@ export default function ClearConvos() {
|
|||
const { mutate } = useSWRConfig()
|
||||
|
||||
const { trigger } = manualSWR(
|
||||
'http://localhost:3050/convos/clear',
|
||||
`http://localhost:3080/convos/clear`,
|
||||
'post',
|
||||
() => {
|
||||
dispatch(setMessages([]));
|
||||
dispatch(setConversation({ error: false, title: 'New chat', conversationId: null, parentMessageId: null }));
|
||||
mutate('http://localhost:3050/convos');
|
||||
mutate(`http://localhost:3080/convos`);
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ export default function Nav() {
|
|||
};
|
||||
|
||||
const { data, isLoading, mutate } = swr(
|
||||
`http://localhost:3050/convos?pageNumber=${pageNumber}`
|
||||
`http://localhost:3080/convos?pageNumber=${pageNumber}`
|
||||
, onSuccess);
|
||||
const containerRef = useRef(null);
|
||||
const scrollPositionRef = useRef(null);
|
||||
|
|
|
@ -29,7 +29,10 @@ const currentSlice = createSlice({
|
|||
state.pageNumber = state.pageNumber + 1;
|
||||
},
|
||||
setConvos: (state, action) => {
|
||||
state.convos = [...state.convos, ...action.payload];
|
||||
const newConvos = action.payload.filter((convo) => {
|
||||
return !state.convos.some((c) => c.conversationId === convo.conversationId);
|
||||
});
|
||||
state.convos = [...state.convos, ...newConvos];
|
||||
},
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { SSE } from '../../app/sse';
|
||||
const endpoint = 'http://localhost:3050/ask';
|
||||
import { SSE } from './sse';
|
||||
// const newLineRegex = /^\n+/;
|
||||
|
||||
export default function handleSubmit({
|
||||
|
@ -12,6 +11,7 @@ export default function handleSubmit({
|
|||
chatGptLabel,
|
||||
promptPrefix
|
||||
}) {
|
||||
const endpoint = `http://localhost:3080/ask`;
|
||||
let payload = { model, text, chatGptLabel, promptPrefix };
|
||||
if (convo.conversationId && convo.parentMessageId) {
|
||||
payload = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue