@plaisolutions/react 0.1.0 → 0.2.0
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/README.md +14 -0
- package/dist/components/index.d.ts +175 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +896 -0
- package/dist/components/index.js.map +1 -0
- package/dist/index.d.ts +173 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +894 -2
- package/dist/index.js.map +1 -1
- package/dist/styles.css +2 -0
- package/package.json +17 -4
package/README.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
React hooks for Plai chat, powered by `@plaisolutions/client`.
|
|
4
4
|
|
|
5
|
+
`useChat` is the main API. Optional UI primitives are also exported for teams
|
|
6
|
+
that don't want to build chat UI from scratch.
|
|
7
|
+
|
|
5
8
|
## Install
|
|
6
9
|
|
|
7
10
|
```bash
|
|
@@ -84,3 +87,14 @@ export function Chat() {
|
|
|
84
87
|
}
|
|
85
88
|
```
|
|
86
89
|
|
|
90
|
+
## Optional UI Primitives
|
|
91
|
+
|
|
92
|
+
```tsx
|
|
93
|
+
import { Message, PromptForm, ToolResultCard } from "@plaisolutions/react";
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Available optional components:
|
|
97
|
+
|
|
98
|
+
- `Message`
|
|
99
|
+
- `PromptForm`
|
|
100
|
+
- `ToolResultCard`
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import * as react0 from "react";
|
|
2
|
+
import { ButtonHTMLAttributes, ReactNode, SVGProps } from "react";
|
|
3
|
+
import { ChatStatus, UIMessage, UIToolCallPart } from "@plaisolutions/client";
|
|
4
|
+
|
|
5
|
+
//#region src/components/message.d.ts
|
|
6
|
+
type MessageProps = {
|
|
7
|
+
message: UIMessage;
|
|
8
|
+
className?: string;
|
|
9
|
+
showRole?: boolean;
|
|
10
|
+
collapseThreshold?: number;
|
|
11
|
+
};
|
|
12
|
+
declare function Message({
|
|
13
|
+
message,
|
|
14
|
+
className,
|
|
15
|
+
showRole,
|
|
16
|
+
collapseThreshold
|
|
17
|
+
}: MessageProps): react0.JSX.Element;
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/components/icons/arrow.d.ts
|
|
20
|
+
declare function ArrowUp(props: SVGProps<SVGSVGElement>): react0.JSX.Element;
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/icons/loader.d.ts
|
|
23
|
+
declare function Loader(props: SVGProps<SVGSVGElement>): react0.JSX.Element;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/components/icons/microphone.d.ts
|
|
26
|
+
declare function Microphone(props: SVGProps<SVGSVGElement>): react0.JSX.Element;
|
|
27
|
+
//#endregion
|
|
28
|
+
//#region src/components/icons/paperclip.d.ts
|
|
29
|
+
declare function Paperclip(props: SVGProps<SVGSVGElement>): react0.JSX.Element;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/components/icons/stop.d.ts
|
|
32
|
+
declare function Stop(props: SVGProps<SVGSVGElement>): react0.JSX.Element;
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/components/icons/x.d.ts
|
|
35
|
+
declare function X(props: SVGProps<SVGSVGElement>): react0.JSX.Element;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/components/prompt-form/file-attachments.d.ts
|
|
38
|
+
declare const PROMPT_FORM_FILE_ACCEPT = "image/*,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx";
|
|
39
|
+
type InvalidPromptFormFile = {
|
|
40
|
+
file: File;
|
|
41
|
+
reason: string;
|
|
42
|
+
};
|
|
43
|
+
declare function isAllowedPromptFormFile(file: File): boolean;
|
|
44
|
+
declare function partitionPromptFormFiles(files: File[]): {
|
|
45
|
+
validFiles: File[];
|
|
46
|
+
invalidFiles: InvalidPromptFormFile[];
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/components/prompt-form/prompt-form.d.ts
|
|
50
|
+
type PromptFormIconButtonProps = ButtonHTMLAttributes<HTMLButtonElement>;
|
|
51
|
+
declare function PromptFormIconButton({
|
|
52
|
+
className,
|
|
53
|
+
type,
|
|
54
|
+
...props
|
|
55
|
+
}: PromptFormIconButtonProps): react0.JSX.Element;
|
|
56
|
+
type PromptFormSubmitInput = {
|
|
57
|
+
text: string;
|
|
58
|
+
enabledTools?: string[];
|
|
59
|
+
files: File[];
|
|
60
|
+
};
|
|
61
|
+
type PromptFormProps = {
|
|
62
|
+
value: string;
|
|
63
|
+
onValueChange: (value: string) => void;
|
|
64
|
+
onSubmit: (input: PromptFormSubmitInput) => void | Promise<void>;
|
|
65
|
+
status?: ChatStatus;
|
|
66
|
+
onStop?: () => void;
|
|
67
|
+
disabled?: boolean;
|
|
68
|
+
clearOnSubmit?: boolean;
|
|
69
|
+
enabledTools?: string[];
|
|
70
|
+
placeholder?: string;
|
|
71
|
+
sendLabel?: string;
|
|
72
|
+
stopLabel?: string;
|
|
73
|
+
attachLabel?: string;
|
|
74
|
+
removeFileLabel?: string;
|
|
75
|
+
enableAttachments?: boolean;
|
|
76
|
+
files?: File[];
|
|
77
|
+
onFilesChange?: (files: File[]) => void;
|
|
78
|
+
onInvalidFiles?: (invalidFiles: InvalidPromptFormFile[]) => void;
|
|
79
|
+
accept?: string;
|
|
80
|
+
className?: string;
|
|
81
|
+
textareaClassName?: string;
|
|
82
|
+
attachmentsClassName?: string;
|
|
83
|
+
maxRows?: number;
|
|
84
|
+
submitButtonClassName?: string;
|
|
85
|
+
stopButtonClassName?: string;
|
|
86
|
+
leftSlot?: ReactNode;
|
|
87
|
+
rightSlot?: ReactNode;
|
|
88
|
+
};
|
|
89
|
+
declare function PromptForm({
|
|
90
|
+
value,
|
|
91
|
+
onValueChange,
|
|
92
|
+
onSubmit,
|
|
93
|
+
status,
|
|
94
|
+
onStop,
|
|
95
|
+
disabled,
|
|
96
|
+
clearOnSubmit,
|
|
97
|
+
enabledTools,
|
|
98
|
+
placeholder,
|
|
99
|
+
sendLabel,
|
|
100
|
+
stopLabel,
|
|
101
|
+
attachLabel,
|
|
102
|
+
removeFileLabel,
|
|
103
|
+
enableAttachments,
|
|
104
|
+
files: filesProp,
|
|
105
|
+
onFilesChange,
|
|
106
|
+
onInvalidFiles,
|
|
107
|
+
accept,
|
|
108
|
+
className,
|
|
109
|
+
textareaClassName,
|
|
110
|
+
attachmentsClassName,
|
|
111
|
+
maxRows,
|
|
112
|
+
submitButtonClassName,
|
|
113
|
+
stopButtonClassName,
|
|
114
|
+
leftSlot,
|
|
115
|
+
rightSlot
|
|
116
|
+
}: PromptFormProps): react0.JSX.Element;
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/components/prompt-form/prompt-form-attach-button.d.ts
|
|
119
|
+
type PromptFormAttachButtonProps = {
|
|
120
|
+
onFilesSelected: (files: File[]) => void;
|
|
121
|
+
onInvalidFiles?: (invalidFiles: InvalidPromptFormFile[]) => void;
|
|
122
|
+
accept?: string;
|
|
123
|
+
label?: string;
|
|
124
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onChange">;
|
|
125
|
+
declare function PromptFormAttachButton({
|
|
126
|
+
onFilesSelected,
|
|
127
|
+
onInvalidFiles,
|
|
128
|
+
accept,
|
|
129
|
+
disabled,
|
|
130
|
+
label,
|
|
131
|
+
...props
|
|
132
|
+
}: PromptFormAttachButtonProps): react0.JSX.Element;
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/components/speech-to-text-toggle/transcribe-audio.d.ts
|
|
135
|
+
type TranscribeAudioFn = (audio: Blob, signal?: AbortSignal) => Promise<string>;
|
|
136
|
+
declare function dummyTranscribeAudio(_audio: Blob, signal?: AbortSignal): Promise<string>;
|
|
137
|
+
declare function transcribeAudioViaEndpoint(audio: Blob, endpoint: string, signal?: AbortSignal): Promise<string>;
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/components/speech-to-text-toggle/speech-to-text-toggle.d.ts
|
|
140
|
+
type SpeechToTextToggleProps = {
|
|
141
|
+
onTranscriptionComplete: (text: string) => void;
|
|
142
|
+
onTranscriptionError?: (error: Error) => void;
|
|
143
|
+
transcribe?: TranscribeAudioFn;
|
|
144
|
+
transcriptionEndpoint?: string;
|
|
145
|
+
label?: string;
|
|
146
|
+
listeningLabel?: string;
|
|
147
|
+
loadingLabel?: string;
|
|
148
|
+
} & Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onToggle">;
|
|
149
|
+
declare function SpeechToTextToggle({
|
|
150
|
+
onTranscriptionComplete,
|
|
151
|
+
onTranscriptionError,
|
|
152
|
+
transcribe,
|
|
153
|
+
transcriptionEndpoint,
|
|
154
|
+
disabled,
|
|
155
|
+
label,
|
|
156
|
+
listeningLabel,
|
|
157
|
+
loadingLabel,
|
|
158
|
+
className,
|
|
159
|
+
...props
|
|
160
|
+
}: SpeechToTextToggleProps): react0.JSX.Element;
|
|
161
|
+
//#endregion
|
|
162
|
+
//#region src/components/tool-result-card.d.ts
|
|
163
|
+
type ToolResultCardProps = {
|
|
164
|
+
part: UIToolCallPart;
|
|
165
|
+
className?: string;
|
|
166
|
+
detailsOpen?: boolean;
|
|
167
|
+
};
|
|
168
|
+
declare function ToolResultCard({
|
|
169
|
+
part,
|
|
170
|
+
className,
|
|
171
|
+
detailsOpen
|
|
172
|
+
}: ToolResultCardProps): react0.JSX.Element;
|
|
173
|
+
//#endregion
|
|
174
|
+
export { ArrowUp, type InvalidPromptFormFile, Loader, Message, type MessageProps, Microphone, PROMPT_FORM_FILE_ACCEPT, Paperclip, PromptForm, PromptFormAttachButton, type PromptFormAttachButtonProps, PromptFormIconButton, type PromptFormIconButtonProps, type PromptFormProps, type PromptFormSubmitInput, SpeechToTextToggle, type SpeechToTextToggleProps, Stop, ToolResultCard, type ToolResultCardProps, type TranscribeAudioFn, X, dummyTranscribeAudio, isAllowedPromptFormFile, partitionPromptFormFiles, transcribeAudioViaEndpoint };
|
|
175
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/components/message.tsx","../../src/components/icons/arrow.tsx","../../src/components/icons/loader.tsx","../../src/components/icons/microphone.tsx","../../src/components/icons/paperclip.tsx","../../src/components/icons/stop.tsx","../../src/components/icons/x.tsx","../../src/components/prompt-form/file-attachments.ts","../../src/components/prompt-form/prompt-form.tsx","../../src/components/prompt-form/prompt-form-attach-button.tsx","../../src/components/speech-to-text-toggle/transcribe-audio.ts","../../src/components/speech-to-text-toggle/speech-to-text-toggle.tsx","../../src/components/tool-result-card.tsx"],"sourcesContent":[],"mappings":";;;;;KAKY,YAAA;WACD;;;EADC,iBAAY,CAAA,EAAA,MACb;AAyHX,CAAA;AACE,iBADc,OAAA,CACd;EAAA,OAAA;EAAA,SAAA;EAAA,QAAA;EAAA;AAAA,CAAA,EAIC,YAJD,CAAA,EAIa,MAAA,CAAA,GAAA,CAAA,OAJb;;;iBC9Hc,OAAA,QAAe,SAAS,iBAAc,MAAA,CAAA,GAAA,CAAA;;;iBCAtC,MAAA,QAAc,SAAS,iBAAc,MAAA,CAAA,GAAA,CAAA;;;iBCArC,UAAA,QAAkB,SAAS,iBAAc,MAAA,CAAA,GAAA,CAAA;;;iBCAzC,SAAA,QAAiB,SAAS,iBAAc,MAAA,CAAA,GAAA,CAAA;;;iBCAxC,IAAA,QAAY,SAAS,iBAAc,MAAA,CAAA,GAAA,CAAA;;;iBCAnC,CAAA,QAAS,SAAS,iBAAc,MAAA,CAAA,GAAA,CAAA;;;cCcnC,uBAAA;KAGD,qBAAA;QACJ;;;APfI,iBO4BI,uBAAA,CP3BI,IAAA,EO2B0B,IP3B1B,CAAA,EAAA,OAAA;AAyHJ,iBOrFA,wBAAA,CPqFO,KAAA,EOrFyB,IPqFzB,EAAA,CAAA,EAAA;EACrB,UAAA,EOrFY,IPqFZ,EAAA;EACA,YAAA,EOrFc,qBPqFd,EAAA;CACA;;;KQlGU,yBAAA,GAA4B,qBAAqB;iBAE7C,oBAAA;;;;G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