feat: view endpoint setting in message header.

This commit is contained in:
Wentao Lyu 2023-03-31 16:35:30 +08:00
parent babc4da7ab
commit a8e44d0028
2 changed files with 97 additions and 31 deletions

View file

@ -5,6 +5,7 @@ import { throttle } from 'lodash';
import { CSSTransition } from 'react-transition-group';
import ScrollToBottom from './ScrollToBottom';
import MultiMessage from './MultiMessage';
import MessageHeader from './MessageHeader';
import store from '~/store';
@ -20,13 +21,11 @@ export default function Messages({ isSearchView = false }) {
const _messagesTree = isSearchView ? searchResultMessagesTree : messagesTree;
const conversation = useRecoilValue(store.conversation) || {};
const { conversationId, endpoint } = conversation;
const { conversationId } = conversation;
// const models = useRecoilValue(store.models) || [];
// const modelName = models.find(element => element.model == model)?.name;
const searchQuery = useRecoilValue(store.searchQuery);
useEffect(() => {
const timeoutId = setTimeout(() => {
const { scrollTop, scrollHeight, clientHeight } = scrollableRef.current;
@ -79,31 +78,6 @@ export default function Messages({ isSearchView = false }) {
scrollToBottom();
};
const getConversationTitle = () => {
if (isSearchView) return `Search: ${searchQuery}`;
else {
let _title = `${endpoint}`;
if (endpoint === 'azureOpenAI' || endpoint === 'openAI') {
const { chatGptLabel, model } = conversation;
if (model) _title += `: ${model}`;
if (chatGptLabel) _title += ` as ${chatGptLabel}`;
} else if (endpoint === 'bingAI') {
const { jailbreak, toneStyle } = conversation;
if (toneStyle) _title += `: ${toneStyle}`;
if (jailbreak) _title += ` as Sydney`;
} else if (endpoint === 'chatGPTBrowser') {
const { model } = conversation;
if (model) _title += `: ${model}`;
} else if (endpoint === null) {
null;
} else {
null;
}
return _title;
}
};
return (
<div
className="flex-1 overflow-y-auto pt-0"
@ -112,9 +86,7 @@ export default function Messages({ isSearchView = false }) {
>
<div className="dark:gpt-dark-gray h-full">
<div className="dark:gpt-dark-gray flex h-full flex-col items-center text-sm">
<div className="flex w-full items-center justify-center gap-1 border-b border-black/10 bg-gray-50 p-3 text-sm text-gray-500 dark:border-gray-900/50 dark:bg-gray-700 dark:text-gray-300">
{getConversationTitle()}
</div>
<MessageHeader isSearchView={isSearchView} />
{_messagesTree === null ? (
<Spinner />
) : _messagesTree?.length == 0 && isSearchView ? (