diff --git a/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/_components/EvaluationEditor/Editor/Playground/Chat/index.tsx b/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/_components/EvaluationEditor/Editor/Playground/Chat/index.tsx index 7e6da5a2e..257fe4f21 100644 --- a/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/_components/EvaluationEditor/Editor/Playground/Chat/index.tsx +++ b/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/_components/EvaluationEditor/Editor/Playground/Chat/index.tsx @@ -156,7 +156,6 @@ export default function Chat({ messages={ conversation?.messages.slice(chainLength - 1, chainLength) ?? [] } - variant='accent' /> {endTime && } @@ -164,10 +163,7 @@ export default function Chat({ {(conversation?.messages.length ?? 0) > chainLength && ( <> Chat - + )} {error ? ( @@ -188,7 +184,7 @@ export default function Chat({ />
-
diff --git a/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/import-logs/page.tsx b/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/import-logs/page.tsx index c7951c22e..6aa02acfe 100644 --- a/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/import-logs/page.tsx +++ b/apps/web/src/app/(private)/evaluations/(evaluation)/[evaluationUuid]/editor/import-logs/page.tsx @@ -10,6 +10,7 @@ import { Button, CloseTrigger, Modal, + roleVariant, Table, TableBody, TableCell, @@ -225,19 +226,6 @@ const printMessageContent = (content: string | MessageContent[]) => { return '-' } -const roleVariant = (role: string) => { - switch (role) { - case 'user': - return 'purple' - case 'system': - return 'outline' - case 'assistant': - return 'yellow' - default: - return 'default' - } -} - function ellipsis(str: string) { if (!str) return null return str.length > 30 ? str.substring(0, 30) + '...' : str diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx index 9448a09d4..7b42cbdbd 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Chat.tsx @@ -210,7 +210,6 @@ export default function Chat({ messages={ conversation?.messages.slice(chainLength - 1, chainLength) ?? [] } - variant='accent' /> {time && } @@ -218,10 +217,7 @@ export default function Chat({ {(conversation?.messages.length ?? 0) > chainLength && ( <> Chat - + )} {error ? ( @@ -320,7 +316,6 @@ export function StreamMessage({ ) } @@ -329,7 +324,6 @@ export function StreamMessage({ ) } diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Preview.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Preview.tsx index 0a8adff3f..e99daed9b 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Preview.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/Preview.tsx @@ -59,10 +59,12 @@ export default function Preview({ ref={containerRef} className='flex flex-col gap-3 h-full overflow-y-auto' > - Preview - {(conversation?.messages ?? []).map((message, index) => ( - - ))} +
+ Preview + {(conversation?.messages ?? []).map((message, index) => ( + + ))} +
{error !== undefined && } {!completed && (
diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/index.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/index.tsx index 69029bfd8..c2feb6680 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/index.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/Playground/index.tsx @@ -65,7 +65,7 @@ export default function Playground({ )}
-
+
Inputs {Object.keys(inputs).length > 0 ? ( Object.entries(inputs).map(([param, value], idx) => ( diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/index.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/index.tsx index 7f9630c97..0dc62c44d 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/index.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/_components/DocumentEditor/Editor/index.tsx @@ -158,7 +158,7 @@ export default function DocumentEditor({ />
-
+
diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/EvaluationResults/EvaluationResultInfo/Messages.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/EvaluationResults/EvaluationResultInfo/Messages.tsx index 94438d66a..3ff743601 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/EvaluationResults/EvaluationResultInfo/Messages.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/evaluations/[evaluationId]/_components/EvaluationResults/EvaluationResultInfo/Messages.tsx @@ -22,12 +22,6 @@ export function EvaluationResultMessages({ }, [providerLog]) if (!providerLog) return null - return ( - - ) + + return } diff --git a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/logs/_components/DocumentLogs/DocumentLogInfo/Messages.tsx b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/logs/_components/DocumentLogs/DocumentLogInfo/Messages.tsx index d2f74c44d..246c5a404 100644 --- a/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/logs/_components/DocumentLogs/DocumentLogInfo/Messages.tsx +++ b/apps/web/src/app/(private)/projects/[projectId]/versions/[commitUuid]/documents/[documentUuid]/logs/_components/DocumentLogs/DocumentLogInfo/Messages.tsx @@ -23,12 +23,6 @@ export function DocumentLogMessages({ }, [providerLogs]) if (!providerLogs) return null - return ( - - ) + + return } diff --git a/packages/web-ui/src/ds/molecules/Chat/ErrorMessage/index.tsx b/packages/web-ui/src/ds/molecules/Chat/ErrorMessage/index.tsx index 674502be1..fb5cc3686 100644 --- a/packages/web-ui/src/ds/molecules/Chat/ErrorMessage/index.tsx +++ b/packages/web-ui/src/ds/molecules/Chat/ErrorMessage/index.tsx @@ -1,16 +1,11 @@ -import { CompileError, ContentType } from '@latitude-data/compiler' +import { CompileError } from '@latitude-data/compiler' -import { Text } from '../../../atoms' -import { Message } from '../Message' +import { Alert, Text } from '../../../atoms' export function ErrorMessage({ error }: { error: Error }) { return (
- + {error instanceof CompileError && (
{error diff --git a/packages/web-ui/src/ds/molecules/Chat/Message/helpers.ts b/packages/web-ui/src/ds/molecules/Chat/Message/helpers.ts new file mode 100644 index 000000000..f93c90698 --- /dev/null +++ b/packages/web-ui/src/ds/molecules/Chat/Message/helpers.ts @@ -0,0 +1,12 @@ +export const roleVariant = (role: string) => { + switch (role) { + case 'user': + return 'purple' + case 'system': + return 'outline' + case 'assistant': + return 'yellow' + default: + return 'default' + } +} diff --git a/packages/web-ui/src/ds/molecules/Chat/Message/index.tsx b/packages/web-ui/src/ds/molecules/Chat/Message/index.tsx index 3724afb48..f27a69a75 100644 --- a/packages/web-ui/src/ds/molecules/Chat/Message/index.tsx +++ b/packages/web-ui/src/ds/molecules/Chat/Message/index.tsx @@ -5,39 +5,16 @@ import { } from '@latitude-data/compiler' import { cn } from '../../../../lib/utils' -import { Badge, BadgeProps, Text } from '../../../atoms' +import { Badge, Text } from '../../../atoms' import { TextColor } from '../../../tokens' +import { roleVariant } from './helpers' -type MessageVariant = { - badgeVariant: BadgeProps['variant'] - textColor: TextColor -} - -const MessageVariants = { - muted: { - badgeVariant: 'muted', - textColor: 'foregroundMuted', - } as MessageVariant, - accent: { - badgeVariant: 'accent', - textColor: 'accentForeground', - } as MessageVariant, - outline: { - badgeVariant: 'outline', - textColor: 'foregroundMuted', - } as MessageVariant, - destructive: { - badgeVariant: 'destructive', - textColor: 'destructive', - } as MessageVariant, -} +export { roleVariant } from './helpers' export type MessageProps = { role: string content: MessageContent[] | string className?: string - variant?: keyof typeof MessageVariants - layout?: 'horizontal' | 'vertical' size?: 'default' | 'small' animatePulse?: boolean } @@ -46,38 +23,36 @@ export function Message({ role, content, animatePulse, - variant = 'muted', - layout = 'horizontal', size = 'default', }: MessageProps) { - const { badgeVariant, textColor } = MessageVariants[variant] return (
-
- +
+ {role.charAt(0).toUpperCase() + role.slice(1)}
-
- {typeof content === 'string' ? ( - - ) : ( - content.map((c, idx) => ( - - )) - )} +
+
+
+ {typeof content === 'string' ? ( + + ) : ( + content.map((c, idx) => ( + + )) + )} +
) diff --git a/packages/web-ui/src/ds/molecules/Chat/MessageList/index.tsx b/packages/web-ui/src/ds/molecules/Chat/MessageList/index.tsx index 3a9136f18..c421c6112 100644 --- a/packages/web-ui/src/ds/molecules/Chat/MessageList/index.tsx +++ b/packages/web-ui/src/ds/molecules/Chat/MessageList/index.tsx @@ -4,35 +4,14 @@ import { Fragment } from 'react' import { Message as ConversationMessage } from '@latitude-data/compiler' -import { Message, MessageProps } from '../Message' +import { Message } from '../Message' -export function MessageList({ - messages, - variant, - messageLayout, - separator = false, - size, -}: { - messages: ConversationMessage[] - variant?: MessageProps['variant'] - messageLayout?: MessageProps['layout'] - size?: MessageProps['size'] - separator?: boolean -}) { +export function MessageList({ messages }: { messages: ConversationMessage[] }) { return (
{messages.map((message, index) => ( - {separator && index > 0 && ( -
- )} - + ))}