Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

convo change also changes model selection

Daniel Avilafc899da944df
diff --git a/src/components/Conversations/Conversation.jsx b/src/components/Conversations/Conversation.jsx
index 17ad16eec7..7210c9d820 100644
--- a/src/components/Conversations/Conversation.jsx
+++ b/src/components/Conversations/Conversation.jsx
@@ -1,9 +1,9 @@
import React, { useState, useRef } from 'react';
import RenameButton from './RenameButton';
import DeleteButton from './DeleteButton';
-import { useDispatch } from 'react-redux';
+import { useSelector, useDispatch } from 'react-redux';
import { setConversation } from '~/store/convoSlice';
-import { setCustomGpt, setModel } from '~/store/submitSlice';
+import { setCustomGpt, setModel, setCustomModel } from '~/store/submitSlice';
import { setMessages } from '~/store/messageSlice';
import { setText } from '~/store/textSlice';
import manualSWR from '~/utils/fetchers';
@@ -20,6 +20,7 @@ export default function Conversation({
}) {
const [renaming, setRenaming] = useState(false);
const [titleInput, setTitleInput] = useState(title);
+ const { modelMap } = useSelector((state) => state.models);
const inputRef = useRef(null);
const dispatch = useDispatch();
const { trigger } = manualSWR(`http://localhost:3050/messages/${id}`, 'get');
@@ -62,6 +63,13 @@ export default function Conversation({
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(setCustomGpt(convo));
dispatch(setText(''));
diff --git a/src/components/Models/ModelMenu.jsx b/src/components/Models/ModelMenu.jsx
index 69a8c76c68..8074c89b6f 100644
--- a/src/components/Models/ModelMenu.jsx
+++ b/src/components/Models/ModelMenu.jsx
@@ -1,6 +1,6 @@
-import React, { useState, useEffect } from 'react';
+import React, { useEffect } from 'react';
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 ModelDialog from './ModelDialog';
import MenuItems from './MenuItems';
@@ -23,8 +23,7 @@ import { Dialog } from '../ui/Dialog.tsx';
export default function ModelMenu() {
const dispatch = useDispatch();
- const { model } = useSelector((state) => state.submit);
- const [customModel, setCustomModel] = useState(false);
+ const { model, customModel } = useSelector((state) => state.submit);
const { models, modelMap, initial } = useSelector((state) => state.models);
const { trigger } = manualSWR('http://localhost:3050/customGpts', 'get', (res) => {
console.log('models data (response)', res);
@@ -69,13 +68,15 @@ export default function ModelMenu() {
} else if (initial[value]) {
dispatch(setModel(value));
dispatch(setDisabled(false));
- setCustomModel(false);
+ setCustomModel(null);
} else if (!initial[value]) {
const chatGptLabel = modelMap[value]?.chatGptLabel;
const promptPrefix = modelMap[value]?.promptPrefix;
dispatch(setCustomGpt({ chatGptLabel, promptPrefix }));
dispatch(setModel('chatgptCustom'));
setCustomModel(value);
+ } else if (!modelMap[value]) {
+ setCustomModel(null);
}
// Set new conversation
@@ -84,7 +85,7 @@ export default function ModelMenu() {
title: 'New Chat',
error: false,
conversationId: null,
- parentMessageId: null,
+ parentMessageId: null
})
);
};
diff --git a/src/store/modelSlice.js b/src/store/modelSlice.js
index 473d0dc407..c13c9a899a 100644
--- a/src/store/modelSlice.js
+++ b/src/store/modelSlice.js
@@ -32,7 +32,6 @@ const currentSlice = createSlice({
initialState,
reducers: {
setModels: (state, action) => {
- console.log('setModels', action.payload);
const models = [...initialState.models, ...action.payload];
state.models = models;
const modelMap = {};
diff --git a/src/store/submitSlice.js b/src/store/submitSlice.js
index 835c0b2496..b659ddcc7d 100644
--- a/src/store/submitSlice.js
+++ b/src/store/submitSlice.js
@@ -6,6 +6,7 @@ const initialState = {
model: 'chatgpt',
promptPrefix: '',
chatGptLabel: '',
+ customModel: null
};
const currentSlice = createSlice({
@@ -25,9 +26,13 @@ const currentSlice = createSlice({
state.promptPrefix = action.payload.promptPrefix;
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;