mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 17:00:15 +01:00
convo change also changes model selection
This commit is contained in:
parent
d64f914552
commit
fc899da944
4 changed files with 23 additions and 10 deletions
|
|
@ -1,9 +1,9 @@
|
||||||
import React, { useState, useRef } from 'react';
|
import React, { useState, useRef } from 'react';
|
||||||
import RenameButton from './RenameButton';
|
import RenameButton from './RenameButton';
|
||||||
import DeleteButton from './DeleteButton';
|
import DeleteButton from './DeleteButton';
|
||||||
import { useDispatch } from 'react-redux';
|
import { useSelector, useDispatch } from 'react-redux';
|
||||||
import { setConversation } from '~/store/convoSlice';
|
import { setConversation } from '~/store/convoSlice';
|
||||||
import { setCustomGpt, setModel } from '~/store/submitSlice';
|
import { setCustomGpt, setModel, setCustomModel } from '~/store/submitSlice';
|
||||||
import { setMessages } from '~/store/messageSlice';
|
import { setMessages } from '~/store/messageSlice';
|
||||||
import { setText } from '~/store/textSlice';
|
import { setText } from '~/store/textSlice';
|
||||||
import manualSWR from '~/utils/fetchers';
|
import manualSWR from '~/utils/fetchers';
|
||||||
|
|
@ -20,6 +20,7 @@ export default function Conversation({
|
||||||
}) {
|
}) {
|
||||||
const [renaming, setRenaming] = useState(false);
|
const [renaming, setRenaming] = useState(false);
|
||||||
const [titleInput, setTitleInput] = useState(title);
|
const [titleInput, setTitleInput] = useState(title);
|
||||||
|
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:3050/messages/${id}`, 'get');
|
const { trigger } = manualSWR(`http://localhost:3050/messages/${id}`, 'get');
|
||||||
|
|
@ -62,6 +63,13 @@ export default function Conversation({
|
||||||
dispatch(setModel(data[1].sender));
|
dispatch(setModel(data[1].sender));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (modelMap[data[1].sender.toLowerCase()]) {
|
||||||
|
console.log('sender', data[1].sender);
|
||||||
|
dispatch(setCustomModel(data[1].sender.toLowerCase()));
|
||||||
|
} else {
|
||||||
|
dispatch(setCustomModel(null));
|
||||||
|
}
|
||||||
|
|
||||||
dispatch(setMessages(data));
|
dispatch(setMessages(data));
|
||||||
dispatch(setCustomGpt(convo));
|
dispatch(setCustomGpt(convo));
|
||||||
dispatch(setText(''));
|
dispatch(setText(''));
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import { useSelector, useDispatch } from 'react-redux';
|
import { useSelector, useDispatch } from 'react-redux';
|
||||||
import { setModel, setDisabled, setCustomGpt } from '~/store/submitSlice';
|
import { setModel, setDisabled, setCustomGpt, setCustomModel } from '~/store/submitSlice';
|
||||||
import { setConversation } from '~/store/convoSlice';
|
import { setConversation } from '~/store/convoSlice';
|
||||||
import ModelDialog from './ModelDialog';
|
import ModelDialog from './ModelDialog';
|
||||||
import MenuItems from './MenuItems';
|
import MenuItems from './MenuItems';
|
||||||
|
|
@ -23,8 +23,7 @@ import { Dialog } from '../ui/Dialog.tsx';
|
||||||
|
|
||||||
export default function ModelMenu() {
|
export default function ModelMenu() {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const { model } = useSelector((state) => state.submit);
|
const { model, customModel } = useSelector((state) => state.submit);
|
||||||
const [customModel, setCustomModel] = useState(false);
|
|
||||||
const { models, modelMap, initial } = useSelector((state) => state.models);
|
const { models, modelMap, initial } = useSelector((state) => state.models);
|
||||||
const { trigger } = manualSWR('http://localhost:3050/customGpts', 'get', (res) => {
|
const { trigger } = manualSWR('http://localhost:3050/customGpts', 'get', (res) => {
|
||||||
console.log('models data (response)', res);
|
console.log('models data (response)', res);
|
||||||
|
|
@ -69,13 +68,15 @@ export default function ModelMenu() {
|
||||||
} else if (initial[value]) {
|
} else if (initial[value]) {
|
||||||
dispatch(setModel(value));
|
dispatch(setModel(value));
|
||||||
dispatch(setDisabled(false));
|
dispatch(setDisabled(false));
|
||||||
setCustomModel(false);
|
setCustomModel(null);
|
||||||
} else if (!initial[value]) {
|
} else if (!initial[value]) {
|
||||||
const chatGptLabel = modelMap[value]?.chatGptLabel;
|
const chatGptLabel = modelMap[value]?.chatGptLabel;
|
||||||
const promptPrefix = modelMap[value]?.promptPrefix;
|
const promptPrefix = modelMap[value]?.promptPrefix;
|
||||||
dispatch(setCustomGpt({ chatGptLabel, promptPrefix }));
|
dispatch(setCustomGpt({ chatGptLabel, promptPrefix }));
|
||||||
dispatch(setModel('chatgptCustom'));
|
dispatch(setModel('chatgptCustom'));
|
||||||
setCustomModel(value);
|
setCustomModel(value);
|
||||||
|
} else if (!modelMap[value]) {
|
||||||
|
setCustomModel(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set new conversation
|
// Set new conversation
|
||||||
|
|
@ -84,7 +85,7 @@ export default function ModelMenu() {
|
||||||
title: 'New Chat',
|
title: 'New Chat',
|
||||||
error: false,
|
error: false,
|
||||||
conversationId: null,
|
conversationId: null,
|
||||||
parentMessageId: null,
|
parentMessageId: null
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ const currentSlice = createSlice({
|
||||||
initialState,
|
initialState,
|
||||||
reducers: {
|
reducers: {
|
||||||
setModels: (state, action) => {
|
setModels: (state, action) => {
|
||||||
console.log('setModels', action.payload);
|
|
||||||
const models = [...initialState.models, ...action.payload];
|
const models = [...initialState.models, ...action.payload];
|
||||||
state.models = models;
|
state.models = models;
|
||||||
const modelMap = {};
|
const modelMap = {};
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ const initialState = {
|
||||||
model: 'chatgpt',
|
model: 'chatgpt',
|
||||||
promptPrefix: '',
|
promptPrefix: '',
|
||||||
chatGptLabel: '',
|
chatGptLabel: '',
|
||||||
|
customModel: null
|
||||||
};
|
};
|
||||||
|
|
||||||
const currentSlice = createSlice({
|
const currentSlice = createSlice({
|
||||||
|
|
@ -25,9 +26,13 @@ const currentSlice = createSlice({
|
||||||
state.promptPrefix = action.payload.promptPrefix;
|
state.promptPrefix = action.payload.promptPrefix;
|
||||||
state.chatGptLabel = action.payload.chatGptLabel;
|
state.chatGptLabel = action.payload.chatGptLabel;
|
||||||
},
|
},
|
||||||
|
setCustomModel: (state, action) => {
|
||||||
|
state.customModel = action.payload;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const { setSubmitState, setDisabled, setModel, setCustomGpt } = currentSlice.actions;
|
export const { setSubmitState, setDisabled, setModel, setCustomGpt, setCustomModel } =
|
||||||
|
currentSlice.actions;
|
||||||
|
|
||||||
export default currentSlice.reducer;
|
export default currentSlice.reducer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue