@bmx-labs/chat-widget 0.0.1 → 0.0.3
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 +38 -46
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/rest-adapter.d.ts +25 -0
- package/dist/components/chat/ChatPanel.d.ts +2 -1
- package/dist/components/chat/SettingsPanel.d.ts +3 -1
- package/dist/components/message/EmptyMessages.d.ts +4 -0
- package/dist/components/message/MessageList.d.ts +2 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/types.d.ts +71 -0
- package/package.json +10 -9
- package/dist/adapters/AnthropicAdapter.d.ts +0 -16
- package/dist/adapters/ContextAdapter.d.ts +0 -19
- package/dist/adapters/CustomAPIAdapter.d.ts +0 -20
- package/dist/adapters/KnowledgeBaseAdapter.d.ts +0 -20
- package/dist/adapters/MockAdapter.d.ts +0 -6
- package/dist/adapters/MorphexAdapter.d.ts +0 -16
- package/dist/adapters/OpenAIAdapter.d.ts +0 -17
- package/dist/adapters/RAGAdapter.d.ts +0 -29
- package/dist/adapters/RestRAGAdapter.d.ts +0 -9
- package/dist/adapters/TestAdapter.d.ts +0 -6
- package/dist/adapters/context/ContextAdapter.d.ts +0 -19
- package/dist/adapters/context/KnowledgeBaseAdapter.d.ts +0 -20
- package/dist/adapters/context/MorphexAdapter.d.ts +0 -16
- package/dist/adapters/context/PineconeRAGAdapter.d.ts +0 -40
- package/dist/adapters/context/RAGAdapter.d.ts +0 -29
- package/dist/adapters/context/index.d.ts +0 -2
- package/dist/adapters/rest.d.ts +0 -7
- package/dist/components/LazyComponents.d.ts +0 -3
- package/dist/components/Orb.d.ts +0 -8
- package/dist/components/OrbButton.d.ts +0 -10
- package/dist/components/SimpleIridescence.d.ts +0 -8
- package/dist/components/SimpleOrb.d.ts +0 -8
- package/dist/components/ogl/DarkVeil.d.ts +0 -11
- package/dist/data/morphexData.d.ts +0 -7
- package/dist/framer.js +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ogl.js +0 -1
- package/dist/styles.css.map +0 -1
- package/dist/styles.js.map +0 -1
- package/dist/vendors.js +0 -1
package/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# @bmx-labs/chat-widget
|
2
2
|
|
3
|
-
A reusable chat AI widget for React/Next.js apps. Fixed bottom-right with highest stacking order,
|
3
|
+
A reusable chat AI widget for React/Next.js apps. Fixed bottom-right with highest stacking order, designed for server-side RAG integration.
|
4
4
|
|
5
5
|
## Install
|
6
6
|
|
@@ -8,52 +8,57 @@ A reusable chat AI widget for React/Next.js apps. Fixed bottom-right with highes
|
|
8
8
|
npm i @bmx-labs/chat-widget react react-dom
|
9
9
|
```
|
10
10
|
|
11
|
+
```bash
|
12
|
+
yarn add @bmx-labs/chat-widget react react-dom
|
13
|
+
```
|
14
|
+
|
15
|
+
```bash
|
16
|
+
pnpm add @bmx-labs/chat-widget react react-dom
|
17
|
+
```
|
18
|
+
|
11
19
|
## Usage
|
12
20
|
|
13
21
|
```tsx
|
14
22
|
import React from "react";
|
15
|
-
import { BmxChatBot } from "@bmx-labs/chat-widget";
|
16
|
-
import { PineconeRAGAdapter } from "@bmx-labs/chat-widget/adapters/context";
|
23
|
+
import { BmxChatBot, RestAdapters } from "@bmx-labs/chat-widget";
|
17
24
|
|
18
25
|
export default function App() {
|
19
|
-
//
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
pineconeApiKey: process.env.NEXT_PUBLIC_PINECONE_API_KEY!,
|
24
|
-
pineconeIndexUrl: process.env.NEXT_PUBLIC_PINECONE_HOST!,
|
25
|
-
chatModel: "gpt-4o-mini",
|
26
|
-
});
|
27
|
-
|
28
|
-
return <BmxChatBot api={api} projectId="<your_project_id>" />;
|
26
|
+
// Server-side RAG adapter: calls your backend API endpoint
|
27
|
+
const api = RestAdapters.production(); // or RestAdapters.development()
|
28
|
+
|
29
|
+
return <BmxChatBot api={api} projectId="bmx" />;
|
29
30
|
}
|
30
31
|
```
|
31
32
|
|
32
33
|
- The widget is rendered via a portal to `document.body` with a very high `z-index`.
|
33
|
-
-
|
34
|
+
- **Server-side RAG**: All AI processing happens on your server to keep API keys secure.
|
34
35
|
|
35
36
|
### Adapters
|
36
37
|
|
37
|
-
- `
|
38
|
-
- `
|
38
|
+
- `RestAdapters.production()` – Calls your server endpoint (same domain)
|
39
|
+
- `RestAdapters.development()` – Calls localhost:8080 for development
|
40
|
+
- `createRestAdapter(config)` – Custom server configuration
|
41
|
+
- `createMockAdapter(delayMs?)` – Echo responses for local dev
|
39
42
|
|
40
|
-
###
|
43
|
+
### Server Integration
|
44
|
+
|
45
|
+
Create a POST endpoint on your server (e.g., `/common/ai/chat`) that handles RAG:
|
41
46
|
|
42
47
|
```ts
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
}
|
48
|
+
// Your server endpoint
|
49
|
+
POST /common/ai/chat
|
50
|
+
{
|
51
|
+
"input": "user question",
|
52
|
+
"history": [{"role": "user", "content": "previous message"}]
|
53
|
+
}
|
54
|
+
|
55
|
+
// Response
|
56
|
+
{
|
57
|
+
"id": "msg-123",
|
58
|
+
"role": "assistant",
|
59
|
+
"content": "AI response with sources",
|
60
|
+
"createdAt": 1234567890
|
61
|
+
}
|
57
62
|
```
|
58
63
|
|
59
64
|
### BmxChatBot Props
|
@@ -68,23 +73,10 @@ type PineconeRAGAdapterConfig = {
|
|
68
73
|
## Development
|
69
74
|
|
70
75
|
```bash
|
71
|
-
|
72
|
-
|
73
|
-
npm run dev
|
74
|
-
```
|
75
|
-
|
76
|
-
### GitHub Actions (Publish on tag)
|
77
|
-
|
78
|
-
1. Create an npm token and add it as `NPM_TOKEN` in GitHub repository secrets.
|
79
|
-
2. Push a tag to trigger publish:
|
80
|
-
|
81
|
-
```bash
|
82
|
-
git tag v0.1.1
|
83
|
-
git push --tags
|
76
|
+
pnpm i
|
77
|
+
pnpm dev
|
84
78
|
```
|
85
79
|
|
86
|
-
The workflow at `.github/workflows/publish.yml` will build and publish to npm.
|
87
|
-
|
88
80
|
## License
|
89
81
|
|
90
82
|
This project is licensed as **GNU AGPLv3**.
|
package/dist/adapters/index.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export { createMockAdapter } from "./mock";
|
2
|
-
export {
|
2
|
+
export { createRestAdapter, RestAdapters } from "./rest-adapter";
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { BmxChatApiAdapter, RestAdapterConfig } from "../types";
|
2
|
+
/**
|
3
|
+
* Creates a REST adapter that calls your server endpoint.
|
4
|
+
*
|
5
|
+
* @param {RestAdapterConfig} config - Configuration for the REST adapter.
|
6
|
+
* @returns {BmxChatApiAdapter} BmxChatApiAdapter implementation.
|
7
|
+
*/
|
8
|
+
export declare function createRestAdapter(config: RestAdapterConfig): BmxChatApiAdapter;
|
9
|
+
/**
|
10
|
+
* Convenience factory for development and production.
|
11
|
+
*/
|
12
|
+
export declare const RestAdapters: {
|
13
|
+
/**
|
14
|
+
* For development (localhost:8080)
|
15
|
+
*/
|
16
|
+
development: () => BmxChatApiAdapter;
|
17
|
+
/**
|
18
|
+
* For production (same domain)
|
19
|
+
*/
|
20
|
+
production: (baseUrl?: string) => BmxChatApiAdapter;
|
21
|
+
/**
|
22
|
+
* Custom configuration
|
23
|
+
*/
|
24
|
+
custom: (config: RestAdapterConfig) => BmxChatApiAdapter;
|
25
|
+
};
|
@@ -19,6 +19,7 @@ interface ChatPanelProps {
|
|
19
19
|
onHoverIntensityChange: (intensity: number) => void;
|
20
20
|
rotateOnHover: boolean;
|
21
21
|
onRotateOnHoverChange: (rotate: boolean) => void;
|
22
|
+
onSuggestionClick?: (suggestion: string) => void;
|
22
23
|
}
|
23
|
-
export declare function ChatPanel({ title, messages, input, setInput, onKeyDown, onSend, onClose, placeholder, sending, showSettings, onToggleSettings, onClearHistory, hue, onHueChange, hoverIntensity, onHoverIntensityChange, rotateOnHover, onRotateOnHoverChange, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
24
|
+
export declare function ChatPanel({ title, messages, input, setInput, onKeyDown, onSend, onClose, placeholder, sending, showSettings, onToggleSettings, onClearHistory, hue, onHueChange, hoverIntensity, onHoverIntensityChange, rotateOnHover, onRotateOnHoverChange, onSuggestionClick, }: ChatPanelProps): import("react/jsx-runtime").JSX.Element;
|
24
25
|
export {};
|
@@ -1,6 +1,8 @@
|
|
1
|
+
import { ChatMessage } from "../../types";
|
1
2
|
interface SettingsPanelProps {
|
2
3
|
onClose: () => void;
|
3
4
|
onClearHistory: () => void;
|
5
|
+
history: ChatMessage[];
|
4
6
|
hue: number;
|
5
7
|
onHueChange: (hue: number) => void;
|
6
8
|
hoverIntensity: number;
|
@@ -8,5 +10,5 @@ interface SettingsPanelProps {
|
|
8
10
|
rotateOnHover: boolean;
|
9
11
|
onRotateOnHoverChange: (rotate: boolean) => void;
|
10
12
|
}
|
11
|
-
export declare function SettingsPanel({ onClose, onClearHistory, hue, onHueChange, hoverIntensity, onHoverIntensityChange, rotateOnHover, onRotateOnHoverChange, }: SettingsPanelProps): import("react/jsx-runtime").JSX.Element;
|
13
|
+
export declare function SettingsPanel({ onClose, onClearHistory, history, hue, onHueChange, hoverIntensity, onHoverIntensityChange, rotateOnHover, onRotateOnHoverChange, }: SettingsPanelProps): import("react/jsx-runtime").JSX.Element;
|
12
14
|
export {};
|
@@ -2,6 +2,7 @@ import type { ChatMessage } from "../../types";
|
|
2
2
|
interface MessageListProps {
|
3
3
|
messages: ChatMessage[];
|
4
4
|
sending?: boolean;
|
5
|
+
onSuggestionClick?: (suggestion: string) => void;
|
5
6
|
}
|
6
|
-
export declare function MessageList({ messages, sending }: MessageListProps): import("react/jsx-runtime").JSX.Element;
|
7
|
+
export declare function MessageList({ messages, sending, onSuggestionClick, }: MessageListProps): import("react/jsx-runtime").JSX.Element;
|
7
8
|
export {};
|
package/dist/index.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
+
export { createMockAdapter, createRestAdapter, RestAdapters } from "./adapters";
|
1
2
|
export { BmxChatBot } from "./components/BmxChatBot";
|
2
3
|
export type { BmxChatApiAdapter, ChatMessage, ChatRole } from "./types";
|
3
|
-
export { createMockAdapter, MorphexAdapter, PineconeRAGAdapter, } from "./adapters";
|