agentic-chat-ui-components 0.0.2-testing-v0.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 ADDED
@@ -0,0 +1,164 @@
1
+ # Agentic Chat Components
2
+
3
+ A React component library for building AI chat interfaces with LangChain/LangGraph integration.
4
+
5
+ ## Features
6
+
7
+ - 🎨 **Pre-styled chat UI components** - Sidebar, message bubbles, input fields, markdown rendering
8
+ - 🔄 **Streaming support** - Real-time AI response streaming
9
+ - 📎 **File uploads** - Built-in file handling and metadata
10
+ - 🎭 **Custom components** - Inject your own React components into chat messages
11
+ - 🧩 **Provider-based architecture** - Flexible state management with React Context
12
+ - 📝 **TypeScript** - Full type definitions included
13
+ - 🎨 **Tailwind CSS** - Pre-built styles, easy to customize
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install agentic-chat-ui-components
19
+ ```
20
+
21
+ **Peer dependencies** (install these separately):
22
+
23
+ ```bash
24
+ npm install react react-dom @langchain/core @langchain/langgraph @langchain/langgraph-sdk framer-motion lucide-react react-markdown react-spinners rehype-highlight remark-gfm sonner @radix-ui/react-label
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ```tsx
30
+ import {
31
+ Sidebar,
32
+ ChatProvider
33
+ } from 'agentic-chat-ui-components';
34
+ import 'agentic-chat-ui-components/styles.css';
35
+
36
+ function App() {
37
+ return (
38
+ <ChatProvider
39
+ apiUrl="your-api-url"
40
+ assistantId="your-assistant-id"
41
+ identity={{ user_id: "user123", org_id: "org456" }}
42
+ >
43
+ <Sidebar />
44
+ </ChatProvider>
45
+ );
46
+ }
47
+ ```
48
+
49
+ ## Exported Components
50
+
51
+ - `Sidebar` - Main chat UI with sidebar navigation
52
+
53
+ ## Exported Providers
54
+
55
+ - `ChatProvider` - Core chat state management
56
+ - `ChatRuntimeProvider` - Runtime configuration
57
+ - `ThreadProvider` - Conversation thread management
58
+ - `StreamProvider` - AI streaming responses
59
+ - `FileProvider` - File upload handling
60
+ - `CustomComponentProvider` - Custom component rendering
61
+
62
+ ## Exported Hooks
63
+
64
+ - `useThread()` - Access thread state
65
+ - `useStreamContext()` - Access streaming state
66
+ - `useChatRuntime()` - Access runtime config
67
+ - `useFileProvider()` - Access file state
68
+ - `useCustomComponents()` - Register custom components
69
+
70
+ ## sendMessage Function
71
+
72
+ The `sendMessage` function is available through the `useStreamContext()` hook and allows you to send messages programmatically to the AI agent.
73
+
74
+ ### Parameters
75
+
76
+ - `message` (Message | string): The message content. Can be a string for simple text messages or a full Message object for more control.
77
+ - `options` (optional object):
78
+ - `isAIMessage` (boolean, optional): If true, the message is intended for the agent only and won't be visible to the user. Defaults to false.
79
+ - `config` (any, optional): Additional configuration to pass to the agent.
80
+
81
+ ### Usage Example
82
+
83
+ ```tsx
84
+ import { useStreamContext } from 'agentic-chat-ui-components';
85
+
86
+ function MyComponent() {
87
+ const { sendMessage } = useStreamContext();
88
+
89
+ const handleSend = async () => {
90
+ await sendMessage("Hello, AI!", { isAIMessage: false });
91
+ };
92
+
93
+ return <button onClick={handleSend}>Send Message</button>;
94
+ }
95
+ ```
96
+
97
+ This will send a user-visible message "Hello, AI!" to the agent.
98
+
99
+ For agent-only messages:
100
+
101
+ ```tsx
102
+ await sendMessage("Internal event occurred", { isAIMessage: true });
103
+ ```
104
+
105
+ ## Custom Components
106
+
107
+ You can inject custom React components into chat messages using the `CustomComponentProvider`. Components are registered by name and can be referenced in message content.
108
+
109
+ ### Registering Components via Props
110
+
111
+ Pass initial components as the `initialComponents` prop to `CustomComponentProvider`:
112
+
113
+ ```tsx
114
+ import { CustomComponentProvider } from 'agentic-chat-ui-components';
115
+
116
+ const MyCustomButton = ({ text }) => <button>{text}</button>;
117
+
118
+ function App() {
119
+ return (
120
+ <CustomComponentProvider
121
+ initialComponents={{
122
+ 'my-button': MyCustomButton,
123
+ }}
124
+ >
125
+ {/* Your app */}
126
+ </CustomComponentProvider>
127
+ );
128
+ }
129
+ ```
130
+
131
+ ### Registering Components Programmatically
132
+
133
+ Use the `registerComponent` method from the `useCustomComponents` hook:
134
+
135
+ ```tsx
136
+ import { useCustomComponents } from 'agentic-chat-ui-components';
137
+
138
+ function RegisterComponent() {
139
+ const { registerComponent } = useCustomComponents();
140
+
141
+ useEffect(() => {
142
+ registerComponent('my-button', ({ text }) => <button>{text}</button>);
143
+ }, [registerComponent]);
144
+
145
+ return null;
146
+ }
147
+ ```
148
+
149
+ ### Additional Methods
150
+
151
+ - `registerComponents(components)`: Register multiple components at once.
152
+ - `unregisterComponent(name)`: Remove a registered component.
153
+
154
+ ## Types
155
+
156
+ Full TypeScript definitions available for:
157
+ - `ChatIdentity`
158
+ - `ChatRuntimeContextValue`
159
+ - `FileInfo`
160
+ - `Metadata`
161
+
162
+ ## Development Notes
163
+
164
+ This library is designed to work with LangChain/LangGraph for AI agent interactions. All heavy dependencies are peer dependencies to keep the bundle size small (~50-200 KB).