@rag-widget/chat-widget 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 +196 -0
- package/dist/components/ChatBubble.d.ts +4 -0
- package/dist/components/ChatWidget.d.ts +5 -0
- package/dist/components/ChatWindow.d.ts +4 -0
- package/dist/hooks/useChatWidget.d.ts +21 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.esm.js +305 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +315 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +2 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/providers/ChatWidgetProvider.d.ts +18 -0
- package/dist/styles.css +1 -0
- package/dist/types/index.d.ts +68 -0
- package/package.json +57 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface WidgetConfig {
|
|
2
|
+
widgetId: string;
|
|
3
|
+
name: string;
|
|
4
|
+
greeting: string;
|
|
5
|
+
placeholder: string;
|
|
6
|
+
primaryColor: string;
|
|
7
|
+
position: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
8
|
+
showPoweredBy: boolean;
|
|
9
|
+
systemPrompt?: string;
|
|
10
|
+
channelName: string;
|
|
11
|
+
allowedMessageLength: number;
|
|
12
|
+
maxMessagesPerSession: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Message {
|
|
15
|
+
id: string;
|
|
16
|
+
role: 'user' | 'assistant';
|
|
17
|
+
content: string;
|
|
18
|
+
timestamp: Date;
|
|
19
|
+
sources?: Source[];
|
|
20
|
+
isStreaming?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface Source {
|
|
23
|
+
documentId: string;
|
|
24
|
+
title: string;
|
|
25
|
+
relevanceScore: number;
|
|
26
|
+
snippet?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface ChatSession {
|
|
29
|
+
sessionId: string;
|
|
30
|
+
expiresAt: Date;
|
|
31
|
+
}
|
|
32
|
+
export interface UsageInfo {
|
|
33
|
+
promptTokens?: number;
|
|
34
|
+
completionTokens?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ChatWidgetProps {
|
|
37
|
+
apiKey: string;
|
|
38
|
+
widgetId: string;
|
|
39
|
+
apiBaseUrl?: string;
|
|
40
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
41
|
+
primaryColor?: string;
|
|
42
|
+
greeting?: string;
|
|
43
|
+
placeholder?: string;
|
|
44
|
+
showPoweredBy?: boolean;
|
|
45
|
+
onError?: (error: Error) => void;
|
|
46
|
+
onMessageSent?: (message: string) => void;
|
|
47
|
+
onMessageReceived?: (message: Message) => void;
|
|
48
|
+
}
|
|
49
|
+
export interface ChatBubbleProps {
|
|
50
|
+
isOpen: boolean;
|
|
51
|
+
onClick: () => void;
|
|
52
|
+
primaryColor?: string;
|
|
53
|
+
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
54
|
+
unreadCount?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface ChatWindowProps {
|
|
57
|
+
isOpen: boolean;
|
|
58
|
+
onClose: () => void;
|
|
59
|
+
config: WidgetConfig;
|
|
60
|
+
messages: Message[];
|
|
61
|
+
isLoading: boolean;
|
|
62
|
+
onSendMessage: (message: string) => void;
|
|
63
|
+
}
|
|
64
|
+
export interface ApiResponse<T> {
|
|
65
|
+
status: 'success' | 'error';
|
|
66
|
+
data?: T;
|
|
67
|
+
message?: string;
|
|
68
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rag-widget/chat-widget",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Embeddable chat widget for RAG-powered knowledge bases",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "rollup -c",
|
|
13
|
+
"build:watch": "rollup -c -w",
|
|
14
|
+
"clean": "rm -rf dist",
|
|
15
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
16
|
+
},
|
|
17
|
+
"peerDependencies": {
|
|
18
|
+
"react": ">=17.0.0",
|
|
19
|
+
"react-dom": ">=17.0.0"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
23
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
24
|
+
"@rollup/plugin-typescript": "^11.1.6",
|
|
25
|
+
"@types/react": "^18.2.0",
|
|
26
|
+
"@types/react-dom": "^18.2.0",
|
|
27
|
+
"postcss": "^8.4.35",
|
|
28
|
+
"rollup": "^4.12.0",
|
|
29
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
30
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
31
|
+
"tslib": "^2.6.2",
|
|
32
|
+
"typescript": "^5.3.3"
|
|
33
|
+
},
|
|
34
|
+
"keywords": [
|
|
35
|
+
"react",
|
|
36
|
+
"chat",
|
|
37
|
+
"widget",
|
|
38
|
+
"embeddable",
|
|
39
|
+
"rag",
|
|
40
|
+
"ai",
|
|
41
|
+
"knowledge-base"
|
|
42
|
+
],
|
|
43
|
+
"author": "",
|
|
44
|
+
"license": "MIT",
|
|
45
|
+
"repository": {
|
|
46
|
+
"type": "git",
|
|
47
|
+
"url": "https://github.com/randallgann/rag-widget.git",
|
|
48
|
+
"directory": "widget"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"homepage": "https://github.com/randallgann/rag-widget/tree/main/widget#readme",
|
|
54
|
+
"bugs": {
|
|
55
|
+
"url": "https://github.com/randallgann/rag-widget/issues"
|
|
56
|
+
}
|
|
57
|
+
}
|