mirror of
https://github.com/bitbaum/chatkit.git
synced 2026-12-05 13:37:24 +01:00
* feat(answers): answers that read like the ChatGPT app's (0.13.0)
Measured screen by screen against the ChatGPT app on a phone, and closed
in the package so every product gets it:
- Headings are signposts: a size up, with air above them, so a long answer
can be scanned and found again.
- Options are cards: a numbered list whose items open with a bold name gets
a tile badge, the name a size up, a hairline between cards, and a pill
for a short tag written right after the name (`[Recommended]`). The
instruction asks the model to mark the option it recommends that way.
- Sources are chips: a `[F2, F1]` handle is drawn after the sentence as
"Fleet AGENTS.md +1", linked when the record has a link, and moved after
the full stop when the model wrote it before.
- Links in the words that leave the site say so: dotted underline, arrow.
- A layered figure, `{"type":"stack"}`: full-width boxes top to bottom, a
row of tiles where a layer has parts (icons from a closed list, never
markup), the words that cross each arrow, an accent tone, a caption.
`diagram` stays for an arbitrary graph.
- "Thought for 3m 38s ›" above an answer from `message.thinking`, closed by
default; `live.steps` shows the same row open while a turn runs, with
the newest step marked. `ThinkingRow` and `formatThinkingDuration` are
exported; `thoughtFor`, `thought`, `thinking` join the thread labels.
Tests: tag and citation placement (core), stack validation and text form
(core), the whole answer rendered on the server (render), and the stack
fitting six tiles on a 390px phone with the thought line above (browser).
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
* fix(markdown): no space before the full stop when a citation chip moves after it
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018WZnBnaLP6RhwFkLxRTKgE
---------
Co-authored-by: Claude <noreply@anthropic.com>
81 lines
3.2 KiB
TypeScript
81 lines
3.2 KiB
TypeScript
import { type ReactNode } from "react";
|
|
/** What a grounded answer's `[F8]` / `[D1]` handle refers to. Unknown handles
|
|
* are dropped rather than shown bare: a dangling `[F8]` implies a source the
|
|
* reader cannot reach. */
|
|
export type CitationMap = Record<string, {
|
|
label: string;
|
|
detail: string;
|
|
href?: string;
|
|
}>;
|
|
export type RenderLink = (link: {
|
|
href: string;
|
|
internal: boolean;
|
|
className: string;
|
|
children: ReactNode;
|
|
}) => ReactNode;
|
|
/** How a `[F1]` handle shows in the text. The default is a small superscript
|
|
* with the source in its tooltip; an app with its own source sheet renders
|
|
* that here instead. */
|
|
export type RenderCitation = (cite: {
|
|
ids: string[];
|
|
citations: CitationMap;
|
|
className: string;
|
|
}) => ReactNode;
|
|
/** The sources an answer cites, listed once under it. The default is the chip
|
|
* row; an app with its own source sheet renders that here instead. */
|
|
export type RenderSources = (sources: {
|
|
records: {
|
|
id: string;
|
|
label: string;
|
|
detail: string;
|
|
href?: string;
|
|
}[];
|
|
label: string;
|
|
}) => ReactNode;
|
|
/** A plain anchor: same-site paths in place, everything else in a new tab. */
|
|
export declare const defaultRenderLink: RenderLink;
|
|
/**
|
|
* The sources an answer cites, listed once under it. On a mouse, a row of
|
|
* chips. On a touch screen, ONE "Sources" button that opens a sheet with every
|
|
* record — its label, what it is, and a link — the way the ChatGPT app lists
|
|
* them: a row of chips on a phone was a row of cut-off words.
|
|
*/
|
|
export declare function SourcesRow({ records, label, renderLink, }: {
|
|
records: {
|
|
id: string;
|
|
label: string;
|
|
detail: string;
|
|
href?: string;
|
|
}[];
|
|
label: string;
|
|
renderLink?: RenderLink;
|
|
}): import("react").JSX.Element | null;
|
|
/** The in-text citation as a chip: the first source's name, and how many
|
|
* more stand behind the sentence — the ChatGPT app's "NVIDIA De… +3". The
|
|
* full list stays in the sources row under the answer. */
|
|
export declare const defaultRenderCitation: RenderCitation;
|
|
/**
|
|
* Model output as readable text: paragraphs, lists, headings, tables, bold,
|
|
* italic, code, links, images and citations. Never HTML — nothing here can
|
|
* inject markup.
|
|
*
|
|
* A list of named things (`1. **Option.** why`) becomes cards with a badge,
|
|
* a name and a body; a table becomes a table that scrolls sideways on a phone
|
|
* instead of breaking the page; the sources an answer cites are listed once
|
|
* under it as chips.
|
|
*/
|
|
export declare function Markdown({ text, citations, renderLink, renderCitation, renderSources, sources, sourcesLabel, className, onReply, }: {
|
|
text: string;
|
|
/** A visual choice sends a normal conversation message. Omit while streaming. */
|
|
onReply?: (text: string) => void;
|
|
citations?: CitationMap;
|
|
renderLink?: RenderLink;
|
|
renderCitation?: RenderCitation;
|
|
/** Your own sources row (a button that opens a sheet) in place of the chips. */
|
|
renderSources?: RenderSources;
|
|
/** The row of cited sources under the answer (needs `citations`). */
|
|
sources?: boolean;
|
|
sourcesLabel?: string;
|
|
className?: string;
|
|
}): import("react").JSX.Element;
|
|
//# sourceMappingURL=Markdown.d.ts.map
|