@openchatwidget/sdk 0.1.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 +63 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1135 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# OpenChatWidget
|
|
2
|
+
|
|
3
|
+
OpenChatWidget is a minimal, open-source React chat widget for any website.
|
|
4
|
+
It intentionally ships only the client widget:
|
|
5
|
+
|
|
6
|
+
- floating bottom-right widget UI
|
|
7
|
+
- AI SDK chat streaming client
|
|
8
|
+
|
|
9
|
+
Live chat, Convex, dashboard, and backend hosting are intentionally excluded.
|
|
10
|
+
|
|
11
|
+
## Install the widget
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
cd /Users/matt8p/Desktop/openchatwidget/sdk
|
|
15
|
+
npm install
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Use the component (React)
|
|
19
|
+
|
|
20
|
+
```jsx
|
|
21
|
+
import { OpenChatWidget } from "openchatwidget";
|
|
22
|
+
|
|
23
|
+
export default function App() {
|
|
24
|
+
return <OpenChatWidget url={"http://localhost:3001/api/chat"} />;
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
`url` is the only configurable React prop and should point to your exact chat endpoint.
|
|
29
|
+
|
|
30
|
+
## Example backend and app
|
|
31
|
+
|
|
32
|
+
A Vite + Express example app lives in:
|
|
33
|
+
|
|
34
|
+
`/Users/matt8p/Desktop/openchatwidget/examples/vite-express-app`
|
|
35
|
+
|
|
36
|
+
It includes:
|
|
37
|
+
|
|
38
|
+
- Vite landing page with `OpenChatWidget`
|
|
39
|
+
- Express `POST /api/chat` endpoint
|
|
40
|
+
- AI SDK streaming response from the backend endpoint
|
|
41
|
+
|
|
42
|
+
## Backend helpers
|
|
43
|
+
|
|
44
|
+
The package also re-exports the backend helpers used by the example server, so a simple OpenAI-backed server can import from `openchatwidget` directly:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import {
|
|
48
|
+
convertToModelMessages,
|
|
49
|
+
createOpenAI,
|
|
50
|
+
streamText,
|
|
51
|
+
type UIMessage,
|
|
52
|
+
} from "openchatwidget";
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Build
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm run build
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
This outputs:
|
|
62
|
+
|
|
63
|
+
- `dist/index.js` (widget bundle)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
export { createOpenAI } from '@ai-sdk/openai';
|
|
3
|
+
export { UIMessage, convertToModelMessages, streamText } from 'ai';
|
|
4
|
+
|
|
5
|
+
type OpenChatWidgetProps = {
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
declare function OpenChatWidget({ url }: OpenChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
9
|
+
|
|
10
|
+
export { OpenChatWidget, type OpenChatWidgetProps };
|