mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-03-10 18:12:35 +01:00
Merge pull request #19 from wtlyu/master
support config host name and proxy address.
This commit is contained in:
commit
0b3b6f91fc
13 changed files with 24 additions and 14 deletions
|
|
@ -1,7 +1,13 @@
|
||||||
OPENAI_KEY=
|
OPENAI_KEY=
|
||||||
|
HOST=
|
||||||
PORT=3080
|
PORT=3080
|
||||||
NODE_ENV=development
|
NODE_ENV=development
|
||||||
|
|
||||||
# Change this to your MongoDB URI if different and I recommend appending chatgpt-clone
|
# Change this to your MongoDB URI if different and I recommend appending chatgpt-clone
|
||||||
MONGO_URI="mongodb://127.0.0.1:27017/chatgpt-clone"
|
MONGO_URI="mongodb://127.0.0.1:27017/chatgpt-clone"
|
||||||
|
|
||||||
|
# Change this to proxy any request.
|
||||||
|
PROXY=
|
||||||
|
|
||||||
CHATGPT_TOKEN=""
|
CHATGPT_TOKEN=""
|
||||||
BING_TOKEN=""
|
BING_TOKEN=""
|
||||||
|
|
@ -7,6 +7,7 @@ const clientOptions = {
|
||||||
// Access token from https://chat.openai.com/api/auth/session
|
// Access token from https://chat.openai.com/api/auth/session
|
||||||
accessToken: process.env.CHATGPT_TOKEN,
|
accessToken: process.env.CHATGPT_TOKEN,
|
||||||
// debug: true
|
// debug: true
|
||||||
|
proxy: process.env.PROXY || null,
|
||||||
};
|
};
|
||||||
|
|
||||||
const browserClient = async ({ text, progressCallback, convo }) => {
|
const browserClient = async ({ text, progressCallback, convo }) => {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ const clientOptions = {
|
||||||
modelOptions: {
|
modelOptions: {
|
||||||
model: 'gpt-3.5-turbo'
|
model: 'gpt-3.5-turbo'
|
||||||
},
|
},
|
||||||
|
proxy: process.env.PROXY || null,
|
||||||
debug: false
|
debug: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ const clientOptions = {
|
||||||
modelOptions: {
|
modelOptions: {
|
||||||
model: 'gpt-3.5-turbo'
|
model: 'gpt-3.5-turbo'
|
||||||
},
|
},
|
||||||
|
proxy: process.env.PROXY || null,
|
||||||
debug: false
|
debug: false
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ const cors = require('cors');
|
||||||
const routes = require('./routes');
|
const routes = require('./routes');
|
||||||
const app = express();
|
const app = express();
|
||||||
const port = process.env.PORT || 3080;
|
const port = process.env.PORT || 3080;
|
||||||
|
const host = process.env.HOST || 'localhost'
|
||||||
const projectPath = path.join(__dirname, '..', '..', 'client');
|
const projectPath = path.join(__dirname, '..', '..', 'client');
|
||||||
dbConnect().then(() => console.log('Connected to MongoDB'));
|
dbConnect().then(() => console.log('Connected to MongoDB'));
|
||||||
|
|
||||||
|
|
@ -23,6 +24,6 @@ app.use('/api/convos', routes.convos);
|
||||||
app.use('/api/customGpts', routes.customGpts);
|
app.use('/api/customGpts', routes.customGpts);
|
||||||
app.use('/api/prompts', routes.prompts);
|
app.use('/api/prompts', routes.prompts);
|
||||||
|
|
||||||
app.listen(port, () => {
|
app.listen(port, host, () => {
|
||||||
console.log(`Server listening at http://localhost:${port}`);
|
console.log(`Server listening at http://${host}:${port}`);
|
||||||
});
|
});
|
||||||
|
|
@ -23,8 +23,8 @@ export default function Conversation({
|
||||||
const { modelMap } = useSelector((state) => state.models);
|
const { modelMap } = useSelector((state) => state.models);
|
||||||
const inputRef = useRef(null);
|
const inputRef = useRef(null);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { trigger } = manualSWR(`http://localhost:3080/api/messages/${id}`, 'get');
|
const { trigger } = manualSWR(`/api/messages/${id}`, 'get');
|
||||||
const rename = manualSWR(`http://localhost:3080/api/convos/update`, 'post');
|
const rename = manualSWR(`/api/convos/update`, 'post');
|
||||||
|
|
||||||
const clickHandler = async () => {
|
const clickHandler = async () => {
|
||||||
if (conversationId === id) {
|
if (conversationId === id) {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { setMessages } from '~/store/messageSlice';
|
||||||
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
|
export default function DeleteButton({ conversationId, renaming, cancelHandler }) {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { trigger } = manualSWR(
|
const { trigger } = manualSWR(
|
||||||
`http://localhost:3080/api/convos/clear`,
|
`/api/convos/clear`,
|
||||||
'post',
|
'post',
|
||||||
() => {
|
() => {
|
||||||
dispatch(setMessages([]));
|
dispatch(setMessages([]));
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export default function ModelDialog({ mutate, setModelSave, handleSaveState }) {
|
||||||
const [saveText, setSaveText] = useState('Save');
|
const [saveText, setSaveText] = useState('Save');
|
||||||
const [required, setRequired] = useState(false);
|
const [required, setRequired] = useState(false);
|
||||||
const inputRef = useRef(null);
|
const inputRef = useRef(null);
|
||||||
const updateCustomGpt = manualSWR(`http://localhost:3080/api/customGpts/`, 'post');
|
const updateCustomGpt = manualSWR(`/api/customGpts/`, 'post');
|
||||||
|
|
||||||
const submitHandler = (e) => {
|
const submitHandler = (e) => {
|
||||||
if (chatGptLabel.length === 0) {
|
if (chatGptLabel.length === 0) {
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ export default function ModelItem({ modelName, value, onSelect }) {
|
||||||
const [currentName, setCurrentName] = useState(modelName);
|
const [currentName, setCurrentName] = useState(modelName);
|
||||||
const [modelInput, setModelInput] = useState(modelName);
|
const [modelInput, setModelInput] = useState(modelName);
|
||||||
const inputRef = useRef(null);
|
const inputRef = useRef(null);
|
||||||
const rename = manualSWR(`http://localhost:3080/api/customGpts`, 'post');
|
const rename = manualSWR(`/api/customGpts`, 'post');
|
||||||
const deleteCustom = manualSWR(`http://localhost:3080/api/customGpts/delete`, 'post');
|
const deleteCustom = manualSWR(`/api/customGpts/delete`, 'post');
|
||||||
|
|
||||||
if (value === 'chatgptCustom') {
|
if (value === 'chatgptCustom') {
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ export default function ModelMenu() {
|
||||||
const [menuOpen, setMenuOpen] = useState(false);
|
const [menuOpen, setMenuOpen] = useState(false);
|
||||||
const { model, customModel } = useSelector((state) => state.submit);
|
const { model, customModel } = useSelector((state) => state.submit);
|
||||||
const { models, modelMap, initial } = useSelector((state) => state.models);
|
const { models, modelMap, initial } = useSelector((state) => state.models);
|
||||||
const { trigger } = manualSWR(`http://localhost:3080/api/customGpts`, 'get', (res) => {
|
const { trigger } = manualSWR(`/api/customGpts`, 'get', (res) => {
|
||||||
const fetchedModels = res.map((modelItem) => ({
|
const fetchedModels = res.map((modelItem) => ({
|
||||||
...modelItem,
|
...modelItem,
|
||||||
name: modelItem.chatGptLabel
|
name: modelItem.chatGptLabel
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,10 @@ export default function ClearConvos() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { mutate } = useSWRConfig();
|
const { mutate } = useSWRConfig();
|
||||||
|
|
||||||
const { trigger } = manualSWR(`http://localhost:3080/api/convos/clear`, 'post', () => {
|
const { trigger } = manualSWR(`/api/convos/clear`, 'post', () => {
|
||||||
dispatch(setMessages([]));
|
dispatch(setMessages([]));
|
||||||
dispatch(setNewConvo());
|
dispatch(setNewConvo());
|
||||||
mutate(`http://localhost:3080/api/convos`);
|
mutate(`/api/convos`);
|
||||||
});
|
});
|
||||||
|
|
||||||
const clickHandler = () => {
|
const clickHandler = () => {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ export default function Nav() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data, isLoading, mutate } = swr(
|
const { data, isLoading, mutate } = swr(
|
||||||
`http://localhost:3080/api/convos?pageNumber=${pageNumber}`,
|
`/api/convos?pageNumber=${pageNumber}`,
|
||||||
onSuccess
|
onSuccess
|
||||||
);
|
);
|
||||||
const containerRef = useRef(null);
|
const containerRef = useRef(null);
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ export default function handleSubmit({
|
||||||
chatGptLabel,
|
chatGptLabel,
|
||||||
promptPrefix
|
promptPrefix
|
||||||
}) {
|
}) {
|
||||||
const endpoint = `http://localhost:3080/api/ask`;
|
const endpoint = `/api/ask`;
|
||||||
let payload = { model, text, chatGptLabel, promptPrefix };
|
let payload = { model, text, chatGptLabel, promptPrefix };
|
||||||
if (convo.conversationId && convo.parentMessageId) {
|
if (convo.conversationId && convo.parentMessageId) {
|
||||||
payload = {
|
payload = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue