mirror of https://github.com/buster-so/buster.git
Merge branch 'big-nate/bus-939-create-new-structure-for-chats' into nate/create-component-library
This commit is contained in:
commit
493698f42c
|
@ -48,15 +48,15 @@ export type BusterChatMessageReasoning =
|
||||||
| BusterChatMessageReasoning_text
|
| BusterChatMessageReasoning_text
|
||||||
| BusterChatMessageReasoning_file;
|
| BusterChatMessageReasoning_file;
|
||||||
|
|
||||||
export type BusterChatMessageReasoning_pillsPill = {
|
export type BusterChatMessageReasoning_Pill = {
|
||||||
text: string;
|
text: string;
|
||||||
type: ThoughtFileType | null; //if null then the pill will not link anywhere
|
type: ThoughtFileType | null; //if null then the pill will not link anywhere
|
||||||
id: string;
|
id: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BusterChatMessageReasoning_pillsPillContainer = {
|
export type BusterChatMessageReasoning_PillsContainer = {
|
||||||
title: string;
|
title: string;
|
||||||
thought_pills: BusterChatMessageReasoning_pillsPill[];
|
pills: BusterChatMessageReasoning_Pill[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export type BusterChatMessageReasoning_status = 'loading' | 'completed' | 'failed';
|
export type BusterChatMessageReasoning_status = 'loading' | 'completed' | 'failed';
|
||||||
|
@ -65,8 +65,8 @@ export type BusterChatMessageReasoning_pills = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'pills';
|
type: 'pills';
|
||||||
title: string;
|
title: string;
|
||||||
secondary_title: string;
|
secondary_title?: string;
|
||||||
pill_containers?: BusterChatMessageReasoning_pillsPillContainer[];
|
pill_containers?: BusterChatMessageReasoning_PillsContainer[];
|
||||||
status?: BusterChatMessageReasoning_status; //if left undefined, will automatically be set to 'loading' if the chat stream is in progress AND there is no message after it
|
status?: BusterChatMessageReasoning_status; //if left undefined, will automatically be set to 'loading' if the chat stream is in progress AND there is no message after it
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,6 +74,7 @@ export type BusterChatMessageReasoning_text = {
|
||||||
id: string;
|
id: string;
|
||||||
type: 'text';
|
type: 'text';
|
||||||
title: string;
|
title: string;
|
||||||
|
secondary_title?: string;
|
||||||
message?: string;
|
message?: string;
|
||||||
message_chunk?: string;
|
message_chunk?: string;
|
||||||
status?: BusterChatMessageReasoning_status;
|
status?: BusterChatMessageReasoning_status;
|
||||||
|
|
|
@ -5,8 +5,8 @@ import {
|
||||||
type BusterChatMessageRequest,
|
type BusterChatMessageRequest,
|
||||||
BusterChatMessage_fileMetadata,
|
BusterChatMessage_fileMetadata,
|
||||||
BusterChatMessageReasoning_pills,
|
BusterChatMessageReasoning_pills,
|
||||||
BusterChatMessageReasoning_file,
|
BusterChatMessageReasoning_Pill,
|
||||||
BusterChatMessageReasoning_pillsPill
|
BusterChatMessageReasoning_file
|
||||||
} from '@/api/asset_interfaces';
|
} from '@/api/asset_interfaces';
|
||||||
import { faker } from '@faker-js/faker';
|
import { faker } from '@faker-js/faker';
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ export const createMockResponseMessageText = (): BusterChatMessage_text => ({
|
||||||
|
|
||||||
export const createMockResponseMessageThought = (): BusterChatMessageReasoning_pills => {
|
export const createMockResponseMessageThought = (): BusterChatMessageReasoning_pills => {
|
||||||
const randomPillCount = faker.number.int({ min: 0, max: 10 });
|
const randomPillCount = faker.number.int({ min: 0, max: 10 });
|
||||||
const fourRandomPills: BusterChatMessageReasoning_pillsPill[] = Array.from(
|
const fourRandomPills: BusterChatMessageReasoning_Pill[] = Array.from(
|
||||||
{ length: randomPillCount },
|
{ length: randomPillCount },
|
||||||
() => {
|
() => {
|
||||||
return {
|
return {
|
||||||
|
@ -49,11 +49,11 @@ export const createMockResponseMessageThought = (): BusterChatMessageReasoning_p
|
||||||
pill_containers: [
|
pill_containers: [
|
||||||
{
|
{
|
||||||
title: `Found ${faker.number.int(100)} terms`,
|
title: `Found ${faker.number.int(100)} terms`,
|
||||||
thought_pills: fourRandomPills
|
pills: fourRandomPills
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: `Found ${faker.number.int(100)} terms 2`,
|
title: `Found ${faker.number.int(100)} terms 2`,
|
||||||
thought_pills: fourRandomPills
|
pills: fourRandomPills
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
status: undefined
|
status: undefined
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { BusterChatMessageReasoning_pillsPillContainer } from '@/api/asset_interfaces';
|
import { BusterChatMessageReasoning_PillsContainer } from '@/api/asset_interfaces';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Text } from '@/components/ui';
|
import { Text } from '@/components/ui';
|
||||||
import { PillContainer } from './ReasoningMessage_ThoughtPills';
|
import { PillContainer } from './ReasoningMessage_ThoughtPills';
|
||||||
|
@ -6,7 +6,7 @@ import { itemAnimationConfig } from '../animationConfig';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
|
|
||||||
export const ReasoningMessage_ThoughtContainer: React.FC<{
|
export const ReasoningMessage_ThoughtContainer: React.FC<{
|
||||||
pillContainer: BusterChatMessageReasoning_pillsPillContainer;
|
pillContainer: BusterChatMessageReasoning_PillsContainer;
|
||||||
isCompletedStream: boolean;
|
isCompletedStream: boolean;
|
||||||
}> = React.memo(({ pillContainer, isCompletedStream }) => {
|
}> = React.memo(({ pillContainer, isCompletedStream }) => {
|
||||||
return (
|
return (
|
||||||
|
@ -16,10 +16,7 @@ export const ReasoningMessage_ThoughtContainer: React.FC<{
|
||||||
<Text size="xs" type="tertiary">
|
<Text size="xs" type="tertiary">
|
||||||
{pillContainer.title}
|
{pillContainer.title}
|
||||||
</Text>
|
</Text>
|
||||||
<PillContainer
|
<PillContainer pills={pillContainer.pills} isCompletedStream={isCompletedStream} />
|
||||||
pills={pillContainer.thought_pills}
|
|
||||||
isCompletedStream={isCompletedStream}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { BusterChatMessageReasoning_pillsPill } from '@/api/asset_interfaces';
|
import type { BusterChatMessageReasoning_Pill } from '@/api/asset_interfaces';
|
||||||
import { createStyles } from 'antd-style';
|
import { createStyles } from 'antd-style';
|
||||||
import React, { useMemo } from 'react';
|
import React, { useMemo } from 'react';
|
||||||
import { AnimatePresence, motion } from 'framer-motion';
|
import { AnimatePresence, motion } from 'framer-motion';
|
||||||
|
@ -36,7 +36,7 @@ const pillVariants = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const PillContainer: React.FC<{
|
export const PillContainer: React.FC<{
|
||||||
pills: BusterChatMessageReasoning_pillsPill[];
|
pills: BusterChatMessageReasoning_Pill[];
|
||||||
isCompletedStream: boolean;
|
isCompletedStream: boolean;
|
||||||
}> = React.memo(({ pills = [], isCompletedStream }) => {
|
}> = React.memo(({ pills = [], isCompletedStream }) => {
|
||||||
const { cx } = useStyles();
|
const { cx } = useStyles();
|
||||||
|
@ -45,7 +45,7 @@ export const PillContainer: React.FC<{
|
||||||
const useAnimation = !isCompletedStream;
|
const useAnimation = !isCompletedStream;
|
||||||
|
|
||||||
const handlePillClick = useMemoizedFn(
|
const handlePillClick = useMemoizedFn(
|
||||||
(pill: Pick<BusterChatMessageReasoning_pillsPill, 'id' | 'type'>) => {
|
(pill: Pick<BusterChatMessageReasoning_Pill, 'id' | 'type'>) => {
|
||||||
if (isOpenableFile(pill.type)) {
|
if (isOpenableFile(pill.type)) {
|
||||||
onSetSelectedFile(pill as SelectedFile);
|
onSetSelectedFile(pill as SelectedFile);
|
||||||
}
|
}
|
||||||
|
@ -78,10 +78,10 @@ PillContainer.displayName = 'PillContainer';
|
||||||
const Pill: React.FC<{
|
const Pill: React.FC<{
|
||||||
text: string;
|
text: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
type?: BusterChatMessageReasoning_pillsPill['type'];
|
type?: BusterChatMessageReasoning_Pill['type'];
|
||||||
useAnimation: boolean;
|
useAnimation: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
onClick?: (pill: Pick<BusterChatMessageReasoning_pillsPill, 'id' | 'type'>) => void;
|
onClick?: (pill: Pick<BusterChatMessageReasoning_Pill, 'id' | 'type'>) => void;
|
||||||
}> = React.memo(({ text, type, id, useAnimation, className = '', onClick }) => {
|
}> = React.memo(({ text, type, id, useAnimation, className = '', onClick }) => {
|
||||||
const { styles, cx } = useStyles();
|
const { styles, cx } = useStyles();
|
||||||
return (
|
return (
|
||||||
|
@ -110,9 +110,9 @@ const OverflowPill = React.memo(
|
||||||
useAnimation,
|
useAnimation,
|
||||||
onClickPill
|
onClickPill
|
||||||
}: {
|
}: {
|
||||||
hiddenPills: BusterChatMessageReasoning_pillsPill[];
|
hiddenPills: BusterChatMessageReasoning_Pill[];
|
||||||
useAnimation: boolean;
|
useAnimation: boolean;
|
||||||
onClickPill: (pill: Pick<BusterChatMessageReasoning_pillsPill, 'id' | 'type'>) => void;
|
onClickPill: (pill: Pick<BusterChatMessageReasoning_Pill, 'id' | 'type'>) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const count = hiddenPills.length;
|
const count = hiddenPills.length;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue