reachat 0.0.1 → 1.0.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.
Files changed (46) hide show
  1. package/README.md +84 -39
  2. package/dist/{Sessions.d.ts → Chat.d.ts} +23 -17
  3. package/dist/ChatContext.d.ts +16 -0
  4. package/dist/ChatInput.d.ts +42 -0
  5. package/dist/Markdown/CodeHighlighter.d.ts +9 -0
  6. package/dist/Markdown/Markdown.d.ts +11 -0
  7. package/dist/Markdown/Table.d.ts +5 -0
  8. package/dist/Markdown/index.d.ts +4 -0
  9. package/dist/Markdown/plugins/index.d.ts +1 -0
  10. package/dist/Markdown/plugins/remarkCve.d.ts +1 -0
  11. package/dist/SessionMessages/MessageActions.d.ts +45 -0
  12. package/dist/SessionMessages/MessageFile.d.ts +14 -0
  13. package/dist/SessionMessages/MessageFiles.d.ts +11 -0
  14. package/dist/SessionMessages/MessageQuestion.d.ts +9 -0
  15. package/dist/SessionMessages/MessageResponse.d.ts +13 -0
  16. package/dist/SessionMessages/MessageSource.d.ts +10 -0
  17. package/dist/SessionMessages/MessageSources.d.ts +11 -0
  18. package/dist/SessionMessages/SessionEmpty.d.ts +6 -0
  19. package/dist/SessionMessages/SessionMessage.d.ts +15 -0
  20. package/dist/SessionMessages/SessionMessagePanel.d.ts +3 -0
  21. package/dist/SessionMessages/SessionMessages.d.ts +23 -0
  22. package/dist/SessionMessages/SessionMessagesHeader.d.ts +3 -0
  23. package/dist/SessionMessages/index.d.ts +12 -0
  24. package/dist/SessionsList/NewSessionButton.d.ts +10 -0
  25. package/dist/SessionsList/SessionGroups.d.ts +10 -0
  26. package/dist/SessionsList/SessionListItem.d.ts +22 -0
  27. package/dist/SessionsList/SessionsGroup.d.ts +10 -0
  28. package/dist/SessionsList/SessionsList.d.ts +3 -0
  29. package/dist/SessionsList/index.d.ts +5 -0
  30. package/dist/docs.json +1379 -0
  31. package/dist/index.d.ts +4 -5
  32. package/dist/index.js +758 -131
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.umd.cjs +737 -120
  35. package/dist/index.umd.cjs.map +1 -1
  36. package/dist/theme.d.ts +70 -1
  37. package/dist/types.d.ts +71 -17
  38. package/dist/utils.d.ts +7 -0
  39. package/dist/utils.spec.d.ts +1 -0
  40. package/package.json +31 -19
  41. package/dist/SessionInput.d.ts +0 -22
  42. package/dist/SessionListItem.d.ts +0 -11
  43. package/dist/SessionMessage.d.ts +0 -10
  44. package/dist/SessionMessages.d.ts +0 -9
  45. package/dist/SessionsList.d.ts +0 -11
  46. package/dist/useLlm.d.ts +0 -3
package/README.md CHANGED
@@ -1,41 +1,86 @@
1
- # reachat
2
- 💬 Building Blocks for LLM UI
3
-
4
- ## Features
5
- - Markdown
6
- - Code block
7
- - CSV Table
8
- - JSON Block
9
- - Dynamic Links ( regex )
10
- - Source Support
11
- - Image Preview Support
12
- - File Upload Support
13
- - Typeahead
1
+ <div align="center">
2
+ <img width="650" src=".storybook/logo.png">
3
+ <br />
4
+ Building Blocks for LLM UI
5
+ <br /><br />
6
+ <a href="https://github.com/reaviz/reachat/actions/workflows/build.yml">
7
+ <img src="https://github.com/reaviz/reachat/actions/workflows/build.yml/badge.svg" />
8
+ </a>
9
+ &nbsp;
10
+ <a href="https://npm.im/reachat" target="_blank">
11
+ <img src="https://img.shields.io/npm/v/reachat.svg" />
12
+ </a>&nbsp;
13
+ <a href="https://npm.im/reachat" target="_blank">
14
+ <img src="https://badgen.net/npm/dw/reachat" />
15
+ </a>&nbsp;
16
+ <a href="https://github.com/reaviz/reachat/blob/master/LICENSE">
17
+ <img src="https://badgen.now.sh/badge/license/apache2" />
18
+ </a>&nbsp;
19
+ <a href="https://github.com/reaviz/reachat">
20
+ <img alt="GitHub stars" src="https://img.shields.io/github/stars/reaviz/reachat?style=social" />
21
+ </a>&nbsp;
22
+ <a href="https://discord.gg/tt8wGExq35" target="_blank">
23
+ <img src="https://img.shields.io/discord/773948315037073409?label=discord" />
24
+ </a>
25
+ </div>
26
+
27
+ ---
28
+
29
+ reachat is a UI library for building chat experiences. No more manually coding
30
+ all the components required to build LLM uis manually. Customize each component and
31
+ theme via Tailwind.
32
+
33
+ ## 🚀 Quick Links
34
+ - Checkout the [docs and demos](https://reachat.dev)
35
+ - Checkout the [storybook demos](https://storybook.reachat.dev)
36
+ - Learn about updates from the [changelog](CHANGELOG.md)
37
+
38
+ ## 💎 Other Projects
39
+
40
+ - [Reaflow](https://reaflow.dev?utm=reagraph) - Open-source library for workflow and diagram graphs.
41
+ - [Reablocks](https://reablocks.dev?utm=reagraph) - Open-source component library for React based on Tailwind.
42
+ - [Reaviz](https://reaviz.dev?utm=reagraph) - Open-source library for data visualizations for React.
43
+ - [Reagraph](https://reagraph.dev?utm=reaviz) - Open-source library for large webgl based network graphs.
44
+
45
+ ## 🪄 Features
46
+ - Markdown Rendering
47
+ - GFM Styling
48
+ - Code Highlighting
49
+ - Tables
50
+ - JSON
51
+ - Lists
52
+ - Embeds ( Youtube )
53
+ - remark plugin support
54
+ - File Uploads
55
+ - Message Sources
56
+ - Animations
57
+ - Conversation Pagination
58
+ - Smart/Dynamic Grouping of Sessions
14
59
  - Keyboard shortcuts
60
+ - Animations via Framer Motion
15
61
  - Tailwind for Themeing
16
- - Polygot LLM Support - Vercel, OpenAI, Claude, Gemini
17
-
18
- ## Installation
19
- TODO
20
-
21
- ## Themeing
22
- TODO
23
-
24
- ## References
25
- - https://www.chatbotui.com/
26
- - https://llm-ui.com/
27
- - https://github.com/huggingface/chat-ui - Amazing clean UI with very good web search, my go to currently. (they added the ability to do it all locally very recently!)
28
- - https://github.com/oobabooga/text-generation-webui - Best overall, supports any model format and has many extensions
29
- - https://github.com/ParisNeo/lollms-webui/ - Has PDF, stable diffusion and web search integration
30
- - https://github.com/h2oai/h2ogpt - Has PDF, Web search, best for files ingestion (supports many file formats)
31
- - https://github.com/SillyTavern/SillyTavern - Best for custom characters and roleplay
32
- - https://github.com/NimbleBoxAI/ChainFury - Has great UI and web search (experimental)
33
- - https://github.com/nomic-ai/gpt4all - Basic UI that replicated ChatGPT
34
- - https://github.com/imartinez/privateGPT - Basic UI that replicated ChatGPT with PDF integration
35
- - https://github.com/LostRuins/koboldcpp - Easy to install and simple interface
36
- - LM Studio - Clean UI, focuses on GGUF format
37
- - https://github.com/lobehub/lobe-chat - Nice rich UI with the ability to load extensions for web search, TTS and more
38
- - https://github.com/ollama-webui/ollama-webui - ChatGPT like UI with easy way to download models
39
- - https://github.com/turboderp/exui - very fast and vram efficient
40
- - https://github.com/PromtEngineer/localGPT - Focuses on PDF files
41
- - https://github.com/shinomakoi/AI-Messenger - Supports EXLv2 and LLava
62
+ - Customizable via Slots
63
+
64
+ ## 📦 Install
65
+
66
+ To use reachat in your project, install it via npm/yarn:
67
+
68
+ ```
69
+ npm i reachat --save
70
+ ```
71
+
72
+ ## 🔭 Development
73
+
74
+ If you want to run reachat locally, its super easy!
75
+
76
+ - Clone the repository
77
+ - `npm i`
78
+ - `npm start`
79
+ - Browser opens to Storybook page
80
+
81
+ ## ❤️ Contributors & Credits
82
+
83
+ Thanks to all our contributors!
84
+
85
+ <a href="https://github.com/reaviz/reaviz/graphs/contributors"><img src="https://opencollective.com/reaviz/contributors.svg?width=890" /></a>
86
+
@@ -1,13 +1,23 @@
1
- import { FC } from 'react';
2
- import { ResponseTransformer, Session } from './types';
1
+ import { CSSProperties, FC, PropsWithChildren } from 'react';
2
+ import { Session } from './types';
3
+ import { ChatTheme } from './theme';
4
+ import { PluggableList } from 'react-markdown/lib';
3
5
 
4
- export interface SessionsProps {
6
+ export interface ChatProps extends PropsWithChildren {
7
+ /**
8
+ * The style to apply to the root element.
9
+ */
10
+ style?: CSSProperties;
11
+ /**
12
+ * The class name to apply to the root element.
13
+ */
14
+ className?: string;
5
15
  /**
6
16
  * The type of prompt to display. Companion prompts are smaller and are
7
17
  * meant to be displayed alongside other content. Full prompts are larger
8
18
  * and are meant to be displayed on their own.
9
19
  */
10
- viewType: 'companion' | 'full';
20
+ viewType?: 'companion' | 'console';
11
21
  /**
12
22
  * The list of sessions to display.
13
23
  */
@@ -17,17 +27,17 @@ export interface SessionsProps {
17
27
  */
18
28
  activeSessionId?: string;
19
29
  /**
20
- * Indicates whether the sessions are currently loading.
30
+ * Custom theme for the chat.
21
31
  */
22
- isLoading?: boolean;
32
+ theme?: ChatTheme;
23
33
  /**
24
- * Placeholder text for the input field.
34
+ * Remark plugins to apply to the request/response.
25
35
  */
26
- inputPlaceholder?: string;
36
+ remarkPlugins?: PluggableList[];
27
37
  /**
28
- * Array of transformer functions to apply to the response.
38
+ * Whether to display a loading state.
29
39
  */
30
- responseTransformers?: ResponseTransformer[];
40
+ isLoading?: boolean;
31
41
  /**
32
42
  * Callback function to handle when a session is selected.
33
43
  */
@@ -37,12 +47,8 @@ export interface SessionsProps {
37
47
  */
38
48
  onDeleteSession?: (sessionId: string) => void;
39
49
  /**
40
- * Callback function to handle sending a new message.
41
- */
42
- onSendMessage?: (message: string) => void;
43
- /**
44
- * Callback function to handle stopping the current action.
50
+ * Callback function to handle creating a new session.
45
51
  */
46
- onStopMessage?: () => void;
52
+ onNewSession?: () => void;
47
53
  }
48
- export declare const Sessions: FC<SessionsProps>;
54
+ export declare const Chat: FC<ChatProps>;
@@ -0,0 +1,16 @@
1
+ import { Session } from './types';
2
+ import { ChatTheme } from './theme';
3
+ import { PluggableList } from 'react-markdown/lib';
4
+
5
+ export interface ChatContextProps {
6
+ sessions: Session[];
7
+ activeSessionId: string | null;
8
+ theme?: ChatTheme;
9
+ isLoading?: boolean;
10
+ activeSession?: Session | null;
11
+ remarkPlugins?: PluggableList[];
12
+ selectSession?: (sessionId: string) => void;
13
+ deleteSession?: (sessionId: string) => void;
14
+ createSession?: () => void;
15
+ }
16
+ export declare const ChatContext: import('react').Context<ChatContextProps>;
@@ -0,0 +1,42 @@
1
+ import { FC, ReactElement } from 'react';
2
+
3
+ interface ChatInputProps {
4
+ /**
5
+ * Default value for the input field.
6
+ */
7
+ defaultValue?: string;
8
+ /**
9
+ * Allowed file types for upload.
10
+ */
11
+ allowedFiles?: string[];
12
+ /**
13
+ * Placeholder text for the input field.
14
+ */
15
+ placeholder?: string;
16
+ /**
17
+ * Icon to show for send.
18
+ */
19
+ sendIcon?: ReactElement;
20
+ /**
21
+ * Icon to show for send.
22
+ */
23
+ stopIcon?: ReactElement;
24
+ /**
25
+ * Icon to show for attach.
26
+ */
27
+ attachIcon?: ReactElement;
28
+ /**
29
+ * Callback function to handle sending a new message.
30
+ */
31
+ onSendMessage?: (message: string) => void;
32
+ /**
33
+ * Callback function to handle stopping the current action.
34
+ */
35
+ onStopMessage?: () => void;
36
+ /**
37
+ * Callback function to handle file upload.
38
+ */
39
+ onFileUpload?: (file: File) => void;
40
+ }
41
+ export declare const ChatInput: FC<ChatInputProps>;
42
+ export {};
@@ -0,0 +1,9 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+
3
+ export interface CodeHighlighterProps extends PropsWithChildren {
4
+ /**
5
+ * The class name to apply to the code block.
6
+ */
7
+ className?: string;
8
+ }
9
+ export declare const CodeHighlighter: FC<CodeHighlighterProps>;
@@ -0,0 +1,11 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { PluggableList } from 'react-markdown/lib';
3
+
4
+ interface MarkdownWrapperProps extends PropsWithChildren {
5
+ /**
6
+ * Remark plugins to apply to the markdown content.
7
+ */
8
+ remarkPlugins?: PluggableList[];
9
+ }
10
+ export declare const Markdown: FC<MarkdownWrapperProps>;
11
+ export {};
@@ -0,0 +1,5 @@
1
+ import { default as React, FC, PropsWithChildren } from 'react';
2
+
3
+ export declare const TableComponent: FC<PropsWithChildren<React.HTMLAttributes<HTMLTableElement>>>;
4
+ export declare const TableHeaderCell: FC<PropsWithChildren<React.HTMLAttributes<HTMLTableHeaderCellElement>>>;
5
+ export declare const TableDataCell: FC<PropsWithChildren<React.HTMLAttributes<HTMLTableDataCellElement>>>;
@@ -0,0 +1,4 @@
1
+ export * from './Markdown';
2
+ export * from './Table';
3
+ export * from './CodeHighlighter';
4
+ export * from './plugins';
@@ -0,0 +1 @@
1
+ export * from './remarkCve';
@@ -0,0 +1 @@
1
+ export declare function remarkCve(): (tree: any, _file: any) => void;
@@ -0,0 +1,45 @@
1
+ import { FC, PropsWithChildren, ReactElement } from 'react';
2
+
3
+ export interface MessageActionsProps extends PropsWithChildren {
4
+ /**
5
+ * Question to be copied
6
+ */
7
+ question: string;
8
+ /**
9
+ * Response to be copied
10
+ */
11
+ response?: string;
12
+ /**
13
+ * Icon to show for copy.
14
+ */
15
+ copyIcon?: ReactElement;
16
+ /**
17
+ * Icon to show for thumbs up.
18
+ */
19
+ thumbsUpIcon?: ReactElement;
20
+ /**
21
+ * Icon to show for thumbs down.
22
+ */
23
+ thumbsDownIcon?: ReactElement;
24
+ /**
25
+ * Icon to show for refresh.
26
+ */
27
+ refreshIcon?: ReactElement;
28
+ /**
29
+ * Callback function to handle copying.
30
+ */
31
+ onCopy?: () => void;
32
+ /**
33
+ * Callback function to handle upvoting.
34
+ */
35
+ onUpvote?: () => void;
36
+ /**
37
+ * Callback function to handle downvoting.
38
+ */
39
+ onDownvote?: () => void;
40
+ /**
41
+ * Callback function to handle refreshing.
42
+ */
43
+ onRefresh?: () => void;
44
+ }
45
+ export declare const MessageActions: FC<MessageActionsProps>;
@@ -0,0 +1,14 @@
1
+ import { FC, ReactElement } from 'react';
2
+ import { ConversationFile } from '../types';
3
+
4
+ export interface MessageFileProps extends ConversationFile {
5
+ /**
6
+ * Icon to show for delete.
7
+ */
8
+ fileIcon?: ReactElement;
9
+ /**
10
+ * Limit for the name.
11
+ */
12
+ limit?: number;
13
+ }
14
+ export declare const MessageFile: FC<MessageFileProps>;
@@ -0,0 +1,11 @@
1
+ import { ConversationFile } from '../types';
2
+ import { FC, PropsWithChildren } from 'react';
3
+
4
+ interface MessageFilesProps extends PropsWithChildren {
5
+ /**
6
+ * Files to render.
7
+ */
8
+ files: ConversationFile[];
9
+ }
10
+ export declare const MessageFiles: FC<MessageFilesProps>;
11
+ export {};
@@ -0,0 +1,9 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+
3
+ export interface MessageQuestionProps extends PropsWithChildren {
4
+ /**
5
+ * Question to render.
6
+ */
7
+ question: string;
8
+ }
9
+ export declare const MessageQuestion: FC<MessageQuestionProps>;
@@ -0,0 +1,13 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+
3
+ export interface MessageResponseProps extends PropsWithChildren {
4
+ /**
5
+ * Response to render.
6
+ */
7
+ response: string;
8
+ /**
9
+ * Whether the response is loading.
10
+ */
11
+ isLoading?: boolean;
12
+ }
13
+ export declare const MessageResponse: FC<MessageResponseProps>;
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ import { ConversationSource } from '../types';
3
+
4
+ export interface MessageSourceProps extends ConversationSource {
5
+ /**
6
+ * Limit for the title.
7
+ */
8
+ limit?: number;
9
+ }
10
+ export declare const MessageSource: FC<MessageSourceProps>;
@@ -0,0 +1,11 @@
1
+ import { ConversationSource } from '../types';
2
+ import { FC, PropsWithChildren } from 'react';
3
+
4
+ interface MessageSourcesProps extends PropsWithChildren {
5
+ /**
6
+ * Sources to render.
7
+ */
8
+ sources: ConversationSource[];
9
+ }
10
+ export declare const MessageSources: FC<MessageSourcesProps>;
11
+ export {};
@@ -0,0 +1,6 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+
3
+ interface SessionEmptyProps extends PropsWithChildren {
4
+ }
5
+ export declare const SessionEmpty: FC<SessionEmptyProps>;
6
+ export {};
@@ -0,0 +1,15 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+ import { Conversation } from '../types';
3
+
4
+ interface SessionMessageProps extends PropsWithChildren {
5
+ /**
6
+ * Conversation to render.
7
+ */
8
+ conversation: Conversation;
9
+ /**
10
+ * Whether the message is the last one in the list.
11
+ */
12
+ isLast?: boolean;
13
+ }
14
+ export declare const SessionMessage: FC<SessionMessageProps>;
15
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+
3
+ export declare const SessionMessagePanel: FC<PropsWithChildren>;
@@ -0,0 +1,23 @@
1
+ import { default as React, ReactNode } from 'react';
2
+ import { Conversation } from '../types';
3
+
4
+ interface SessionMessagesProps {
5
+ /**
6
+ * Content to display when there are no sessions selected or a new session is started.
7
+ */
8
+ newSessionContent?: string | ReactNode;
9
+ /**
10
+ * Limit the number of results returned. Clientside pagination.
11
+ */
12
+ limit?: number | null;
13
+ /**
14
+ * Text to display for the show more button.
15
+ */
16
+ showMoreText?: string;
17
+ /**
18
+ * Render function for the session messages.
19
+ */
20
+ children?: (conversations: Conversation[]) => ReactNode;
21
+ }
22
+ export declare const SessionMessages: React.FC<SessionMessagesProps>;
23
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+
3
+ export declare const SessionMessagesHeader: FC<PropsWithChildren>;
@@ -0,0 +1,12 @@
1
+ export * from './SessionEmpty';
2
+ export * from './SessionMessagesHeader';
3
+ export * from './SessionMessagePanel';
4
+ export * from './SessionMessage';
5
+ export * from './SessionMessages';
6
+ export * from './MessageSource';
7
+ export * from './MessageActions';
8
+ export * from './MessageFile';
9
+ export * from './MessageFiles';
10
+ export * from './MessageQuestion';
11
+ export * from './MessageResponse';
12
+ export * from './MessageSources';
@@ -0,0 +1,10 @@
1
+ import { FC, PropsWithChildren, ReactNode } from 'react';
2
+
3
+ interface NewSessionButtonProps extends PropsWithChildren {
4
+ /**
5
+ * Text for the new session button.
6
+ */
7
+ newSessionText?: string | ReactNode;
8
+ }
9
+ export declare const NewSessionButton: FC<NewSessionButtonProps>;
10
+ export {};
@@ -0,0 +1,10 @@
1
+ import { FC, ReactNode } from 'react';
2
+ import { GroupedSessions } from '../utils';
3
+
4
+ export interface SessionGroupsProps {
5
+ /**
6
+ * Render function for the session groups.
7
+ */
8
+ children: (groups: GroupedSessions[]) => ReactNode;
9
+ }
10
+ export declare const SessionGroups: FC<SessionGroupsProps>;
@@ -0,0 +1,22 @@
1
+ import { FC, PropsWithChildren, ReactElement } from 'react';
2
+ import { Session } from '../types';
3
+
4
+ export interface SessionListItemProps extends PropsWithChildren {
5
+ /**
6
+ * Session to display.
7
+ */
8
+ session: Session;
9
+ /**
10
+ * Indicates whether the session is deletable.
11
+ */
12
+ deletable?: boolean;
13
+ /**
14
+ * Icon to show for delete.
15
+ */
16
+ deleteIcon?: ReactElement;
17
+ /**
18
+ * Limit for the ellipsis.
19
+ */
20
+ limit?: number;
21
+ }
22
+ export declare const SessionListItem: FC<SessionListItemProps>;
@@ -0,0 +1,10 @@
1
+ import { FC, PropsWithChildren, ReactNode } from 'react';
2
+
3
+ interface SessionsGroupProps extends PropsWithChildren {
4
+ /**
5
+ * Heading for the session group.
6
+ */
7
+ heading?: string | ReactNode;
8
+ }
9
+ export declare const SessionsGroup: FC<SessionsGroupProps>;
10
+ export {};
@@ -0,0 +1,3 @@
1
+ import { FC, PropsWithChildren } from 'react';
2
+
3
+ export declare const SessionsList: FC<PropsWithChildren>;
@@ -0,0 +1,5 @@
1
+ export * from './SessionsList';
2
+ export * from './SessionListItem';
3
+ export * from './NewSessionButton';
4
+ export * from './SessionGroups';
5
+ export * from './SessionsGroup';