mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-25 20:58:50 +01:00
loads up to 20 messages, debugging markdown issue
This commit is contained in:
parent
4e6168d8fa
commit
d56aa2edef
19 changed files with 329 additions and 625 deletions
|
|
@ -1,3 +1,6 @@
|
|||
const even = 'w-full border-b border-black/10 dark:border-gray-900/50 text-gray-800 bg-white dark:text-gray-100 group dark:bg-gray-800 hover:bg-gray-100/25 hover:text-gray-700 dark:hover:bg-[#32343e] dark:hover:text-gray-200';
|
||||
const odd = 'w-full border-b border-black/10 bg-gray-50 dark:border-gray-900/50 text-gray-800 dark:text-gray-100 group bg-gray-100 dark:bg-[#444654] hover:bg-gray-100/40 hover:text-gray-700 dark:hover:bg-[#3b3d49] dark:hover:text-gray-200';
|
||||
|
||||
export default function buildTree(messages, groupAll = false) {
|
||||
let messageMap = {};
|
||||
let rootMessages = [];
|
||||
|
|
@ -16,14 +19,15 @@ export default function buildTree(messages, groupAll = false) {
|
|||
}
|
||||
|
||||
// Group all messages into one tree
|
||||
let parentId = messages[0].messageId;
|
||||
let parentId = null;
|
||||
messages.forEach((message, i) => {
|
||||
if (i === 0) {
|
||||
messageMap[parentId] = { ...message, children: [] };
|
||||
return;
|
||||
}
|
||||
messageMap[parentId].children.push({ ...message, children: [] });
|
||||
messageMap[message.messageId] = { ...message, bg: i % 2 === 0 ? even : odd, children: [] };
|
||||
const currentMessage = messageMap[message.messageId];
|
||||
const parentMessage = messageMap[parentId];
|
||||
if (parentMessage) parentMessage.children.push(currentMessage);
|
||||
else rootMessages.push(currentMessage);
|
||||
parentId = message.messageId;
|
||||
});
|
||||
|
||||
return [messageMap[parentId]];
|
||||
return rootMessages;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,12 @@ export const searchFetcher = async (pre, q, pageNumber, callback) => {
|
|||
callback(data);
|
||||
};
|
||||
|
||||
export const fetchById = async (path, conversationId) => {
|
||||
return await axios.get(`/api/${path}/${conversationId}`);
|
||||
// console.log(`fetch ${path} data`, data);
|
||||
// callback(data);
|
||||
};
|
||||
|
||||
export const swr = (path, successCallback, options) => {
|
||||
const _options = { ...options };
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,9 @@ export const wrapperRegex = {
|
|||
newLineMatch: /^```(\n+)/
|
||||
};
|
||||
|
||||
export const getIconOfModel = ({ size=30, sender, isCreatedByUser, model, chatGptLabel, error, ...props }) => {
|
||||
export const getIconOfModel = ({ size=30, sender, isCreatedByUser, searchResult, model, chatGptLabel, error, ...props }) => {
|
||||
// 'ai' is used as 'model' is not accurate for search results
|
||||
let ai = searchResult ? sender : model;
|
||||
const { button } = props;
|
||||
const bgColors = {
|
||||
chatgpt: `rgb(16, 163, 127${ button ? ', 0.75' : ''})`,
|
||||
|
|
@ -69,12 +71,12 @@ export const getIconOfModel = ({ size=30, sender, isCreatedByUser, model, chatGp
|
|||
else if (!isCreatedByUser) {
|
||||
// TODO: use model from convo, rather than submit
|
||||
// const { model, chatGptLabel, promptPrefix } = convo;
|
||||
let background = bgColors[model];
|
||||
const isBing = model === 'bingai' || model === 'sydney';
|
||||
let background = bgColors[ai];
|
||||
const isBing = ai === 'bingai' || ai === 'sydney';
|
||||
|
||||
return (
|
||||
<div
|
||||
title={chatGptLabel || model}
|
||||
title={chatGptLabel || ai}
|
||||
style={
|
||||
{ background: background || 'radial-gradient(circle at 90% 110%, #F0F0FA, #D0E0F9)', width: size, height: size }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue