Tài liệu

Message part

Native message-part là tool surface inline đặt dưới chat message liên quan. Nó dùng cùng ToolResultSurfaceProps, state, context của producer lane, toolNames và renderBeforeOutput như tool view; chọn nó khi kết quả nên đọc như một phần của message.

YAML
contributes:
  ui:
    - id: source-summary
      kind: nativeModule
      surface: message-part
      slot: chat.message.inline.below
      toolNames: [searchSources]
      renderBeforeOutput: true
      module:
        entry: dist/ui/app.js
        export: SourceSummary
TSX
import type { ToolResultSurfaceProps } from '@sota/platform';

type SearchOutput = { sources: Array<{ title: string; url: string }> };

export function SourceSummary({ toolResult }: ToolResultSurfaceProps<unknown, SearchOutput>) {
  if (toolResult.state === 'output-pending') {
    return <aside aria-live="polite">Waiting for the app…</aside>;
  }
  if (toolResult.state !== 'output-available') return null;
  return <aside aria-label="Sources">{toolResult.result?.sources.map((source) => (
    <a key={source.url} href={source.url} rel="noreferrer" target="_blank">
      {source.title}
    </a>
  ))}</aside>;
}
Khác với declarative message renderer.

kind: messageRenderer trang trí text match được thành citation, mention hoặc pill. surface: message-part load React của app cho named tool call.

Mục lục

Esc

Tìm theo tiêu đề và nội dung trong mọi chương.