/**
*
* Copyright 2023-present InspectorRAGet Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
**/
import cx from 'classnames';
import Balancer from 'react-wrap-balancer';
import { useState, useEffect, useRef } from 'react';
import { Modal, Button, DefinitionTooltip } from '@carbon/react';
import {
CheckmarkFilled,
WarningFilled,
ErrorFilled,
Restart,
} from '@carbon/icons-react';
import {
ToolCallCard,
ToolResponseCard,
} from '@/src/components/tools/ToolCards';
import {
Message,
MessageRetry,
ToolMessage,
AssistantMessage,
} from '@/src/types';
import Avatar from '@/src/components/chat/Avatar';
import DocumentsViewer from '@/src/components/chat/DocumentsViewer';
import classes from './ChatLine.module.scss';
// ===================================================================================
// TYPES
// ===================================================================================
interface ChatLineProps {
messageId: string;
message: Message;
latestResponse?: boolean;
onSelection?: Function;
focused?: boolean;
selected?: boolean;
}
// ===================================================================================
// RENDER FUNCTIONS
// ===================================================================================
const STATUS_CONFIG = {
pass: {
icon: CheckmarkFilled,
label: 'Pass',
badgeClass: classes.statusBadgePass,
},
warn: {
icon: WarningFilled,
label: 'Warn',
badgeClass: classes.statusBadgeWarn,
},
fail: {
icon: ErrorFilled,
label: 'Fail',
badgeClass: classes.statusBadgeFail,
},
} as const;
function RetriesModal({
retries,
open,
onClose,
}: {
retries: MessageRetry[];
open: boolean;
onClose: () => void;
}) {
return (