flowdit-chatbot-library 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.
- package/LICENSE +21 -0
- package/README.md +218 -0
- package/dist/assets/data/types/index.d.ts +2 -0
- package/dist/assets/data/types/index.d.ts.map +1 -0
- package/dist/assets/data/types/index.js +2 -0
- package/dist/assets/data/types/index.js.map +1 -0
- package/dist/assets/data/types/redux/action.d.ts +8 -0
- package/dist/assets/data/types/redux/action.d.ts.map +1 -0
- package/dist/assets/data/types/redux/action.js +9 -0
- package/dist/assets/data/types/redux/action.js.map +1 -0
- package/dist/assets/data/types/redux/index.d.ts +2 -0
- package/dist/assets/data/types/redux/index.d.ts.map +1 -0
- package/dist/assets/data/types/redux/index.js +2 -0
- package/dist/assets/data/types/redux/index.js.map +1 -0
- package/dist/assets/data/types/vm/chatbot.d.ts +5 -0
- package/dist/assets/data/types/vm/chatbot.d.ts.map +1 -0
- package/dist/assets/data/types/vm/chatbot.js +8 -0
- package/dist/assets/data/types/vm/chatbot.js.map +1 -0
- package/dist/assets/data/types/vm/index.d.ts +2 -0
- package/dist/assets/data/types/vm/index.d.ts.map +1 -0
- package/dist/assets/data/types/vm/index.js +2 -0
- package/dist/assets/data/types/vm/index.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/redux/Provider.d.ts +11 -0
- package/dist/redux/Provider.d.ts.map +1 -0
- package/dist/redux/Provider.js +12 -0
- package/dist/redux/Provider.js.map +1 -0
- package/dist/redux/actions/index.d.ts +8 -0
- package/dist/redux/actions/index.d.ts.map +1 -0
- package/dist/redux/actions/index.js +73 -0
- package/dist/redux/actions/index.js.map +1 -0
- package/dist/redux/hooks.d.ts +6 -0
- package/dist/redux/hooks.d.ts.map +1 -0
- package/dist/redux/hooks.js +27 -0
- package/dist/redux/hooks.js.map +1 -0
- package/dist/redux/reducers/actions/general.d.ts +7 -0
- package/dist/redux/reducers/actions/general.d.ts.map +1 -0
- package/dist/redux/reducers/actions/general.js +16 -0
- package/dist/redux/reducers/actions/general.js.map +1 -0
- package/dist/redux/reducers/actions/index.d.ts +5 -0
- package/dist/redux/reducers/actions/index.d.ts.map +1 -0
- package/dist/redux/reducers/actions/index.js +8 -0
- package/dist/redux/reducers/actions/index.js.map +1 -0
- package/dist/redux/reducers/index.d.ts +4 -0
- package/dist/redux/reducers/index.d.ts.map +1 -0
- package/dist/redux/reducers/index.js +15 -0
- package/dist/redux/reducers/index.js.map +1 -0
- package/dist/redux/store.d.ts +11 -0
- package/dist/redux/store.d.ts.map +1 -0
- package/dist/redux/store.js +20 -0
- package/dist/redux/store.js.map +1 -0
- package/dist/styles.css +434 -0
- package/dist/utilities/API.d.ts +17 -0
- package/dist/utilities/API.d.ts.map +1 -0
- package/dist/utilities/API.js +71 -0
- package/dist/utilities/API.js.map +1 -0
- package/dist/utilities/external-tools.d.ts +19 -0
- package/dist/utilities/external-tools.d.ts.map +1 -0
- package/dist/utilities/external-tools.js +27 -0
- package/dist/utilities/external-tools.js.map +1 -0
- package/dist/views/fullscreen/index.d.ts +20 -0
- package/dist/views/fullscreen/index.d.ts.map +1 -0
- package/dist/views/fullscreen/index.functions.d.ts +38 -0
- package/dist/views/fullscreen/index.functions.d.ts.map +1 -0
- package/dist/views/fullscreen/index.functions.js +484 -0
- package/dist/views/fullscreen/index.functions.js.map +1 -0
- package/dist/views/fullscreen/index.js +569 -0
- package/dist/views/fullscreen/index.js.map +1 -0
- package/dist/views/tools/ChecklistPreview.d.ts +4 -0
- package/dist/views/tools/ChecklistPreview.d.ts.map +1 -0
- package/dist/views/tools/ChecklistPreview.js +29 -0
- package/dist/views/tools/ChecklistPreview.js.map +1 -0
- package/dist/views/tools/index.d.ts +6 -0
- package/dist/views/tools/index.d.ts.map +1 -0
- package/dist/views/tools/index.js +8 -0
- package/dist/views/tools/index.js.map +1 -0
- package/package.json +74 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Ibaa Ibrahim
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
# @flowdit/chatbot-library
|
|
2
|
+
|
|
3
|
+
A React chatbot library with streaming support, tool integration, and modern UI. Built with TypeScript, Redux, and React.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Streaming Support**: Real-time streaming responses with character-by-character animation
|
|
8
|
+
- 🎨 **Modern UI**: ChatGPT-like interface with dark theme
|
|
9
|
+
- 🔧 **Tool Integration**: Support for custom tool handlers (checklists, translations, etc.)
|
|
10
|
+
- 📦 **TypeScript**: Fully typed for better developer experience
|
|
11
|
+
- 🔄 **Self-Contained Redux**: Uses its own internal Redux store - no setup required!
|
|
12
|
+
- 🎯 **Flexible**: Easy to customize and extend
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @flowdit/chatbot-library
|
|
18
|
+
# or
|
|
19
|
+
yarn add @flowdit/chatbot-library
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Peer Dependencies
|
|
23
|
+
|
|
24
|
+
This library requires the following peer dependencies:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install react react-dom react-redux redux reactstrap react-markdown axios lodash
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Quick Start
|
|
31
|
+
|
|
32
|
+
### 1. Import Styles
|
|
33
|
+
|
|
34
|
+
First, import the CSS styles in your application:
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
import '@flowdit/chatbot-library/dist/styles.css'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### 2. Initialize API
|
|
41
|
+
|
|
42
|
+
Configure the API connection before using the chatbot:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import { initializeAPI } from '@flowdit/chatbot-library'
|
|
46
|
+
|
|
47
|
+
// Initialize API
|
|
48
|
+
initializeAPI({
|
|
49
|
+
baseURL: 'https://your-api-url.com',
|
|
50
|
+
token: 'your-auth-token', // Optional
|
|
51
|
+
timeout: 300000 // 5 minutes
|
|
52
|
+
})
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Use the Chatbot Component
|
|
56
|
+
|
|
57
|
+
The library uses its own internal Redux store, so no setup is needed! Just use the component:
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
import React from 'react'
|
|
61
|
+
import { FullScreenChat } from '@flowdit/chatbot-library'
|
|
62
|
+
|
|
63
|
+
function App() {
|
|
64
|
+
return (
|
|
65
|
+
<div>
|
|
66
|
+
<FullScreenChat />
|
|
67
|
+
</div>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Components
|
|
73
|
+
|
|
74
|
+
### FullScreenChat
|
|
75
|
+
|
|
76
|
+
The main chat interface component (used inside ChatModal).
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
import { FullScreenChat } from '@flowdit/chatbot-library'
|
|
80
|
+
|
|
81
|
+
<FullScreenChat />
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Configuration
|
|
85
|
+
|
|
86
|
+
### API Configuration
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { initializeAPI } from '@flowdit/chatbot-library'
|
|
90
|
+
|
|
91
|
+
initializeAPI({
|
|
92
|
+
baseURL: 'https://api.example.com',
|
|
93
|
+
token: 'your-token',
|
|
94
|
+
timeout: 300000,
|
|
95
|
+
headers: {
|
|
96
|
+
'Custom-Header': 'value'
|
|
97
|
+
},
|
|
98
|
+
withCredentials: false
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Environment Variables
|
|
103
|
+
|
|
104
|
+
You can also use environment variables:
|
|
105
|
+
|
|
106
|
+
- `REACT_APP_CHAT_AI_ASSISTANT_API_URL` - API base URL
|
|
107
|
+
- `REACT_APP_CHAT_AI_TOKEN` - Authentication token
|
|
108
|
+
- `NEXT_PUBLIC_CHAT_AI_ASSISTANT_API_URL` - For Next.js applications
|
|
109
|
+
|
|
110
|
+
## Using the Internal Redux Store
|
|
111
|
+
|
|
112
|
+
The library uses its own internal Redux store, so you don't need to set up Redux in your app. However, you can still access and control the chatbot state using the provided hooks:
|
|
113
|
+
|
|
114
|
+
### Using Hooks (Recommended)
|
|
115
|
+
|
|
116
|
+
```tsx
|
|
117
|
+
import { useChatbotModal, useChatbotChecklist } from '@flowdit/chatbot-library'
|
|
118
|
+
|
|
119
|
+
function MyComponent() {
|
|
120
|
+
const { isOpen, open, close } = useChatbotModal()
|
|
121
|
+
const { isPreviewModalOpen, data } = useChatbotChecklist()
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<div>
|
|
125
|
+
<button onClick={open}>Open Chat</button>
|
|
126
|
+
<button onClick={close}>Close Chat</button>
|
|
127
|
+
{isOpen && <p>Chat is open!</p>}
|
|
128
|
+
</div>
|
|
129
|
+
)
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Direct Store Access (Advanced)
|
|
134
|
+
|
|
135
|
+
If you need direct access to the store:
|
|
136
|
+
|
|
137
|
+
```tsx
|
|
138
|
+
import { getStore, CHATBOT_STORE_ACTION_TYPES } from '@flowdit/chatbot-library'
|
|
139
|
+
|
|
140
|
+
const store = getStore()
|
|
141
|
+
|
|
142
|
+
// Dispatch actions
|
|
143
|
+
store.dispatch({ type: CHATBOT_STORE_ACTION_TYPES.OPEN_AI_MODAL })
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Available Hooks
|
|
147
|
+
|
|
148
|
+
- `useChatbotModal()` - Control the chat modal (open/close)
|
|
149
|
+
- `useChatbotState()` - Get the entire chatbot state
|
|
150
|
+
- `useChatbotSelector()` - Custom selector hook
|
|
151
|
+
- `useChatbotDispatch()` - Dispatch hook
|
|
152
|
+
|
|
153
|
+
## Types
|
|
154
|
+
|
|
155
|
+
The library exports TypeScript types for better type safety:
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
import type {
|
|
159
|
+
ChatbotStore,
|
|
160
|
+
ChatMessage,
|
|
161
|
+
ToolCall,
|
|
162
|
+
ChatbotAPIConfig
|
|
163
|
+
} from '@flowdit/chatbot-library'
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Custom Tool Handlers
|
|
167
|
+
|
|
168
|
+
You can customize tool handlers by modifying the `TOOL_HANDLERS` object in the `FullScreenChat` component or by providing your own implementation.
|
|
169
|
+
|
|
170
|
+
Example tool handler:
|
|
171
|
+
|
|
172
|
+
```tsx
|
|
173
|
+
const TOOL_HANDLERS = {
|
|
174
|
+
generate_checklist: (data) => {
|
|
175
|
+
// Your custom logic
|
|
176
|
+
console.log('Generate checklist:', data)
|
|
177
|
+
},
|
|
178
|
+
translate_text: (data) => {
|
|
179
|
+
// Your custom logic
|
|
180
|
+
console.log('Translate text:', data)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Building
|
|
186
|
+
|
|
187
|
+
To build the library:
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
npm run build
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
This will:
|
|
194
|
+
- Compile TypeScript to CommonJS and ES modules
|
|
195
|
+
- Compile SCSS to CSS
|
|
196
|
+
- Generate type definitions
|
|
197
|
+
|
|
198
|
+
## Development
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Install dependencies
|
|
202
|
+
npm install
|
|
203
|
+
|
|
204
|
+
# Build
|
|
205
|
+
npm run build
|
|
206
|
+
|
|
207
|
+
# Watch mode
|
|
208
|
+
npm run watch
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## License
|
|
212
|
+
|
|
213
|
+
MIT
|
|
214
|
+
|
|
215
|
+
## Contributing
|
|
216
|
+
|
|
217
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
218
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../assets/data/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../assets/data/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,MAAM,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.d.ts","sourceRoot":"","sources":["../../../../../assets/data/types/redux/action.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAG/D,cAAM,WAAW;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,GAAG,CAAC;gBAEF,IAAI,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,GAAG;CAI5C;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../../../../assets/data/types/redux/action.ts"],"names":[],"mappings":"AAEA,0BAA0B;AAC1B,MAAM,WAAW;IAIf,YAAY,IAAgB,EAAE,OAAa;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CACF;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../assets/data/types/redux/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../assets/data/types/redux/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatbot.d.ts","sourceRoot":"","sources":["../../../../../assets/data/types/vm/chatbot.ts"],"names":[],"mappings":"AAGA,cAAM,YAAY;gBAGJ,IAAI,GAAE,OAAO,CAAC,YAAY,CAAM;CAG7C;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chatbot.js","sourceRoot":"","sources":["../../../../../assets/data/types/vm/chatbot.ts"],"names":[],"mappings":"AAAA,4DAA4D;AAC5D,8DAA8D;AAE9D,MAAM,YAAY;IAGhB,YAAY,OAA8B,EAAE;IAE5C,CAAC;CACF;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../assets/data/types/vm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../assets/data/types/vm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { FullScreenChat } from './views/fullscreen';
|
|
2
|
+
export { default as ChatbotToolsWrapper } from './views/tools';
|
|
3
|
+
export { ChatbotProvider } from './redux/Provider';
|
|
4
|
+
export { useChatbotDispatch, useChatbotSelector, useChatbotState } from './redux/hooks';
|
|
5
|
+
export { getStore, resetStore } from './redux/store';
|
|
6
|
+
export { chatbotReducer } from './redux/reducers';
|
|
7
|
+
export { CHATBOT_STORE_ACTION_TYPES } from './redux/reducers/actions';
|
|
8
|
+
export { _sendMessage, _connectWithStreaming } from './redux/actions';
|
|
9
|
+
export type { ChatbotStore } from './assets/data/types/vm';
|
|
10
|
+
export type { ActionStore } from './assets/data/types/redux';
|
|
11
|
+
export type { ChatMessage, ToolCall } from './views/fullscreen';
|
|
12
|
+
export { API, initializeAPI, type ChatbotAPIConfig } from './utilities/API';
|
|
13
|
+
export { setStore, openChecklistPreview, type ToolHandler, type ToolData } from './utilities/external-tools';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAG9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAGlD,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAA;AAGtB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAGpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAGrE,YAAY,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAC1D,YAAY,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAA;AAC5D,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAG/D,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,4BAA4B,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Main entry point for the Chatbot Library
|
|
2
|
+
// Components
|
|
3
|
+
export { FullScreenChat } from './views/fullscreen';
|
|
4
|
+
export { default as ChatbotToolsWrapper } from './views/tools';
|
|
5
|
+
// Redux Provider (wraps components with internal store)
|
|
6
|
+
export { ChatbotProvider } from './redux/Provider';
|
|
7
|
+
// Redux Hooks (for accessing internal store)
|
|
8
|
+
export { useChatbotDispatch, useChatbotSelector, useChatbotState } from './redux/hooks';
|
|
9
|
+
// Redux Store (for advanced usage)
|
|
10
|
+
export { getStore, resetStore } from './redux/store';
|
|
11
|
+
// Redux (for backward compatibility or advanced usage)
|
|
12
|
+
export { chatbotReducer } from './redux/reducers';
|
|
13
|
+
export { CHATBOT_STORE_ACTION_TYPES } from './redux/reducers/actions';
|
|
14
|
+
export { _sendMessage, _connectWithStreaming } from './redux/actions';
|
|
15
|
+
// Utilities
|
|
16
|
+
export { API, initializeAPI } from './utilities/API';
|
|
17
|
+
export { setStore, openChecklistPreview } from './utilities/external-tools';
|
|
18
|
+
// Styles - users should import this in their application
|
|
19
|
+
// import '@flowdit/chatbot-library/dist/styles.css'
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAE3C,aAAa;AACb,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AACnD,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAE9D,wDAAwD;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAElD,6CAA6C;AAC7C,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EAChB,MAAM,eAAe,CAAA;AAEtB,mCAAmC;AACnC,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAEpD,uDAAuD;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAOrE,YAAY;AACZ,OAAO,EAAE,GAAG,EAAE,aAAa,EAAyB,MAAM,iBAAiB,CAAA;AAC3E,OAAO,EAAE,QAAQ,EAAE,oBAAoB,EAAmC,MAAM,4BAA4B,CAAA;AAE5G,yDAAyD;AACzD,oDAAoD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface ChatbotProviderProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* ChatbotProvider wraps the chatbot components with its own Redux store
|
|
7
|
+
* This makes the library self-contained and doesn't require the parent app to set up Redux
|
|
8
|
+
*/
|
|
9
|
+
export declare const ChatbotProvider: React.FC<ChatbotProviderProps>;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../redux/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAIzB,UAAU,oBAAoB;IAC5B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAC1B;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,oBAAoB,CAQ1D,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Provider as ReduxProvider } from 'react-redux';
|
|
3
|
+
import { getStore } from './store';
|
|
4
|
+
/**
|
|
5
|
+
* ChatbotProvider wraps the chatbot components with its own Redux store
|
|
6
|
+
* This makes the library self-contained and doesn't require the parent app to set up Redux
|
|
7
|
+
*/
|
|
8
|
+
export const ChatbotProvider = ({ children }) => {
|
|
9
|
+
const store = getStore();
|
|
10
|
+
return (React.createElement(ReduxProvider, { store: store }, children));
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=Provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../redux/Provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAMlC;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAmC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC9E,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAA;IAExB,OAAO,CACL,oBAAC,aAAa,IAAC,KAAK,EAAE,KAAK,IACxB,QAAQ,CACK,CACjB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const _connectWithStreaming: (job_id: string, signal: AbortSignal, lastEventId?: number | null) => Promise<Response>;
|
|
2
|
+
export declare const _sendMessage: (message: string, conversation_id: string) => Promise<{
|
|
3
|
+
data: {
|
|
4
|
+
job_id: string;
|
|
5
|
+
status: string;
|
|
6
|
+
};
|
|
7
|
+
}>;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../redux/actions/index.ts"],"names":[],"mappings":"AAkDA,eAAO,MAAM,qBAAqB,GAAU,QAAQ,MAAM,EAAE,QAAQ,WAAW,EAAE,cAAc,MAAM,GAAG,IAAI,sBAuB3G,CAAA;AAED,eAAO,MAAM,YAAY,GAAU,SAAS,MAAM,EAAE,iBAAiB,MAAM;UAElD;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE;EAU1D,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
import { getAPI } from "../../utilities/API";
|
|
3
|
+
const buildChatStreamUrl = (job_id) => {
|
|
4
|
+
const API = getAPI();
|
|
5
|
+
const base = API.defaults.baseURL ?? "";
|
|
6
|
+
const normalizedBase = base.replace(/\/$/, "");
|
|
7
|
+
return `${normalizedBase || ""}/v1/jobs/${job_id}/events`;
|
|
8
|
+
};
|
|
9
|
+
const buildHeaders = () => {
|
|
10
|
+
const API = getAPI();
|
|
11
|
+
const defaults = API.defaults.headers || {};
|
|
12
|
+
const common = defaults.common || {};
|
|
13
|
+
const post = defaults.post || {};
|
|
14
|
+
// Flatten headers that axios keeps under method-specific keys
|
|
15
|
+
// Filter out undefined values and convert to strings
|
|
16
|
+
const flattened = {};
|
|
17
|
+
Object.entries(common).forEach(([key, value]) => {
|
|
18
|
+
if (value !== undefined && value !== null) {
|
|
19
|
+
flattened[key] = String(value);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
Object.entries(post).forEach(([key, value]) => {
|
|
23
|
+
if (value !== undefined && value !== null) {
|
|
24
|
+
flattened[key] = String(value);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
// Pull over any custom top-level headers (ignoring axios's method buckets)
|
|
28
|
+
const methodBuckets = new Set(['common', 'delete', 'get', 'head', 'post', 'put', 'patch']);
|
|
29
|
+
Object.entries(defaults).forEach(([key, value]) => {
|
|
30
|
+
if (!methodBuckets.has(key) && typeof value === "string") {
|
|
31
|
+
flattened[key] = value;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
// Ensure we control the content type for JSON payloads
|
|
35
|
+
delete flattened['Content-Type'];
|
|
36
|
+
return {
|
|
37
|
+
...flattened,
|
|
38
|
+
Accept: "text/event-stream",
|
|
39
|
+
"Content-Type": "application/json"
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
export const _connectWithStreaming = async (job_id, signal, lastEventId) => {
|
|
43
|
+
const headers = buildHeaders();
|
|
44
|
+
// Add Last-Event-ID header for reconnection support
|
|
45
|
+
if (lastEventId !== undefined && lastEventId !== null) {
|
|
46
|
+
headers["Last-Event-ID"] = lastEventId.toString();
|
|
47
|
+
}
|
|
48
|
+
const response = await fetch(buildChatStreamUrl(job_id), {
|
|
49
|
+
method: "GET",
|
|
50
|
+
headers,
|
|
51
|
+
signal
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
throw new Error(`Chat stream failed with status ${response.status}`);
|
|
55
|
+
}
|
|
56
|
+
if (!response.body) {
|
|
57
|
+
throw new Error("Readable stream not supported in this environment");
|
|
58
|
+
}
|
|
59
|
+
return response;
|
|
60
|
+
};
|
|
61
|
+
export const _sendMessage = async (message, conversation_id) => {
|
|
62
|
+
const API = getAPI();
|
|
63
|
+
const response = await API.post(`/v1/jobs`, {
|
|
64
|
+
user_message: message,
|
|
65
|
+
conversation_id
|
|
66
|
+
}, {
|
|
67
|
+
headers: {
|
|
68
|
+
"Idempotency-Key": uuidv4()
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return response;
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../redux/actions/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TypedUseSelectorHook } from 'react-redux';
|
|
2
|
+
import { ChatbotStore } from '../assets/data/types/vm';
|
|
3
|
+
export declare const useChatbotDispatch: () => import("redux").Dispatch<import("redux").AnyAction>;
|
|
4
|
+
export declare const useChatbotSelector: TypedUseSelectorHook<ChatbotStore>;
|
|
5
|
+
export declare const useChatbotState: () => ChatbotStore;
|
|
6
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../redux/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA4B,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAKtD,eAAO,MAAM,kBAAkB,2DAAsB,CAAA;AACrD,eAAO,MAAM,kBAAkB,EAAE,oBAAoB,CAAC,YAAY,CAAe,CAAA;AAGjF,eAAO,MAAM,eAAe,oBAE3B,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { useSelector, useDispatch } from 'react-redux';
|
|
2
|
+
// Type the hooks to use our internal store
|
|
3
|
+
export const useChatbotDispatch = () => useDispatch();
|
|
4
|
+
export const useChatbotSelector = useSelector;
|
|
5
|
+
// Convenience hooks for common state access
|
|
6
|
+
export const useChatbotState = () => {
|
|
7
|
+
return useChatbotSelector((state) => state);
|
|
8
|
+
};
|
|
9
|
+
// export const useChatbotModal = () => {
|
|
10
|
+
// const isOpen = useChatbotSelector((state) => state.aiModalOpen)
|
|
11
|
+
// const dispatch = useChatbotDispatch()
|
|
12
|
+
// return {
|
|
13
|
+
// isOpen,
|
|
14
|
+
// open: () => dispatch({ type: CHATBOT_STORE_ACTION_TYPES.OPEN_AI_MODAL } as ActionStore),
|
|
15
|
+
// close: () => dispatch({ type: CHATBOT_STORE_ACTION_TYPES.CLOSE_AI_MODAL } as ActionStore),
|
|
16
|
+
// }
|
|
17
|
+
// }
|
|
18
|
+
// export const useChatbotChecklist = () => {
|
|
19
|
+
// const checklist = useChatbotSelector((state) => state.checklist)
|
|
20
|
+
// const dispatch = useChatbotDispatch()
|
|
21
|
+
// return {
|
|
22
|
+
// ...checklist,
|
|
23
|
+
// openPreview: (data: any) => dispatch({ type: CHATBOT_STORE_ACTION_TYPES.OPEN_PREVIEW_MODAL, payload: data } as ActionStore),
|
|
24
|
+
// closePreview: () => dispatch({ type: CHATBOT_STORE_ACTION_TYPES.CLOSE_PREVIEW_MODAL } as ActionStore),
|
|
25
|
+
// }
|
|
26
|
+
// }
|
|
27
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../redux/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAwB,MAAM,aAAa,CAAA;AAK5E,2CAA2C;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,WAAW,EAAE,CAAA;AACrD,MAAM,CAAC,MAAM,kBAAkB,GAAuC,WAAW,CAAA;AAEjF,4CAA4C;AAC5C,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,EAAE;IAClC,OAAO,kBAAkB,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,CAAA;AAC7C,CAAC,CAAA;AAED,yCAAyC;AACzC,oEAAoE;AACpE,0CAA0C;AAE1C,aAAa;AACb,cAAc;AACd,+FAA+F;AAC/F,iGAAiG;AACjG,MAAM;AACN,IAAI;AAEJ,6CAA6C;AAC7C,qEAAqE;AACrE,0CAA0C;AAE1C,aAAa;AACb,oBAAoB;AACpB,mIAAmI;AACnI,6GAA6G;AAC7G,MAAM;AACN,IAAI"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const ChatbotGeneralCases: {};
|
|
2
|
+
export type ChatbotGeneralActionType = keyof typeof ChatbotGeneralCases;
|
|
3
|
+
export declare const CHATBOT_GENERAL_ACTION_TYPES: {
|
|
4
|
+
[K in ChatbotGeneralActionType]: K;
|
|
5
|
+
};
|
|
6
|
+
export type ChatbotGeneralActionHandler = typeof ChatbotGeneralCases[ChatbotGeneralActionType];
|
|
7
|
+
//# sourceMappingURL=general.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.d.ts","sourceRoot":"","sources":["../../../../redux/reducers/actions/general.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,mBAAmB,IAG/B,CAAA;AAED,MAAM,MAAM,wBAAwB,GAAG,MAAM,OAAO,mBAAmB,CAAA;AACvE,eAAO,MAAM,4BAA4B,EAAE;KAAG,CAAC,IAAI,wBAAwB,GAAG,CAAC;CAEpC,CAAA;AAE3C,MAAM,MAAM,2BAA2B,GAAG,OAAO,mBAAmB,CAAC,wBAAwB,CAAC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// export const handleOpenAiModal = (state: ChatbotStore, action: ActionStore): ChatbotStore => {
|
|
2
|
+
// const tempState = { ...state }
|
|
3
|
+
// tempState.aiModalOpen = true
|
|
4
|
+
// return tempState
|
|
5
|
+
// }
|
|
6
|
+
// export const handleCloseAiModal = (state: ChatbotStore, action: ActionStore): ChatbotStore => {
|
|
7
|
+
// const tempState = { ...state }
|
|
8
|
+
// tempState.aiModalOpen = false
|
|
9
|
+
// return tempState
|
|
10
|
+
// }
|
|
11
|
+
export const ChatbotGeneralCases = {
|
|
12
|
+
// OPEN_AI_MODAL: handleOpenAiModal,
|
|
13
|
+
// CLOSE_AI_MODAL: handleCloseAiModal
|
|
14
|
+
};
|
|
15
|
+
export const CHATBOT_GENERAL_ACTION_TYPES = Object.fromEntries(Object.keys(ChatbotGeneralCases).map((key) => [key, key]));
|
|
16
|
+
//# sourceMappingURL=general.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../../../redux/reducers/actions/general.ts"],"names":[],"mappings":"AAGA,iGAAiG;AACjG,mCAAmC;AACnC,iCAAiC;AACjC,qBAAqB;AACrB,IAAI;AAEJ,kGAAkG;AAClG,mCAAmC;AACnC,kCAAkC;AAClC,qBAAqB;AACrB,IAAI;AAEJ,MAAM,CAAC,MAAM,mBAAmB,GAAG;AACjC,oCAAoC;AACpC,qCAAqC;CACtC,CAAA;AAGD,MAAM,CAAC,MAAM,4BAA4B,GAA2C,MAAM,CAAC,WAAW,CACpG,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAChB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../redux/reducers/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,wBAAwB,EAAuB,MAAM,WAAW,CAAA;AAEvG,eAAO,MAAM,KAAK,IAEjB,CAAA;AAED,eAAO,MAAM,0BAA0B,IAEtC,CAAA;AAED,MAAM,MAAM,UAAU,GAAG,wBAAwB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../redux/reducers/actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAA4B,mBAAmB,EAAE,MAAM,WAAW,CAAA;AAEvG,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,mBAAmB;CACvB,CAAA;AAED,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,GAAG,4BAA4B;CAChC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../redux/reducers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAErC,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AAQzD,eAAO,MAAM,cAAc,GAAI,OAAO,YAAY,YAAe,EAAE,QAAQ,aAAa,KAAG,YAU1F,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ChatbotStore } from '../../assets/data/types/vm';
|
|
2
|
+
import { cases } from './actions';
|
|
3
|
+
const initialState = new ChatbotStore();
|
|
4
|
+
export const chatbotReducer = (state = initialState, action) => {
|
|
5
|
+
// Type guard to check if action is ActionStore and has a valid type
|
|
6
|
+
if ('type' in action && typeof action.type === 'string' && action.type in cases) {
|
|
7
|
+
const handler = cases[action.type];
|
|
8
|
+
if (handler && typeof handler === 'function') {
|
|
9
|
+
// Convert through unknown first to avoid type mismatch
|
|
10
|
+
return handler(state, action);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
return state;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=index.js.map
|