@han_zzpw/chatbot 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 (40) hide show
  1. package/README.md +154 -0
  2. package/dist/chat-library.es.js +25120 -0
  3. package/dist/chat-library.umd.js +41 -0
  4. package/dist/components/ChatBot.d.ts +7 -0
  5. package/dist/components/ChatInput.d.ts +17 -0
  6. package/dist/components/ChatStreaming.d.ts +8 -0
  7. package/dist/components/ChatTyping.d.ts +1 -0
  8. package/dist/components/Icons/CameraIcon.d.ts +6 -0
  9. package/dist/components/Icons/CancelIcon.d.ts +7 -0
  10. package/dist/components/Icons/CheckIcon.d.ts +7 -0
  11. package/dist/components/Icons/CloseIcon.d.ts +7 -0
  12. package/dist/components/Icons/ImageUploadIcon.d.ts +1 -0
  13. package/dist/components/Icons/LeftArrowIcon.d.ts +6 -0
  14. package/dist/components/Icons/RightArrowIcon.d.ts +6 -0
  15. package/dist/components/Icons/SendIcon.d.ts +7 -0
  16. package/dist/components/Icons/ShoppingIcon.d.ts +6 -0
  17. package/dist/components/Icons/SpinnerIcon.d.ts +6 -0
  18. package/dist/components/Icons/TrashIcon.d.ts +6 -0
  19. package/dist/components/Icons/UploadIcon.d.ts +6 -0
  20. package/dist/components/Icons/VoiceIcon.d.ts +6 -0
  21. package/dist/components/MessageBubble.d.ts +11 -0
  22. package/dist/components/ThinkingBlock.d.ts +6 -0
  23. package/dist/components/ToolBlock/ExpandableHeader.d.ts +8 -0
  24. package/dist/components/ToolBlock/ImageGrid.d.ts +16 -0
  25. package/dist/components/ToolBlock/ImageTool.d.ts +13 -0
  26. package/dist/components/ToolBlock/ProcessingSpinner.d.ts +6 -0
  27. package/dist/components/ToolBlock/index.d.ts +4 -0
  28. package/dist/components/ToolBlock.d.ts +9 -0
  29. package/dist/components/WavelensConfigModal.d.ts +12 -0
  30. package/dist/components/atoms/ImageModal.d.ts +9 -0
  31. package/dist/components/atoms/InputUnderline.d.ts +5 -0
  32. package/dist/components/atoms/LoadingSpinner.d.ts +1 -0
  33. package/dist/components/atoms/MultimediaInput.d.ts +10 -0
  34. package/dist/components/atoms/TextInput.d.ts +10 -0
  35. package/dist/hooks/useSpeechRecognition.d.ts +11 -0
  36. package/dist/index.d.ts +15 -0
  37. package/dist/types/index.d.ts +97 -0
  38. package/dist/utils/api-helper.d.ts +2 -0
  39. package/dist/utils/stream-parser.d.ts +8 -0
  40. package/package.json +57 -0
