@a.izzuddin/ai-chat 0.1.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/README.md +293 -0
- package/README.npm.md +293 -0
- package/custom-elements.json +729 -0
- package/dist/index.d.mts +71 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +422 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +422 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +82 -0
package/README.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# @a.izzuddin/ai-chat
|
|
2
|
+
|
|
3
|
+
A **framework-agnostic** AI chat web component built with Lit and TypeScript. Works seamlessly with React, Vue, Svelte, Angular, and vanilla JavaScript.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@yourusername/ai-chat)
|
|
6
|
+
[](https://www.npmjs.com/package/@yourusername/ai-chat)
|
|
7
|
+
|
|
8
|
+
## ✨ Features
|
|
9
|
+
|
|
10
|
+
- 🌐 **Framework Agnostic** - Works with any framework or no framework
|
|
11
|
+
- 🎨 **Beautiful UI** - Modern chat interface with light/dark mode
|
|
12
|
+
- ⚡ **Lightweight** - Only ~15KB (gzipped)
|
|
13
|
+
- 🔧 **Fully Customizable** - Configure API endpoint, styling, and behavior
|
|
14
|
+
- 📱 **Responsive** - Mobile-friendly design
|
|
15
|
+
- 🎯 **TypeScript** - Full type safety and IntelliSense
|
|
16
|
+
- ♿ **Accessible** - Semantic HTML and ARIA attributes
|
|
17
|
+
- 🎪 **Event-Driven** - Listen to messages, responses, and errors
|
|
18
|
+
|
|
19
|
+
## 📦 Installation
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install @yourusername/ai-chat
|
|
23
|
+
# or
|
|
24
|
+
yarn add @yourusername/ai-chat
|
|
25
|
+
# or
|
|
26
|
+
pnpm add @yourusername/ai-chat
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 🚀 Quick Start
|
|
30
|
+
|
|
31
|
+
### Vanilla JavaScript / HTML
|
|
32
|
+
|
|
33
|
+
```html
|
|
34
|
+
<!DOCTYPE html>
|
|
35
|
+
<html>
|
|
36
|
+
<body>
|
|
37
|
+
<script type="module">
|
|
38
|
+
import '@yourusername/ai-chat';
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<ai-chat
|
|
42
|
+
api-url="https://your-api.com"
|
|
43
|
+
session-id="user-123"
|
|
44
|
+
title="My AI Assistant">
|
|
45
|
+
</ai-chat>
|
|
46
|
+
</body>
|
|
47
|
+
</html>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### React
|
|
51
|
+
|
|
52
|
+
```tsx
|
|
53
|
+
import '@yourusername/ai-chat';
|
|
54
|
+
|
|
55
|
+
function App() {
|
|
56
|
+
return (
|
|
57
|
+
<ai-chat
|
|
58
|
+
api-url={process.env.REACT_APP_API_URL}
|
|
59
|
+
session-id="user-123"
|
|
60
|
+
title="AI Assistant"
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Vue
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<template>
|
|
70
|
+
<ai-chat
|
|
71
|
+
:api-url="apiUrl"
|
|
72
|
+
session-id="user-123"
|
|
73
|
+
title="AI Assistant"
|
|
74
|
+
/>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<script setup>
|
|
78
|
+
import '@yourusername/ai-chat';
|
|
79
|
+
const apiUrl = import.meta.env.VITE_API_URL;
|
|
80
|
+
</script>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Svelte
|
|
84
|
+
|
|
85
|
+
```svelte
|
|
86
|
+
<script>
|
|
87
|
+
import '@yourusername/ai-chat';
|
|
88
|
+
export let apiUrl;
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<ai-chat
|
|
92
|
+
api-url={apiUrl}
|
|
93
|
+
session-id="user-123"
|
|
94
|
+
title="AI Assistant"
|
|
95
|
+
/>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Angular
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
|
|
102
|
+
import '@yourusername/ai-chat';
|
|
103
|
+
|
|
104
|
+
@Component({
|
|
105
|
+
selector: 'app-root',
|
|
106
|
+
template: '<ai-chat api-url="..." session-id="user-123"></ai-chat>',
|
|
107
|
+
schemas: [CUSTOM_ELEMENTS_SCHEMA]
|
|
108
|
+
})
|
|
109
|
+
export class AppComponent {}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 📖 API
|
|
113
|
+
|
|
114
|
+
### Attributes
|
|
115
|
+
|
|
116
|
+
| Attribute | Type | Default | Description |
|
|
117
|
+
|-----------|------|---------|-------------|
|
|
118
|
+
| `api-url` | `string` | **required** | Your API endpoint URL |
|
|
119
|
+
| `session-id` | `string` | `"default-session"` | Session identifier for conversation context |
|
|
120
|
+
| `title` | `string` | `"My AI Agent"` | Chat header title |
|
|
121
|
+
| `theme` | `"light" \| "dark"` | `"light"` | UI theme |
|
|
122
|
+
| `initial-messages` | `Message[]` | `[]` | Pre-populate chat with messages |
|
|
123
|
+
|
|
124
|
+
### Properties (JavaScript)
|
|
125
|
+
|
|
126
|
+
```javascript
|
|
127
|
+
const chat = document.querySelector('ai-chat');
|
|
128
|
+
|
|
129
|
+
// Set properties
|
|
130
|
+
chat.apiUrl = 'https://api.example.com';
|
|
131
|
+
chat.sessionId = 'user-123';
|
|
132
|
+
chat.title = 'Support Bot';
|
|
133
|
+
chat.theme = 'dark';
|
|
134
|
+
chat.initialMessages = [
|
|
135
|
+
{ id: '1', role: 'assistant', content: 'Hello! How can I help?' }
|
|
136
|
+
];
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Events
|
|
140
|
+
|
|
141
|
+
```javascript
|
|
142
|
+
const chat = document.querySelector('ai-chat');
|
|
143
|
+
|
|
144
|
+
// User sends a message
|
|
145
|
+
chat.addEventListener('message-sent', (event) => {
|
|
146
|
+
console.log('User message:', event.detail);
|
|
147
|
+
// event.detail: { id: string, role: 'user', content: string }
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
// AI responds
|
|
151
|
+
chat.addEventListener('response-received', (event) => {
|
|
152
|
+
console.log('AI response:', event.detail);
|
|
153
|
+
// event.detail: { id: string, role: 'assistant', content: string }
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
// Error occurs
|
|
157
|
+
chat.addEventListener('error', (event) => {
|
|
158
|
+
console.error('Chat error:', event.detail);
|
|
159
|
+
// event.detail: Error object
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### TypeScript Types
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import type { Message } from '@yourusername/ai-chat';
|
|
167
|
+
|
|
168
|
+
interface Message {
|
|
169
|
+
id: string;
|
|
170
|
+
role: 'user' | 'assistant';
|
|
171
|
+
content: string;
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## 🔌 Backend API Requirements
|
|
176
|
+
|
|
177
|
+
Your API must implement this endpoint:
|
|
178
|
+
|
|
179
|
+
**POST `/ask`**
|
|
180
|
+
|
|
181
|
+
Request:
|
|
182
|
+
```json
|
|
183
|
+
{
|
|
184
|
+
"session_id": "string",
|
|
185
|
+
"question": "string"
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
Response:
|
|
190
|
+
```json
|
|
191
|
+
{
|
|
192
|
+
"response": "string"
|
|
193
|
+
}
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## 🎨 Theming
|
|
197
|
+
|
|
198
|
+
### Built-in Themes
|
|
199
|
+
|
|
200
|
+
```html
|
|
201
|
+
<!-- Light mode (default) -->
|
|
202
|
+
<ai-chat theme="light"></ai-chat>
|
|
203
|
+
|
|
204
|
+
<!-- Dark mode -->
|
|
205
|
+
<ai-chat theme="dark"></ai-chat>
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### CSS Custom Properties
|
|
209
|
+
|
|
210
|
+
Customize colors by overriding CSS variables:
|
|
211
|
+
|
|
212
|
+
```css
|
|
213
|
+
ai-chat {
|
|
214
|
+
--ai-chat-primary: #2563eb;
|
|
215
|
+
--ai-chat-background: #ffffff;
|
|
216
|
+
--ai-chat-text: #09090b;
|
|
217
|
+
/* ... more variables */
|
|
218
|
+
}
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Shadow DOM
|
|
222
|
+
|
|
223
|
+
The component uses Shadow DOM for style encapsulation. To style internal elements, use `::part()`:
|
|
224
|
+
|
|
225
|
+
```css
|
|
226
|
+
ai-chat::part(header) {
|
|
227
|
+
background: linear-gradient(to right, #667eea, #764ba2);
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## 📚 Examples
|
|
232
|
+
|
|
233
|
+
Check out the [examples](./examples) directory for complete working examples:
|
|
234
|
+
|
|
235
|
+
- [Vanilla JavaScript](./examples/vanilla.html)
|
|
236
|
+
- [React](./examples/react.tsx)
|
|
237
|
+
- [Vue](./examples/vue.vue)
|
|
238
|
+
- [Svelte](./examples/svelte.svelte)
|
|
239
|
+
- [Angular](./examples/angular.component.ts)
|
|
240
|
+
|
|
241
|
+
## 🌍 Browser Support
|
|
242
|
+
|
|
243
|
+
- Chrome/Edge 90+
|
|
244
|
+
- Firefox 88+
|
|
245
|
+
- Safari 14+
|
|
246
|
+
- Mobile browsers (iOS Safari 14+, Chrome Android)
|
|
247
|
+
|
|
248
|
+
Requires native Web Components support (Custom Elements v1, Shadow DOM v1).
|
|
249
|
+
|
|
250
|
+
## 🔄 Migration from React Version
|
|
251
|
+
|
|
252
|
+
If you were using the React-only version:
|
|
253
|
+
|
|
254
|
+
**Before:**
|
|
255
|
+
```tsx
|
|
256
|
+
import { AIChat } from '@yourusername/ai-chat';
|
|
257
|
+
<AIChat apiUrl="..." />
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
**After:**
|
|
261
|
+
```tsx
|
|
262
|
+
import '@yourusername/ai-chat';
|
|
263
|
+
<ai-chat api-url="..." />
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Key differences:
|
|
267
|
+
- Component name is lowercase: `<ai-chat>` instead of `<AIChat>`
|
|
268
|
+
- Attributes use kebab-case: `api-url` instead of `apiUrl`
|
|
269
|
+
- Events instead of callback props
|
|
270
|
+
|
|
271
|
+
## 🤝 Contributing
|
|
272
|
+
|
|
273
|
+
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md).
|
|
274
|
+
|
|
275
|
+
## 📄 License
|
|
276
|
+
|
|
277
|
+
MIT © [Your Name]
|
|
278
|
+
|
|
279
|
+
## 🔗 Links
|
|
280
|
+
|
|
281
|
+
- [Documentation](https://github.com/yourusername/ai-chat#readme)
|
|
282
|
+
- [Examples](./examples)
|
|
283
|
+
- [Issue Tracker](https://github.com/yourusername/ai-chat/issues)
|
|
284
|
+
- [npm Package](https://www.npmjs.com/package/@yourusername/ai-chat)
|
|
285
|
+
|
|
286
|
+
## ⭐ Similar Projects
|
|
287
|
+
|
|
288
|
+
- [@n8n/chat](https://www.npmjs.com/package/@n8n/chat) - n8n's chat widget
|
|
289
|
+
- [Lit](https://lit.dev/) - The library powering this component
|
|
290
|
+
|
|
291
|
+
---
|
|
292
|
+
|
|
293
|
+
**Built with [Lit](https://lit.dev/)** • **Powered by Web Components**
|
package/README.npm.md
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
# @yourusername/ai-chat
|
|
2
|
+
|
|
3
|
+
A beautiful, configurable AI chat component for React applications. Built with Radix UI, Tailwind CSS, and TypeScript.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🎨 **Beautiful UI** - Modern chat interface with dark mode support
|
|
8
|
+
- ⚡ **Lightweight** - Minimal dependencies, optimized bundle size
|
|
9
|
+
- 🔧 **Configurable** - Customize API endpoint, session management, styling
|
|
10
|
+
- 📱 **Responsive** - Works great on mobile and desktop
|
|
11
|
+
- 🎯 **TypeScript** - Full type safety out of the box
|
|
12
|
+
- ♿ **Accessible** - Built on Radix UI primitives
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @yourusername/ai-chat
|
|
18
|
+
# or
|
|
19
|
+
yarn add @yourusername/ai-chat
|
|
20
|
+
# or
|
|
21
|
+
pnpm add @yourusername/ai-chat
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Peer Dependencies
|
|
25
|
+
|
|
26
|
+
This package requires React 18+ or React 19+:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install react react-dom
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Quick Start
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
import { AIChat } from "@yourusername/ai-chat";
|
|
36
|
+
import "@yourusername/ai-chat/styles";
|
|
37
|
+
|
|
38
|
+
function App() {
|
|
39
|
+
return (
|
|
40
|
+
<AIChat
|
|
41
|
+
apiUrl="https://your-api-endpoint.com"
|
|
42
|
+
sessionId="user-123"
|
|
43
|
+
title="My AI Assistant"
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Tailwind CSS Setup
|
|
50
|
+
|
|
51
|
+
This component uses Tailwind CSS. Add the component path to your `tailwind.config.js`:
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
/** @type {import('tailwindcss').Config} */
|
|
55
|
+
module.exports = {
|
|
56
|
+
content: [
|
|
57
|
+
"./app/**/*.{js,ts,jsx,tsx}",
|
|
58
|
+
"./components/**/*.{js,ts,jsx,tsx}",
|
|
59
|
+
// Add this line:
|
|
60
|
+
"./node_modules/@yourusername/ai-chat/**/*.{js,ts,jsx,tsx}",
|
|
61
|
+
],
|
|
62
|
+
// ... rest of your config
|
|
63
|
+
};
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Or if using Tailwind v4, add to your CSS:
|
|
67
|
+
|
|
68
|
+
```css
|
|
69
|
+
@import "tailwindcss";
|
|
70
|
+
@import "@yourusername/ai-chat/styles";
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Requirements
|
|
74
|
+
|
|
75
|
+
Your API endpoint should accept POST requests to `/ask` with this format:
|
|
76
|
+
|
|
77
|
+
**Request:**
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"session_id": "string",
|
|
81
|
+
"question": "string"
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
**Response:**
|
|
86
|
+
```json
|
|
87
|
+
{
|
|
88
|
+
"response": "string"
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Props
|
|
93
|
+
|
|
94
|
+
| Prop | Type | Default | Description |
|
|
95
|
+
|------|------|---------|-------------|
|
|
96
|
+
| `apiUrl` | `string` | *required* | Your API endpoint URL |
|
|
97
|
+
| `sessionId` | `string` | `"default-session"` | Session identifier for conversation context |
|
|
98
|
+
| `title` | `string` | `"My AI Agent"` | Chat header title |
|
|
99
|
+
| `initialMessages` | `Message[]` | `[]` | Pre-populate chat with messages |
|
|
100
|
+
| `className` | `string` | `undefined` | Custom CSS class for container |
|
|
101
|
+
| `onMessageSent` | `(message: Message) => void` | `undefined` | Callback when user sends a message |
|
|
102
|
+
| `onResponseReceived` | `(message: Message) => void` | `undefined` | Callback when AI responds |
|
|
103
|
+
| `onError` | `(error: Error) => void` | `undefined` | Callback when an error occurs |
|
|
104
|
+
|
|
105
|
+
## Advanced Usage
|
|
106
|
+
|
|
107
|
+
### With Custom Styling
|
|
108
|
+
|
|
109
|
+
```tsx
|
|
110
|
+
<AIChat
|
|
111
|
+
apiUrl="https://api.example.com"
|
|
112
|
+
className="max-w-4xl mx-auto shadow-lg"
|
|
113
|
+
title="Customer Support Bot"
|
|
114
|
+
/>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
### With Event Handlers
|
|
118
|
+
|
|
119
|
+
```tsx
|
|
120
|
+
<AIChat
|
|
121
|
+
apiUrl="https://api.example.com"
|
|
122
|
+
onMessageSent={(message) => {
|
|
123
|
+
// Track analytics
|
|
124
|
+
analytics.track("message_sent", { content: message.content });
|
|
125
|
+
}}
|
|
126
|
+
onResponseReceived={(message) => {
|
|
127
|
+
// Log responses
|
|
128
|
+
console.log("AI responded:", message.content);
|
|
129
|
+
}}
|
|
130
|
+
onError={(error) => {
|
|
131
|
+
// Handle errors
|
|
132
|
+
toast.error(error.message);
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### With Initial Messages
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
const welcomeMessages = [
|
|
141
|
+
{
|
|
142
|
+
id: "1",
|
|
143
|
+
role: "assistant" as const,
|
|
144
|
+
content: "Hello! How can I help you today?",
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
|
|
148
|
+
<AIChat
|
|
149
|
+
apiUrl="https://api.example.com"
|
|
150
|
+
initialMessages={welcomeMessages}
|
|
151
|
+
/>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### With Dynamic Session Management
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
import { useUser } from "@/hooks/useUser";
|
|
158
|
+
|
|
159
|
+
function ChatPage() {
|
|
160
|
+
const user = useUser();
|
|
161
|
+
|
|
162
|
+
return (
|
|
163
|
+
<AIChat
|
|
164
|
+
apiUrl={process.env.NEXT_PUBLIC_API_URL!}
|
|
165
|
+
sessionId={user.id}
|
|
166
|
+
title={`Chat with ${user.name}'s Assistant`}
|
|
167
|
+
/>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## TypeScript
|
|
173
|
+
|
|
174
|
+
Full TypeScript support is included. Import types as needed:
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
import type { Message, AIChatProps } from "@yourusername/ai-chat";
|
|
178
|
+
|
|
179
|
+
const customMessage: Message = {
|
|
180
|
+
id: "123",
|
|
181
|
+
role: "user",
|
|
182
|
+
content: "Hello!",
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## Styling
|
|
187
|
+
|
|
188
|
+
The component uses Tailwind CSS with custom theme variables. You can customize the appearance by:
|
|
189
|
+
|
|
190
|
+
1. **Using Tailwind's dark mode**: The component automatically supports dark mode
|
|
191
|
+
2. **Custom CSS variables**: Override theme colors in your global CSS
|
|
192
|
+
3. **className prop**: Add custom Tailwind classes to the container
|
|
193
|
+
|
|
194
|
+
### Custom Theme Colors
|
|
195
|
+
|
|
196
|
+
```css
|
|
197
|
+
@layer base {
|
|
198
|
+
:root {
|
|
199
|
+
--primary: oklch(0.205 0 0);
|
|
200
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
201
|
+
/* ... other variables */
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.dark {
|
|
205
|
+
--primary: oklch(0.922 0 0);
|
|
206
|
+
--primary-foreground: oklch(0.205 0 0);
|
|
207
|
+
/* ... other variables */
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## Framework Support
|
|
213
|
+
|
|
214
|
+
### Next.js (App Router)
|
|
215
|
+
|
|
216
|
+
```tsx
|
|
217
|
+
"use client";
|
|
218
|
+
|
|
219
|
+
import { AIChat } from "@yourusername/ai-chat";
|
|
220
|
+
import "@yourusername/ai-chat/styles";
|
|
221
|
+
|
|
222
|
+
export default function ChatPage() {
|
|
223
|
+
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
224
|
+
}
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Next.js (Pages Router)
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
import { AIChat } from "@yourusername/ai-chat";
|
|
231
|
+
import "@yourusername/ai-chat/styles";
|
|
232
|
+
|
|
233
|
+
export default function ChatPage() {
|
|
234
|
+
return <AIChat apiUrl={process.env.NEXT_PUBLIC_API_URL!} />;
|
|
235
|
+
}
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Vite + React
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
import { AIChat } from "@yourusername/ai-chat";
|
|
242
|
+
import "@yourusername/ai-chat/styles";
|
|
243
|
+
|
|
244
|
+
function App() {
|
|
245
|
+
return <AIChat apiUrl={import.meta.env.VITE_API_URL} />;
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Create React App
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
import { AIChat } from "@yourusername/ai-chat";
|
|
253
|
+
import "@yourusername/ai-chat/styles";
|
|
254
|
+
|
|
255
|
+
function App() {
|
|
256
|
+
return <AIChat apiUrl={process.env.REACT_APP_API_URL} />;
|
|
257
|
+
}
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
## Examples
|
|
261
|
+
|
|
262
|
+
Check out the [examples directory](./examples) for complete working examples with:
|
|
263
|
+
- Next.js App Router
|
|
264
|
+
- Vite + React
|
|
265
|
+
- Custom styling
|
|
266
|
+
- Advanced features
|
|
267
|
+
|
|
268
|
+
## Browser Support
|
|
269
|
+
|
|
270
|
+
- Chrome/Edge (latest)
|
|
271
|
+
- Firefox (latest)
|
|
272
|
+
- Safari 14+
|
|
273
|
+
- Mobile browsers (iOS Safari, Chrome Android)
|
|
274
|
+
|
|
275
|
+
## Contributing
|
|
276
|
+
|
|
277
|
+
Contributions are welcome! Please read our [contributing guidelines](CONTRIBUTING.md) first.
|
|
278
|
+
|
|
279
|
+
## License
|
|
280
|
+
|
|
281
|
+
MIT © [Your Name]
|
|
282
|
+
|
|
283
|
+
## Related
|
|
284
|
+
|
|
285
|
+
- [Radix UI](https://radix-ui.com/) - Accessible component primitives
|
|
286
|
+
- [Tailwind CSS](https://tailwindcss.com/) - Utility-first CSS framework
|
|
287
|
+
- [shadcn/ui](https://ui.shadcn.com/) - Re-usable components built with Radix UI
|
|
288
|
+
|
|
289
|
+
## Support
|
|
290
|
+
|
|
291
|
+
- 📖 [Documentation](https://github.com/yourusername/ai-chat#readme)
|
|
292
|
+
- 🐛 [Issue Tracker](https://github.com/yourusername/ai-chat/issues)
|
|
293
|
+
- 💬 [Discussions](https://github.com/yourusername/ai-chat/discussions)
|