convo change also changes model selection

This commit is contained in:
Daniel Avila 2023-03-04 21:10:45 -05:00
parent d64f914552
commit fc899da944
4 changed files with 23 additions and 10 deletions

View file

@ -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(''));