package/README.md ADDED
@@ -0,0 +1,154 @@
1
+ # VDM Chatbot Library
2
+
3
+ A standalone React chatbot component library with streaming support, speech recognition, and markdown rendering. Designed for easy integration into any React application.
4
+
5
+ ## Features
6
+
7
+ - 🗣️ **Real-time Streaming**: Support for streaming responses with real-time updates
8
+ - 🤖 **AI-Powered**: Built for integration with AI chat services
9
+ - 📱 **Responsive Design**: Works seamlessly on desktop and mobile devices
10
+ - 🎨 **Customizable UI**: Easily customizable with Tailwind CSS
11
+ - 🔧 **Extensible Components**: Modular components for flexible customization
12
+ - 📝 **Markdown Rendering**: Rich text display with markdown support
13
+ - 🎤 **Speech Recognition**: Voice input support (via hooks)
14
+ - 🧠 **Thinking Blocks**: Visual representation of AI thought processes
15
+ - 🔧 **Tool Integration**: Support for external tools and device integration
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ npm install @vdm/chatbot
21
+ ```
22
+
23
+ ## Basic Usage
24
+
25
+ ```jsx
26
+ import React from 'react';
27
+ import { ChatBot } from '@vdm/chatbot';
28
+
29
+ const MyApp = () => {
30
+ return (
31
+ <div style={{ height: '600px', width: '400px' }}>
32
+ <ChatBot
33
+ token="your-api-token-here"
34
+ title="My Chat Assistant"
35
+ className="bg-white"
36
+ />
37
+ </div>
38
+ );
39
+ };
40
+
41
+ export default MyApp;
42
+ ```
43
+
44
+ ## Props
45
+
46
+ | Prop | Type | Required | Description |
47
+ |------|------|----------|-------------|
48
+ | `token` | `string` | Yes | API authentication token |
49
+ | `title` | `string` | No | Chatbot title displayed at the top |
50
+ | `className` | `string` | No | Additional CSS classes for custom styling |
51
+ | `apiEndpoint` | `string` | No | API endpoint (for backward compatibility) |
52
+ | `headers` | `Record<string, string>` | No | Additional headers to include in API requests |
53
+ | `toolApiBaseUrl` | `string` | No | Base URL for tool integrations |
54
+
55
+ ## Advanced Usage
56
+
57
+ ### With Custom Headers
58
+
59
+ ```jsx
60
+ <ChatBot
61
+ token="your-api-token"
62
+ headers={{
63
+ 'X-Custom-Header': 'custom-value',
64
+ 'Authorization': 'Bearer custom-auth'
65
+ }}
66
+ />
67
+ ```
68
+
69
+ ### Embedded Mode (iframe)
70
+
71
+ The library supports embedding via postMessage for secure token passing:
72
+
73
+ ```html
74
+ <iframe
75
+ src="path-to-embedded-chat"
76
+ width="400"
77
+ height="600"
78
+ onload="this.contentWindow.postMessage({type: 'SET_TOKEN', token: 'your-token'}, '*')"
79
+ />
80
+ ```
81
+
82
+ ## Components
83
+
84
+ The library exports several components for flexible usage:
85
+
86
+ - `ChatBot` - Main chatbot component
87
+ - `ChatInput` - Input component with file upload support
88
+ - `MessageBubble` - Individual message display components
89
+ - `ChatStreaming` - Streaming response visualization
90
+ - `ChatTyping` - Typing indicator
91
+ - `ThinkingBlock` - AI thinking visualization
92
+ - `ToolBlock` - Tool execution visualization
93
+ - `WavelensConfigModal` - Configuration modal for advanced features
94
+
95
+ ## Hooks
96
+
97
+ - `useSpeechRecognition` - Hook for speech-to-text functionality
98
+
99
+ ## Utilities
100
+
101
+ - `stream-parser` - Utility for parsing streaming API responses
102
+
103
+ ## Types
104
+
105
+ The library includes comprehensive TypeScript definitions:
106
+
107
+ - `ChatConfig` - Configuration interface
108
+ - `Question` - Question message type
109
+ - `Answer` - Answer message type
110
+ - `StreamingEvent` - Event types for streaming
111
+ - `Device` - Device integration types
112
+
113
+ ## Development
114
+
115
+ ### Prerequisites
116
+
117
+ - Node.js >= 18.0.0
118
+ - npm or yarn
119
+
120
+ ### Setup
121
+
122
+ ```bash
123
+ # Clone and install dependencies
124
+ npm install
125
+
126
+ # Start development server
127
+ npm run dev
128
+
129
+ # Build for production
130
+ npm run build
131
+ ```
132
+
133
+ ### Project Structure
134
+
135
+ ```
136
+ components/ # React components
137
+ hooks/ # React hooks
138
+ types/ # TypeScript definitions
139
+ utils/ # Utility functions
140
+ index.ts # Main entry point
141
+ embedApp.tsx # Embedded app entry point
142
+ ```
143
+
144
+ ## Contributing
145
+
146
+ 1. Fork the repository
147
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
148
+ 3. Commit your changes (`git commit -m 'Add amazing feature'`)
149
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
150
+ 5. Open a Pull Request
151
+
152
+ ## License
153
+
154
+ MIT © VDM