inline-chat-kit 0.54.3 → 0.55.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/dist/ChatExperience/ChatExperience.d.ts +115 -0
- package/dist/ChatExperience-C2UXwrrI.js +5844 -0
- package/dist/ChatExperience-C2UXwrrI.js.map +1 -0
- package/dist/demo/ChatExperienceDemo.d.ts +27 -0
- package/dist/demo/InlineChatBanner.d.ts +6 -0
- package/dist/demo/IntroLanding.d.ts +43 -0
- package/dist/demo/featureStatus.d.ts +18 -0
- package/dist/demo/index.d.ts +8 -0
- package/dist/demo/scriptedApi.d.ts +49 -0
- package/dist/demo.js +693 -0
- package/dist/demo.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/inline-chat-kit.css +1 -1
- package/dist/inline-chat-kit.js +8 -5541
- package/dist/inline-chat-kit.js.map +1 -1
- package/dist/theme/useThemeAttribute.d.ts +16 -0
- package/getting-started.md +33 -69
- package/package.json +7 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes the chosen theme onto the root element, and takes it off again when
|
|
3
|
+
* nothing is chosen.
|
|
4
|
+
*
|
|
5
|
+
* `data-theme` is how a host sets the theme — the same way it would by hand.
|
|
6
|
+
* The absence of the attribute is not a third theme: it is the kit following
|
|
7
|
+
* `prefers-color-scheme`, which is what it is there for, so "nothing chosen"
|
|
8
|
+
* has to actually remove it rather than settle on a default.
|
|
9
|
+
*
|
|
10
|
+
* It is a hook rather than three lines inside one component because two things
|
|
11
|
+
* need it. `ChatExperience` is the chat, and the demo has a landing page in
|
|
12
|
+
* front of it — and with the effect living only in the chat, a site that had
|
|
13
|
+
* decided the page is read in light got a dark landing page and a light
|
|
14
|
+
* conversation, changing under the reader at the press of a button.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useThemeAttribute(chosen: "light" | "dark" | null | undefined): void;
|
package/getting-started.md
CHANGED
|
@@ -19,85 +19,49 @@ kit uses whatever copy your app already has. React 18 or 19.
|
|
|
19
19
|
## The whole thing
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
import {
|
|
23
|
-
import { ChatTurnRow, Conversation, useChatTurns } from "inline-chat-kit";
|
|
22
|
+
import { ChatExperience } from "inline-chat-kit";
|
|
24
23
|
import "inline-chat-kit/styles.css";
|
|
25
24
|
|
|
26
|
-
/** How far below the top edge a sent message comes to rest. */
|
|
27
|
-
const ANCHOR = 24;
|
|
28
|
-
|
|
29
25
|
export function MinimalChat() {
|
|
30
|
-
/* Which turn to hold at the top. Kept here rather than inside the kit
|
|
31
|
-
because "which message am I looking at" is the host's question: you may
|
|
32
|
-
want it to follow a regenerate, a jump from a sidebar, or nothing at all. */
|
|
33
|
-
const [anchored, setAnchored] = useState<string | null>(null);
|
|
34
|
-
|
|
35
|
-
const { turns, setDraft, submit, stop, beginEdit, cancelEdit } = useChatTurns({
|
|
36
|
-
/* Return a string, a promise of one, or an async iterable of deltas. The
|
|
37
|
-
kit has no answers of its own — return nothing and nothing appears. */
|
|
38
|
-
onSend: async (message) => `You said: ${message}`,
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const send = useCallback(
|
|
42
|
-
(id: string, value: string) => {
|
|
43
|
-
setAnchored(id);
|
|
44
|
-
submit(id, value);
|
|
45
|
-
},
|
|
46
|
-
[submit]
|
|
47
|
-
);
|
|
48
|
-
|
|
49
|
-
/* Held while the answer is arriving, let go when it settles — otherwise the
|
|
50
|
-
question stays pinned to the top for ever and the composer, which is the
|
|
51
|
-
last turn, sits below the fold. */
|
|
52
|
-
const holding = turns.find((turn) => turn.id === anchored);
|
|
53
|
-
const anchorId =
|
|
54
|
-
holding && holding.state !== "resting" ? `turn-${holding.id}` : undefined;
|
|
55
|
-
|
|
56
26
|
return (
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
/* Pass the hook's own functions straight through — they are stable,
|
|
77
|
-
and `ChatTurnRow` is memoised on them. An arrow made during
|
|
78
|
-
render hands the memo a new prop every time. */
|
|
79
|
-
onDraft={setDraft}
|
|
80
|
-
onSubmit={send}
|
|
81
|
-
onStop={stop}
|
|
82
|
-
onEdit={beginEdit}
|
|
83
|
-
onCancelEdit={cancelEdit}
|
|
84
|
-
placeholder="Ask anything…"
|
|
85
|
-
/>
|
|
86
|
-
))}
|
|
87
|
-
</Conversation>
|
|
88
|
-
</div>
|
|
27
|
+
<ChatExperience
|
|
28
|
+
/* The one thing that has to be yours. Return a string, a promise of one,
|
|
29
|
+
or an async iterable of deltas — the kit has no answers of its own. */
|
|
30
|
+
onSend={async (message) => `You said: ${message}`}
|
|
31
|
+
/* Shown in the header until a question has been asked; after that the
|
|
32
|
+
header carries the first question, so somebody arriving at a
|
|
33
|
+
conversation in progress can see what it is about. */
|
|
34
|
+
title="Chat"
|
|
35
|
+
placeholder="Ask anything…"
|
|
36
|
+
/* Before anybody has asked. The openers are sent rather than typed into
|
|
37
|
+
the box: one that only fills the input asks somebody to press send on
|
|
38
|
+
a sentence they did not write. */
|
|
39
|
+
empty={{
|
|
40
|
+
title: "Ask me anything",
|
|
41
|
+
description: "Or press one of these.",
|
|
42
|
+
suggestions: ["What can you do?", "Write me a haiku"],
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
89
45
|
);
|
|
90
46
|
}
|
|
91
47
|
```
|
|
92
48
|
|
|
93
|
-
That is a working chat
|
|
94
|
-
bubble holding your message
|
|
95
|
-
|
|
96
|
-
next message
|
|
49
|
+
That is a working chat. Type, press enter, and the pill you typed into becomes
|
|
50
|
+
the bubble holding your message; it travels to the top of the view and stays
|
|
51
|
+
there while the answer is written underneath it, then lets go so the composer
|
|
52
|
+
for your next message is back on screen. The last turn is always that composer
|
|
53
|
+
— which is the whole idea, and the reason a message does not appear to move so
|
|
54
|
+
much as to *become* the thing that was sent.
|
|
55
|
+
|
|
56
|
+
`ChatExperience` is the assembly. Everything it draws is also exported on its
|
|
57
|
+
own — `Conversation`, `ChatHeader`, `ChatTurnRow`, `useChatTurns` — so you can
|
|
58
|
+
put the pieces together yourself when your app needs a shape this one does not
|
|
59
|
+
have. Reach for that second; there is more to remember than it looks, and the
|
|
60
|
+
kit has already been caught getting it wrong in a page that did.
|
|
97
61
|
|
|
98
62
|
**This file is compiled on every build of this package and a test asserts it
|
|
99
|
-
matches this page character for character.** If it does not work, that is a
|
|
100
|
-
|
|
63
|
+
matches this page character for character.** If it does not work, that is a bug
|
|
64
|
+
here, not a mistake you made.
|
|
101
65
|
|
|
102
66
|
## Point it at your model
|
|
103
67
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "inline-chat-kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "An inline AI chat experience for React. The input is the message: it morphs into the bubble, the answer streams beneath it, and the parts around it
|
|
3
|
+
"version": "0.55.1",
|
|
4
|
+
"description": "An inline AI chat experience for React. The input is the message: it morphs into the bubble, the answer streams beneath it, and the parts around it \u2014 tool calls, reasoning, questions, artifacts, dictation \u2014 come with it.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
7
7
|
"chat",
|
|
@@ -45,7 +45,11 @@
|
|
|
45
45
|
"import": "./dist/inline-chat-kit.js"
|
|
46
46
|
},
|
|
47
47
|
"./styles.css": "./dist/inline-chat-kit.css",
|
|
48
|
-
"./package.json": "./package.json"
|
|
48
|
+
"./package.json": "./package.json",
|
|
49
|
+
"./demo": {
|
|
50
|
+
"types": "./dist/demo/index.d.ts",
|
|
51
|
+
"import": "./dist/demo.js"
|
|
52
|
+
}
|
|
49
53
|
},
|
|
50
54
|
"publishConfig": {
|
|
51
55
|
"access": "public"
|