ChatRetrievalChunks

Data Display

검색으로 찾은 청크 목록과 점수 표시.

Usage

RAG 검색 결과 청크들을 점수와 함께 나열할 때 사용합니다. 단일 문서 페이지 근거는 ChatDocumentReference, 본문 내 각주는 ChatInlineCitation을 대신 사용하세요.

import

import

import { ChatRetrievalChunks } from '@mildang/design-system/unofficial/Chat';

예제를 복사해 쓸 때 필요한 준비

@mildang/styled-system 은 이 저장소에서 Panda 가 생성하는 산출물이다. 저장소 안에서는 turbo run ship 이후 쓸 수 있고, 패키지 소비자는 자기 Panda 산출물이나 다른 레이아웃 수단으로 바꿔야 한다.

외부 패키지를 따로 설치한다. DS 의 전이 의존성에 기대지 않는다.

API Reference

ChatRetrievalChunks Props

Prop

Type

Default

chunks
필수

readonly RetrievalChunk[]

지정 안 함

query
필수

string

지정 안 함

labels

Partial<ChatRetrievalChunksLabels>

지정 안 함

searching

boolean

false

visibleCount

number

지정 안 함

같은 패밀리

@mildang/design-system/unofficial/Chat 에서 같이 내보내는 컴포넌트다.

예제

기본 사용

코드

import type { ComponentProps } from 'react';
import { ChatRetrievalChunks } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatRetrievalChunks>;
const CHUNKS = [
  {
    id: 'design-4',
    source: '재시도 정책 설계.md',
    locator: 'p. 4',
    score: 0.91,
    text: '토큰 만료(401)에서만 한 번 재시도한다. 네트워크 오류는 재시도 대상이 아니며 그대로 상위로 전파한다.',
  },
  {
    id: 'rfc-40',
    source: 'RFC-2026-03 인터셉터',
    locator: 'L40-58',
    score: 0.83,
    text: '재시도 간격은 지수 백오프로 늘리되 상한을 둔다. 상한이 없으면 만료된 세션이 오래 살아남는다.',
  },
  {
    id: 'meeting-2',
    source: '2026-02 스프린트 회의록',
    locator: '§2',
    score: 0.42,
    text: '재시도 루프가 네트워크 오류까지 삼키고 있다는 제보가 있었다. 원인은 좁히지 못했다.',
  },
];
const DEFAULT_ARGS: Props = { query: '401 재시도 정책', chunks: CHUNKS };
export default function RetrievalChunksDefaultExample(props: Partial<Props> = {}) {
  return <ChatRetrievalChunks {...DEFAULT_ARGS} {...props} />;
}

검색 중

코드

import type { ComponentProps } from 'react';
import { ChatRetrievalChunks } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatRetrievalChunks>;
const DEFAULT_ARGS: Props = { query: '401 재시도 정책', chunks: [], searching: true };
export default function RetrievalChunksSearchingExample(props: Partial<Props> = {}) {
  return <ChatRetrievalChunks {...DEFAULT_ARGS} {...props} />;
}

결과 없음

코드

import type { ComponentProps } from 'react';
import { ChatRetrievalChunks } from '@mildang/design-system/unofficial/Chat';
type Props = ComponentProps<typeof ChatRetrievalChunks>;
const DEFAULT_ARGS: Props = { query: '존재하지 않는 주제', chunks: [] };
export default function RetrievalChunksEmptyExample(props: Partial<Props> = {}) {
  return <ChatRetrievalChunks {...DEFAULT_ARGS} {...props} />;
}

검색 진행 중 스트리밍

코드

import { css } from '@mildang/styled-system/css';
import { ChatRetrievalChunks } from '@mildang/design-system/unofficial/Chat';
import { RetrievalChunk } from '@mildang/design-system/unofficial/Chat';

const CHUNKS: readonly RetrievalChunk[] = [
  {
    id: 'design-4',
    source: '재시도 정책 설계.md',
    locator: 'p. 4',
    score: 0.91,
    text: '토큰 만료(401)에서만 한 번 재시도한다. 네트워크 오류는 재시도 대상이 아니며 그대로 상위로 전파한다.',
  },
  {
    id: 'rfc-40',
    source: 'RFC-2026-03 인터셉터',
    locator: 'L40-58',
    score: 0.83,
    text: '재시도 간격은 지수 백오프로 늘리되 상한을 둔다. 상한이 없으면 만료된 세션이 오래 살아남는다.',
  },
  {
    id: 'meeting-2',
    source: '2026-02 스프린트 회의록',
    locator: '§2',
    score: 0.42,
    text: '재시도 루프가 네트워크 오류까지 삼키고 있다는 제보가 있었다. 원인은 좁히지 못했다.',
  },
];

const RetrievalChunksStreamingExample = () => (
  <div className={css({ display: 'flex', flexDirection: 'column', gap: '20' })}>
    <ChatRetrievalChunks query="401 재시도 정책" chunks={CHUNKS} visibleCount={1} />
    <ChatRetrievalChunks query="401 재시도 정책" chunks={CHUNKS} visibleCount={2} />
  </div>
);

export default RetrievalChunksStreamingExample;

makeAssistantToolUI 데이터 연동

코드

import { css } from '@mildang/styled-system/css';

const REGISTRATION = `// 앱 소유 — DS 는 등록하지 않고 등록 가능한 부품만 export 한다(AD-1).
import { makeAssistantDataUI } from '@assistant-ui/react';
import { ChatRetrievalChunks } from '@mildang/design-system/unofficial/Chat';
import type { RetrievalChunksData } from '@mildang/design-system/unofficial/Chat';

// DS 가 export 하는 타입이 그대로 data part 페이로드 스키마다(AD-3).
export const RetrievalUI = makeAssistantDataUI<RetrievalChunksData>({
  type: 'retrieval',
  render: ({ data }) => <ChatRetrievalChunks {...data} />,
});

// 서버 페이로드 예시 — 전부 JSON 직렬화 가능한 값이다.
// {
//   "query": "401 재시도 정책",
//   "searching": false,
//   "chunks": [
//     { "id": "design-4", "source": "재시도 정책 설계.md", "locator": "p. 4",
//       "score": 0.91, "text": "토큰 만료(401)에서만 한 번 재시도한다. …" }
//   ]
// }`;

const RetrievalChunksMakeAssistantDataExample = () => (
  <pre
    // 가로 스크롤 영역은 키보드로도 닿아야 한다(axe `scrollable-region-focusable`).
    tabIndex={0}
    className={css({
      margin: '0',
      overflowX: 'auto',
      borderRadius: 'lg',
      backgroundColor: 'neutral.ghostBg.base',
      padding: '16',
      textStyle: 'chat-small-text-R',
      fontFamily: 'monospace',
      color: 'neutral.text.base',
    })}
  >
    {REGISTRATION}
  </pre>
);

export default RetrievalChunksMakeAssistantDataExample;