cool-ai-chatbot 0.1.4 → 0.1.5
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 +129 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -17,8 +17,8 @@ npm install cool-ai-chatbot
|
|
|
17
17
|
## Quick Start
|
|
18
18
|
|
|
19
19
|
```tsx
|
|
20
|
-
import { ChatBot } from "
|
|
21
|
-
import "
|
|
20
|
+
import { ChatBot } from "cool-ai-chatbot";
|
|
21
|
+
import "cool-ai-chatbot/style.css";
|
|
22
22
|
|
|
23
23
|
function App() {
|
|
24
24
|
return (
|
|
@@ -35,6 +35,32 @@ export default App;
|
|
|
35
35
|
|
|
36
36
|
---
|
|
37
37
|
|
|
38
|
+
## How It Works
|
|
39
|
+
|
|
40
|
+
```txt
|
|
41
|
+
Visitor
|
|
42
|
+
↓
|
|
43
|
+
Cool AI Chatbot
|
|
44
|
+
↓
|
|
45
|
+
Your React Application
|
|
46
|
+
↓
|
|
47
|
+
Your Backend Endpoint
|
|
48
|
+
↓
|
|
49
|
+
Your AI Provider
|
|
50
|
+
↓
|
|
51
|
+
Response
|
|
52
|
+
↓
|
|
53
|
+
Visitor
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Cool AI Chatbot provides the chat interface.
|
|
57
|
+
|
|
58
|
+
Your backend provides the AI response.
|
|
59
|
+
|
|
60
|
+
This design allows you to use any AI provider without changing the widget.
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
38
64
|
## Features
|
|
39
65
|
|
|
40
66
|
* React + TypeScript support
|
|
@@ -68,8 +94,6 @@ A welcoming personality for information, navigation, and discovery.
|
|
|
68
94
|
|
|
69
95
|
## Adaptive Theme Example
|
|
70
96
|
|
|
71
|
-
Allow the chatbot to automatically blend with your website's appearance.
|
|
72
|
-
|
|
73
97
|
```tsx
|
|
74
98
|
<ChatBot
|
|
75
99
|
endpoint="/api/chat"
|
|
@@ -93,42 +117,118 @@ Allow the chatbot to automatically blend with your website's appearance.
|
|
|
93
117
|
|
|
94
118
|
## Styling
|
|
95
119
|
|
|
96
|
-
Don't forget to import the included stylesheet:
|
|
97
|
-
|
|
98
120
|
```tsx
|
|
99
|
-
import "
|
|
121
|
+
import "cool-ai-chatbot/style.css";
|
|
100
122
|
```
|
|
101
123
|
|
|
102
124
|
Without this import, the chatbot will render without its intended styling.
|
|
103
125
|
|
|
104
126
|
---
|
|
105
127
|
|
|
106
|
-
## Backend
|
|
128
|
+
## Backend Setup
|
|
107
129
|
|
|
108
|
-
This package
|
|
109
|
-
|
|
110
|
-
You must provide your own backend endpoint that securely communicates with your AI provider.
|
|
130
|
+
This package requires a backend endpoint.
|
|
111
131
|
|
|
112
132
|
Example:
|
|
113
133
|
|
|
114
|
-
```
|
|
115
|
-
/api/chat
|
|
134
|
+
```tsx
|
|
135
|
+
<ChatBot endpoint="/api/chat" />
|
|
116
136
|
```
|
|
117
137
|
|
|
118
138
|
Your backend should:
|
|
119
139
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
140
|
+
1. Receive the user's message.
|
|
141
|
+
2. Send the message to your AI provider.
|
|
142
|
+
3. Return the AI response.
|
|
143
|
+
4. Keep API keys secure.
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Environment Variables
|
|
148
|
+
|
|
149
|
+
Store AI credentials in your backend.
|
|
150
|
+
|
|
151
|
+
Examples:
|
|
152
|
+
|
|
153
|
+
```env
|
|
154
|
+
OPENAI_API_KEY=your_key_here
|
|
155
|
+
|
|
156
|
+
# Or
|
|
157
|
+
|
|
158
|
+
GEMINI_API_KEY=your_key_here
|
|
159
|
+
|
|
160
|
+
# Or
|
|
161
|
+
|
|
162
|
+
ANTHROPIC_API_KEY=your_key_here
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Never place API keys directly in React components or frontend code.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Example Backend (OpenAI)
|
|
170
|
+
|
|
171
|
+
This example uses OpenAI, but you may replace it with any AI provider.
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
import OpenAI from "openai";
|
|
175
|
+
import express from "express";
|
|
176
|
+
|
|
177
|
+
const app = express();
|
|
178
|
+
|
|
179
|
+
app.use(express.json());
|
|
180
|
+
|
|
181
|
+
const client = new OpenAI({
|
|
182
|
+
apiKey: process.env.OPENAI_API_KEY,
|
|
183
|
+
});
|
|
124
184
|
|
|
125
|
-
|
|
185
|
+
app.post("/api/chat", async (req, res) => {
|
|
186
|
+
const { message } = req.body;
|
|
187
|
+
|
|
188
|
+
const response = await client.responses.create({
|
|
189
|
+
model: "gpt-5.5",
|
|
190
|
+
input: message,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
res.json({
|
|
194
|
+
response: response.output_text,
|
|
195
|
+
});
|
|
196
|
+
});
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Example Response Format
|
|
202
|
+
|
|
203
|
+
Your endpoint should return:
|
|
204
|
+
|
|
205
|
+
```json
|
|
206
|
+
{
|
|
207
|
+
"response": "Hello! How can I help you today?"
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
As long as your backend returns this format, Cool AI Chatbot can work with virtually any AI provider.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Supported AI Providers
|
|
216
|
+
|
|
217
|
+
Examples include:
|
|
218
|
+
|
|
219
|
+
* OpenAI
|
|
220
|
+
* Google Gemini
|
|
221
|
+
* Anthropic Claude
|
|
222
|
+
* Ollama
|
|
223
|
+
* Azure OpenAI
|
|
224
|
+
* Local LLMs
|
|
225
|
+
* Custom AI services
|
|
126
226
|
|
|
127
227
|
---
|
|
128
228
|
|
|
129
229
|
## Status
|
|
130
230
|
|
|
131
|
-
Current Version: 0.1.
|
|
231
|
+
Current Version: 0.1.5
|
|
132
232
|
|
|
133
233
|
Cool AI Chatbot is actively under development.
|
|
134
234
|
|
|
@@ -140,6 +240,16 @@ Current focus areas include:
|
|
|
140
240
|
* Accessibility improvements
|
|
141
241
|
* Enhanced developer configuration
|
|
142
242
|
|
|
243
|
+
Future examples may include:
|
|
244
|
+
|
|
245
|
+
```txt
|
|
246
|
+
examples/
|
|
247
|
+
├── openai/
|
|
248
|
+
├── gemini/
|
|
249
|
+
├── claude/
|
|
250
|
+
└── ollama/
|
|
251
|
+
```
|
|
252
|
+
|
|
143
253
|
Breaking changes may occur during early releases as the package evolves.
|
|
144
254
|
|
|
145
255
|
---
|