ghonchu_rag 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/README.md +66 -0
- package/dist/GhonchuRAG.d.ts +9 -0
- package/dist/GhonchuRAG.d.ts.map +1 -0
- package/dist/GhonchuRAG.js +18 -0
- package/dist/GhonchuRAG.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +5 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/widget.d.ts +35 -0
- package/dist/widget.d.ts.map +1 -0
- package/dist/widget.js +378 -0
- package/dist/widget.js.map +1 -0
- package/package.json +34 -0
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Ghonchu_RAG
|
|
2
|
+
|
|
3
|
+
A themeable chatbot widget for frontend integration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install ghonchu_rag
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### React
|
|
14
|
+
|
|
15
|
+
```tsx
|
|
16
|
+
import { GhonchuRAG } from 'ghonchu_rag';
|
|
17
|
+
import 'ghonchu_rag/dist/styles.css';
|
|
18
|
+
|
|
19
|
+
function App() {
|
|
20
|
+
return (
|
|
21
|
+
<GhonchuRAG
|
|
22
|
+
id="123"
|
|
23
|
+
config={{
|
|
24
|
+
backendUrl: process.env.REACT_APP_BACKEND_URL || 'https://api.yoursite.com',
|
|
25
|
+
theme: 'default'
|
|
26
|
+
}}
|
|
27
|
+
/>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Vanilla JavaScript
|
|
33
|
+
|
|
34
|
+
```javascript
|
|
35
|
+
import { GhonchuWidget } from 'ghonchu_rag';
|
|
36
|
+
|
|
37
|
+
new GhonchuWidget('your-user-id', {
|
|
38
|
+
backendUrl: 'https://api.yoursite.com',
|
|
39
|
+
theme: 'cyberpunk'
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Configuration
|
|
44
|
+
|
|
45
|
+
| Option | Type | Default | Description |
|
|
46
|
+
|--------|------|---------|-------------|
|
|
47
|
+
| `backendUrl` | string | `http://localhost:3001` | Backend API endpoint |
|
|
48
|
+
| `theme` | `'default' \| 'cyberpunk' \| 'professional'` | `'default'` | Widget theme |
|
|
49
|
+
|
|
50
|
+
## Themes
|
|
51
|
+
|
|
52
|
+
- **Default**: Amber/Orange Glassmorphism
|
|
53
|
+
- **Cyberpunk**: Neon Blue/Pink
|
|
54
|
+
- **Professional**: Minimalist Blue/Grey
|
|
55
|
+
|
|
56
|
+
## Development
|
|
57
|
+
|
|
58
|
+
Create a `.env` file:
|
|
59
|
+
```env
|
|
60
|
+
BACKEND_URL=http://localhost:3001
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Then build:
|
|
64
|
+
```bash
|
|
65
|
+
npm run build
|
|
66
|
+
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GhonchuRAG.d.ts","sourceRoot":"","sources":["../src/GhonchuRAG.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,UAAU,KAAK;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC;CAClC;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAe/B,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { GhonchuWidget } from './widget.js';
|
|
3
|
+
const GhonchuRAG = ({ id, config }) => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
// Initialize the widget
|
|
6
|
+
const widget = new GhonchuWidget(id, config);
|
|
7
|
+
// Cleanup when component unmounts
|
|
8
|
+
return () => {
|
|
9
|
+
const existing = document.getElementById('ghonchu-widget-root');
|
|
10
|
+
if (existing) {
|
|
11
|
+
existing.remove();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
}, [id, config]);
|
|
15
|
+
return null; // The widget injects itself into the DOM outside the React tree
|
|
16
|
+
};
|
|
17
|
+
export default GhonchuRAG;
|
|
18
|
+
//# sourceMappingURL=GhonchuRAG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GhonchuRAG.js","sourceRoot":"","sources":["../src/GhonchuRAG.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAQ5C,MAAM,UAAU,GAAoB,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;IACnD,SAAS,CAAC,GAAG,EAAE;QACX,wBAAwB;QACxB,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAE7C,kCAAkC;QAClC,OAAO,GAAG,EAAE;YACR,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC;YAChE,IAAI,QAAQ,EAAE,CAAC;gBACX,QAAQ,CAAC,MAAM,EAAE,CAAC;YACtB,CAAC;QACL,CAAC,CAAC;IACN,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAEjB,OAAO,IAAI,CAAC,CAAC,gEAAgE;AACjF,CAAC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3C,MAAc,CAAC,aAAa,GAAG,aAAa,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IACzB,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,cAAc,CAAC;IAChD,UAAU,EAAE,MAAM,CAAC;CACtB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/widget.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { WidgetConfig } from './types.js';
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
marked: {
|
|
5
|
+
parse: (text: string) => string;
|
|
6
|
+
};
|
|
7
|
+
DOMPurify: {
|
|
8
|
+
sanitize: (html: string) => string;
|
|
9
|
+
};
|
|
10
|
+
GhonchuWidget: any;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare class GhonchuWidget {
|
|
14
|
+
private container;
|
|
15
|
+
private config;
|
|
16
|
+
private userId;
|
|
17
|
+
private roomId;
|
|
18
|
+
private typingEl;
|
|
19
|
+
constructor(userId?: string, options?: Partial<WidgetConfig>);
|
|
20
|
+
private generateUUID;
|
|
21
|
+
private init;
|
|
22
|
+
private fetchConfig;
|
|
23
|
+
private createSession;
|
|
24
|
+
private loadHistory;
|
|
25
|
+
private deleteSession;
|
|
26
|
+
private renderHistoryList;
|
|
27
|
+
private fetchSessions;
|
|
28
|
+
private render;
|
|
29
|
+
private setupListeners;
|
|
30
|
+
private addMessage;
|
|
31
|
+
private showTyping;
|
|
32
|
+
private hideTyping;
|
|
33
|
+
private scrollToBottom;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=widget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.d.ts","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AA8B1C,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,MAAM,EAAE;YACJ,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;SACnC,CAAC;QACF,SAAS,EAAE;YACP,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,CAAC;SACtC,CAAC;QACF,aAAa,EAAE,GAAG,CAAC;KACtB;CACJ;AAKD,qBAAa,aAAa;IACtB,OAAO,CAAC,SAAS,CAAc;IAC/B,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,QAAQ,CAA4B;gBAEhC,MAAM,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,OAAO,CAAC,YAAY,CAAM;IAmBhE,OAAO,CAAC,YAAY;YAON,IAAI;YAaJ,WAAW;YAYX,aAAa;YAoBb,WAAW;YAsBX,aAAa;YAyBb,iBAAiB;YA+CjB,aAAa;IAU3B,OAAO,CAAC,MAAM;IAwCd,OAAO,CAAC,cAAc;IAmFtB,OAAO,CAAC,UAAU;IAqDlB,OAAO,CAAC,UAAU;IAmBlB,OAAO,CAAC,UAAU;IAOlB,OAAO,CAAC,cAAc;CAIzB"}
|
package/dist/widget.js
ADDED
|
@@ -0,0 +1,378 @@
|
|
|
1
|
+
/* ===============================
|
|
2
|
+
AUTO LOAD MARKDOWN + SANITIZER
|
|
3
|
+
=============================== */
|
|
4
|
+
function loadScriptOnce(src, globalName) {
|
|
5
|
+
return new Promise((resolve) => {
|
|
6
|
+
if (globalName && window[globalName] !== undefined) {
|
|
7
|
+
return resolve();
|
|
8
|
+
}
|
|
9
|
+
const s = document.createElement("script");
|
|
10
|
+
s.src = src;
|
|
11
|
+
s.onload = () => resolve();
|
|
12
|
+
document.head.appendChild(s);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async function ensureMarkdownReady() {
|
|
16
|
+
await loadScriptOnce("https://cdn.jsdelivr.net/npm/marked/marked.min.js", "marked");
|
|
17
|
+
await loadScriptOnce("https://cdn.jsdelivr.net/npm/dompurify@3.0.6/dist/purify.min.js", "DOMPurify");
|
|
18
|
+
}
|
|
19
|
+
/* ===============================
|
|
20
|
+
WIDGET
|
|
21
|
+
=============================== */
|
|
22
|
+
export class GhonchuWidget {
|
|
23
|
+
container;
|
|
24
|
+
config;
|
|
25
|
+
userId;
|
|
26
|
+
roomId = null;
|
|
27
|
+
typingEl = null;
|
|
28
|
+
constructor(userId, options = {}) {
|
|
29
|
+
// 1. Resolve User ID (Priority: Constructor -> LocalStorage -> Generate)
|
|
30
|
+
this.userId = userId || localStorage.getItem('ghonchu_userId') || this.generateUUID();
|
|
31
|
+
localStorage.setItem('ghonchu_userId', this.userId);
|
|
32
|
+
// 2. Resolve Last Room ID
|
|
33
|
+
this.roomId = localStorage.getItem('ghonchu_lastRoomId');
|
|
34
|
+
this.config = {
|
|
35
|
+
theme: 'default',
|
|
36
|
+
backendUrl: import.meta.env?.BACKEND_URL || 'https://backend-test-ghonchurag.onrender.com',
|
|
37
|
+
...options,
|
|
38
|
+
};
|
|
39
|
+
this.container = document.createElement('div');
|
|
40
|
+
this.container.id = 'ghonchu-widget-root';
|
|
41
|
+
document.body.appendChild(this.container);
|
|
42
|
+
this.init();
|
|
43
|
+
}
|
|
44
|
+
generateUUID() {
|
|
45
|
+
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
46
|
+
var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
|
|
47
|
+
return v.toString(16);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async init() {
|
|
51
|
+
await ensureMarkdownReady();
|
|
52
|
+
await this.fetchConfig();
|
|
53
|
+
this.render();
|
|
54
|
+
// Auto-load history or create new session
|
|
55
|
+
if (this.roomId) {
|
|
56
|
+
await this.loadHistory(this.roomId);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
await this.createSession();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async fetchConfig() {
|
|
63
|
+
try {
|
|
64
|
+
const response = await fetch(`${this.config.backendUrl}/config/${this.userId}`);
|
|
65
|
+
if (response.ok) {
|
|
66
|
+
const data = await response.json();
|
|
67
|
+
this.config.theme = data.theme || this.config.theme;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
console.error('Failed to fetch widget config:', error);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async createSession() {
|
|
75
|
+
try {
|
|
76
|
+
const response = await fetch(`${this.config.backendUrl}/session`, {
|
|
77
|
+
method: 'POST',
|
|
78
|
+
headers: { 'Content-Type': 'application/json' },
|
|
79
|
+
body: JSON.stringify({ userId: this.userId })
|
|
80
|
+
});
|
|
81
|
+
const data = await response.json();
|
|
82
|
+
this.roomId = data.roomId;
|
|
83
|
+
localStorage.setItem('ghonchu_lastRoomId', this.roomId);
|
|
84
|
+
// Clear UI for new chat
|
|
85
|
+
const messagesDiv = this.container.querySelector('.ghonchu-messages');
|
|
86
|
+
if (messagesDiv)
|
|
87
|
+
messagesDiv.innerHTML = '';
|
|
88
|
+
this.addMessage('bot', 'Hello! How can I help you today?');
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error('Failed to create session:', error);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async loadHistory(roomId) {
|
|
95
|
+
try {
|
|
96
|
+
const response = await fetch(`${this.config.backendUrl}/session/${roomId}`);
|
|
97
|
+
const messages = await response.json();
|
|
98
|
+
const messagesDiv = this.container.querySelector('.ghonchu-messages');
|
|
99
|
+
if (messagesDiv)
|
|
100
|
+
messagesDiv.innerHTML = ''; // Clear current view
|
|
101
|
+
if (messages.length === 0) {
|
|
102
|
+
this.addMessage('bot', 'Hello! How can I help you today?');
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
messages.forEach((msg) => {
|
|
106
|
+
this.addMessage(msg.sender, msg.message);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
console.error('Failed to load history:', error);
|
|
112
|
+
// Fallback if room not found?
|
|
113
|
+
this.createSession();
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async deleteSession(roomId, event) {
|
|
117
|
+
event.stopPropagation(); // Prevent opening the chat
|
|
118
|
+
if (!confirm('Are you sure you want to delete this chat?'))
|
|
119
|
+
return;
|
|
120
|
+
try {
|
|
121
|
+
await fetch(`${this.config.backendUrl}/session/${roomId}`, {
|
|
122
|
+
method: 'DELETE'
|
|
123
|
+
});
|
|
124
|
+
// Refresh list
|
|
125
|
+
const historyView = this.container.querySelector('.ghonchu-history-view');
|
|
126
|
+
if (historyView.style.display === 'block') {
|
|
127
|
+
await this.renderHistoryList();
|
|
128
|
+
}
|
|
129
|
+
// If deleted current session, reset
|
|
130
|
+
if (this.roomId === roomId) {
|
|
131
|
+
this.createSession();
|
|
132
|
+
// Close history view if open? No, keep it open to show updated list
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
console.error('Failed to delete session:', error);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
async renderHistoryList() {
|
|
140
|
+
const sessionList = this.container.querySelector('.ghonchu-session-list');
|
|
141
|
+
if (!sessionList)
|
|
142
|
+
return;
|
|
143
|
+
sessionList.innerHTML = 'Loading...';
|
|
144
|
+
const sessions = await this.fetchSessions();
|
|
145
|
+
sessionList.innerHTML = '';
|
|
146
|
+
if (sessions.length === 0) {
|
|
147
|
+
sessionList.innerHTML = '<div style="opacity:0.7; font-style:italic;">No past conversations.</div>';
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
sessions.forEach((s) => {
|
|
151
|
+
const el = document.createElement('div');
|
|
152
|
+
el.className = 'ghonchu-session-item';
|
|
153
|
+
el.style.cssText = "padding:10px; background:rgba(255,255,255,0.1); border-radius:8px; cursor:pointer; border:1px solid transparent; display:flex; justify-content:space-between; align-items:center;";
|
|
154
|
+
const date = new Date(s.createdAt).toLocaleDateString();
|
|
155
|
+
const info = document.createElement('div');
|
|
156
|
+
info.innerHTML = `<div style="font-weight:bold;">${s.title}</div><div style="font-size:0.8em; opacity:0.7;">${date}</div>`;
|
|
157
|
+
const delBtn = document.createElement('button');
|
|
158
|
+
delBtn.innerHTML = '🗑️';
|
|
159
|
+
delBtn.title = 'Delete Chat';
|
|
160
|
+
delBtn.style.cssText = 'background:none; border:none; cursor:pointer; font-size:1.1em; opacity:0.6; padding:4px;';
|
|
161
|
+
delBtn.onmouseenter = () => delBtn.style.opacity = '1';
|
|
162
|
+
delBtn.onmouseleave = () => delBtn.style.opacity = '0.6';
|
|
163
|
+
delBtn.onclick = (e) => this.deleteSession(s._id, e);
|
|
164
|
+
el.appendChild(info);
|
|
165
|
+
el.appendChild(delBtn);
|
|
166
|
+
if (s._id === this.roomId)
|
|
167
|
+
el.style.borderColor = 'var(--ghonchu-amber-400)';
|
|
168
|
+
el.onclick = () => {
|
|
169
|
+
this.roomId = s._id;
|
|
170
|
+
localStorage.setItem('ghonchu_lastRoomId', this.roomId);
|
|
171
|
+
this.loadHistory(this.roomId);
|
|
172
|
+
const historyView = this.container.querySelector('.ghonchu-history-view');
|
|
173
|
+
historyView.style.display = 'none';
|
|
174
|
+
};
|
|
175
|
+
sessionList.appendChild(el);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
async fetchSessions() {
|
|
179
|
+
try {
|
|
180
|
+
const response = await fetch(`${this.config.backendUrl}/sessions/${this.userId}`);
|
|
181
|
+
return await response.json();
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
console.error('Failed to fetch sessions:', error);
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
render() {
|
|
189
|
+
this.container.className = `ghonchu-theme-${this.config.theme}`;
|
|
190
|
+
this.container.innerHTML = `
|
|
191
|
+
<div class="ghonchu-launcher">
|
|
192
|
+
<span>🐕</span>
|
|
193
|
+
</div>
|
|
194
|
+
<div class="ghonchu-chat-window" style="display: none;">
|
|
195
|
+
<div class="ghonchu-header">
|
|
196
|
+
<div style="flex: 1;">
|
|
197
|
+
<div class="ghonchu-title">Ghonchu GPT</div>
|
|
198
|
+
<div class="ghonchu-status">🐕 Your Golden AI Companion</div>
|
|
199
|
+
</div>
|
|
200
|
+
<div class="ghonchu-controls" style="display: flex; gap: 8px;">
|
|
201
|
+
<button class="ghonchu-btn-history" title="History" style="background:none; border:none; cursor:pointer; font-size: 1.2rem;">🕒</button>
|
|
202
|
+
<button class="ghonchu-btn-new" title="New Chat" style="background:none; border:none; cursor:pointer; font-size: 1.2rem;">➕</button>
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
|
|
206
|
+
<!-- HISTORY OVERLAY -->
|
|
207
|
+
<div class="ghonchu-history-view" style="display:none; position:absolute; top:60px; left:0; right:0; bottom:0; background:rgba(0,0,0,0.85); backdrop-filter:blur(5px); z-index:10; padding:20px; color:white; overflow-y:auto;">
|
|
208
|
+
<h3 style="margin-top:0;">Past Conversations</h3>
|
|
209
|
+
<div class="ghonchu-session-list" style="display:flex; flex-direction:column; gap:10px; margin-top:15px;"></div>
|
|
210
|
+
<button class="ghonchu-btn-close-history" style="margin-top:20px; padding:8px 16px; background:var(--ghonchu-amber-600); border:none; border-radius:6px; color:white; cursor:pointer;">Close</button>
|
|
211
|
+
</div>
|
|
212
|
+
|
|
213
|
+
<div class="ghonchu-messages"></div>
|
|
214
|
+
<div class="ghonchu-input-area">
|
|
215
|
+
<input type="text" placeholder="Type your message to Ghonchu..." />
|
|
216
|
+
<button class="ghonchu-send">
|
|
217
|
+
<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
218
|
+
<path d="M22 2L11 13M22 2L15 22L11 13M11 13L2 9L22 2" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
219
|
+
</svg>
|
|
220
|
+
</button>
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
`;
|
|
224
|
+
this.setupListeners();
|
|
225
|
+
}
|
|
226
|
+
setupListeners() {
|
|
227
|
+
const launcher = this.container.querySelector('.ghonchu-launcher');
|
|
228
|
+
const chatWindow = this.container.querySelector('.ghonchu-chat-window');
|
|
229
|
+
const input = this.container.querySelector('input');
|
|
230
|
+
const sendBtn = this.container.querySelector('.ghonchu-send');
|
|
231
|
+
const historyBtn = this.container.querySelector('.ghonchu-btn-history');
|
|
232
|
+
const newChatBtn = this.container.querySelector('.ghonchu-btn-new');
|
|
233
|
+
const historyView = this.container.querySelector('.ghonchu-history-view');
|
|
234
|
+
const closeHistoryBtn = this.container.querySelector('.ghonchu-btn-close-history');
|
|
235
|
+
const sessionList = this.container.querySelector('.ghonchu-session-list');
|
|
236
|
+
// Toggle Widget
|
|
237
|
+
launcher?.addEventListener('click', () => {
|
|
238
|
+
if (chatWindow.style.display === "none") {
|
|
239
|
+
chatWindow.style.display = "flex";
|
|
240
|
+
setTimeout(() => input?.focus(), 50);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
chatWindow.classList.add("closing");
|
|
244
|
+
setTimeout(() => {
|
|
245
|
+
chatWindow.style.display = "none";
|
|
246
|
+
chatWindow.classList.remove("closing");
|
|
247
|
+
}, 200);
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
// New Chat
|
|
251
|
+
newChatBtn?.addEventListener('click', () => {
|
|
252
|
+
this.createSession();
|
|
253
|
+
historyView.style.display = 'none';
|
|
254
|
+
});
|
|
255
|
+
// Toggle History
|
|
256
|
+
historyBtn?.addEventListener('click', async () => {
|
|
257
|
+
historyView.style.display = 'block';
|
|
258
|
+
this.renderHistoryList();
|
|
259
|
+
});
|
|
260
|
+
closeHistoryBtn?.addEventListener('click', () => {
|
|
261
|
+
historyView.style.display = 'none';
|
|
262
|
+
});
|
|
263
|
+
const sendMessage = async () => {
|
|
264
|
+
const message = input?.value?.trim();
|
|
265
|
+
if (!message)
|
|
266
|
+
return;
|
|
267
|
+
if (!this.roomId)
|
|
268
|
+
await this.createSession(); // Safety check
|
|
269
|
+
this.addMessage('user', message);
|
|
270
|
+
input.value = '';
|
|
271
|
+
this.showTyping();
|
|
272
|
+
try {
|
|
273
|
+
const response = await fetch(`${this.config.backendUrl}/chat`, {
|
|
274
|
+
method: 'POST',
|
|
275
|
+
headers: { 'Content-Type': 'application/json' },
|
|
276
|
+
body: JSON.stringify({
|
|
277
|
+
userId: this.userId,
|
|
278
|
+
roomId: this.roomId,
|
|
279
|
+
message: message
|
|
280
|
+
})
|
|
281
|
+
});
|
|
282
|
+
const data = await response.json();
|
|
283
|
+
this.hideTyping();
|
|
284
|
+
this.addMessage('bot', data.reply || "");
|
|
285
|
+
}
|
|
286
|
+
catch (error) {
|
|
287
|
+
this.hideTyping();
|
|
288
|
+
this.addMessage('bot', '❌ Error connecting to service.');
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
sendBtn?.addEventListener('click', sendMessage);
|
|
292
|
+
input?.addEventListener('keypress', (e) => {
|
|
293
|
+
if (e.key === 'Enter')
|
|
294
|
+
sendMessage();
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
/* ===============================
|
|
298
|
+
MESSAGE HANDLING
|
|
299
|
+
=============================== */
|
|
300
|
+
addMessage(sender, text) {
|
|
301
|
+
const messagesDiv = this.container.querySelector('.ghonchu-messages');
|
|
302
|
+
if (!messagesDiv)
|
|
303
|
+
return;
|
|
304
|
+
// Create message wrapper
|
|
305
|
+
const wrapper = document.createElement('div');
|
|
306
|
+
wrapper.className = `ghonchu-message-wrapper msg-${sender}-wrapper`;
|
|
307
|
+
// Create avatar
|
|
308
|
+
const avatar = document.createElement('div');
|
|
309
|
+
avatar.className = `ghonchu-avatar avatar-${sender}`;
|
|
310
|
+
if (sender === 'bot') {
|
|
311
|
+
avatar.innerHTML = `
|
|
312
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 14c1.49-1.46 3-3.21 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.76 0-3 .5-4.5 2-1.5-1.5-2.74-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4.05 3 5.5l7 7Z"/></svg>
|
|
313
|
+
`;
|
|
314
|
+
}
|
|
315
|
+
else {
|
|
316
|
+
avatar.innerHTML = `
|
|
317
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
|
|
318
|
+
`;
|
|
319
|
+
}
|
|
320
|
+
// Create message bubble
|
|
321
|
+
const msgEl = document.createElement('div');
|
|
322
|
+
msgEl.className = `ghonchu-message msg-${sender}`;
|
|
323
|
+
if (sender === 'bot' && typeof window.marked !== 'undefined') {
|
|
324
|
+
// Basic Markdown + Sanitize
|
|
325
|
+
const html = window.marked.parse(text || "");
|
|
326
|
+
msgEl.innerHTML = window.DOMPurify
|
|
327
|
+
? window.DOMPurify.sanitize(html)
|
|
328
|
+
: html;
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
msgEl.textContent = text || "";
|
|
332
|
+
}
|
|
333
|
+
// Assemble message
|
|
334
|
+
if (sender === 'bot') {
|
|
335
|
+
wrapper.appendChild(avatar);
|
|
336
|
+
wrapper.appendChild(msgEl);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
wrapper.appendChild(msgEl);
|
|
340
|
+
wrapper.appendChild(avatar);
|
|
341
|
+
}
|
|
342
|
+
messagesDiv.appendChild(wrapper);
|
|
343
|
+
this.scrollToBottom();
|
|
344
|
+
}
|
|
345
|
+
/* ===============================
|
|
346
|
+
TYPING INDICATOR
|
|
347
|
+
=============================== */
|
|
348
|
+
showTyping() {
|
|
349
|
+
if (this.typingEl)
|
|
350
|
+
return;
|
|
351
|
+
const messagesDiv = this.container.querySelector(".ghonchu-messages");
|
|
352
|
+
if (!messagesDiv)
|
|
353
|
+
return;
|
|
354
|
+
this.typingEl = document.createElement("div");
|
|
355
|
+
this.typingEl.className = "ghonchu-message-wrapper msg-bot-wrapper";
|
|
356
|
+
this.typingEl.innerHTML = `
|
|
357
|
+
<div class="msg-bot ghonchu-typing">
|
|
358
|
+
<span></span><span></span><span></span>
|
|
359
|
+
</div>
|
|
360
|
+
`;
|
|
361
|
+
messagesDiv.appendChild(this.typingEl);
|
|
362
|
+
this.scrollToBottom();
|
|
363
|
+
}
|
|
364
|
+
hideTyping() {
|
|
365
|
+
if (this.typingEl) {
|
|
366
|
+
this.typingEl.remove();
|
|
367
|
+
this.typingEl = null;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
scrollToBottom() {
|
|
371
|
+
const messagesDiv = this.container.querySelector(".ghonchu-messages");
|
|
372
|
+
if (messagesDiv)
|
|
373
|
+
messagesDiv.scrollTop = messagesDiv.scrollHeight;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
// Expose to window for global access if needed
|
|
377
|
+
window.GhonchuWidget = GhonchuWidget;
|
|
378
|
+
//# sourceMappingURL=widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget.js","sourceRoot":"","sources":["../src/widget.ts"],"names":[],"mappings":"AAEA;;kCAEkC;AAClC,SAAS,cAAc,CAAC,GAAW,EAAE,UAAkB;IACnD,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC3B,IAAI,UAAU,IAAK,MAAc,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE,CAAC;YAC1D,OAAO,OAAO,EAAE,CAAC;QACrB,CAAC;QAED,MAAM,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC3C,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;QACZ,CAAC,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;QAC3B,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC,CAAC,CAAC;AACP,CAAC;AAED,KAAK,UAAU,mBAAmB;IAC9B,MAAM,cAAc,CAChB,mDAAmD,EACnD,QAAQ,CACX,CAAC;IAEF,MAAM,cAAc,CAChB,iEAAiE,EACjE,WAAW,CACd,CAAC;AACN,CAAC;AAcD;;kCAEkC;AAClC,MAAM,OAAO,aAAa;IACd,SAAS,CAAc;IACvB,MAAM,CAAe;IACrB,MAAM,CAAS;IACf,MAAM,GAAkB,IAAI,CAAC;IAC7B,QAAQ,GAAuB,IAAI,CAAC;IAE5C,YAAY,MAAe,EAAE,UAAiC,EAAE;QAC5D,yEAAyE;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,YAAY,CAAC,OAAO,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;IAEO,UAAU;QACd,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAChB,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;YACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACzB,CAAC;IACL,CAAC;IAEO,cAAc;QAClB,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC;QACtE,IAAI,WAAW;YAAE,WAAW,CAAC,SAAS,GAAG,WAAW,CAAC,YAAY,CAAC;IACtE,CAAC;CACJ;AAED,+CAA+C;AAC9C,MAAc,CAAC,aAAa,GAAG,aAAa,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ghonchu_rag",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "A themeable chatbot widget for frontend integration.",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"chatbot",
|
|
17
|
+
"widget",
|
|
18
|
+
"rag",
|
|
19
|
+
"frontend"
|
|
20
|
+
],
|
|
21
|
+
"author": "",
|
|
22
|
+
"license": "ISC",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/react": "^19.2.10",
|
|
25
|
+
"@types/react-dom": "^19.2.3",
|
|
26
|
+
"react": "^19.2.4",
|
|
27
|
+
"react-dom": "^19.2.4",
|
|
28
|
+
"typescript": "^5.9.3"
|
|
29
|
+
},
|
|
30
|
+
"peerDependencies": {
|
|
31
|
+
"react": ">=16.8.0",
|
|
32
|
+
"react-dom": ">=16.8.0"
|
|
33
|
+
}
|
|
34
|
+
}
|