@bmx-labs/chat-widget 0.0.1 → 0.0.2

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.
Files changed (38) hide show
  1. package/README.md +11 -16
  2. package/dist/adapters/context/PineconeRAGAdapter.d.ts +58 -23
  3. package/dist/adapters/context/debug.d.ts +11 -0
  4. package/dist/adapters/context/fetchers.d.ts +40 -0
  5. package/dist/adapters/context/index.d.ts +0 -1
  6. package/dist/adapters/context/processing.d.ts +96 -0
  7. package/dist/adapters/index.d.ts +1 -1
  8. package/dist/index.d.ts +1 -1
  9. package/dist/index.js +1 -1
  10. package/dist/types.d.ts +57 -0
  11. package/package.json +10 -9
  12. package/dist/adapters/AnthropicAdapter.d.ts +0 -16
  13. package/dist/adapters/ContextAdapter.d.ts +0 -19
  14. package/dist/adapters/CustomAPIAdapter.d.ts +0 -20
  15. package/dist/adapters/KnowledgeBaseAdapter.d.ts +0 -20
  16. package/dist/adapters/MockAdapter.d.ts +0 -6
  17. package/dist/adapters/MorphexAdapter.d.ts +0 -16
  18. package/dist/adapters/OpenAIAdapter.d.ts +0 -17
  19. package/dist/adapters/RAGAdapter.d.ts +0 -29
  20. package/dist/adapters/RestRAGAdapter.d.ts +0 -9
  21. package/dist/adapters/TestAdapter.d.ts +0 -6
  22. package/dist/adapters/context/ContextAdapter.d.ts +0 -19
  23. package/dist/adapters/context/KnowledgeBaseAdapter.d.ts +0 -20
  24. package/dist/adapters/context/MorphexAdapter.d.ts +0 -16
  25. package/dist/adapters/context/RAGAdapter.d.ts +0 -29
  26. package/dist/adapters/rest.d.ts +0 -7
  27. package/dist/components/LazyComponents.d.ts +0 -3
  28. package/dist/components/Orb.d.ts +0 -8
  29. package/dist/components/OrbButton.d.ts +0 -10
  30. package/dist/components/SimpleIridescence.d.ts +0 -8
  31. package/dist/components/SimpleOrb.d.ts +0 -8
  32. package/dist/components/ogl/DarkVeil.d.ts +0 -11
  33. package/dist/framer.js +0 -1
  34. package/dist/index.js.map +0 -1
  35. package/dist/ogl.js +0 -1
  36. package/dist/styles.css.map +0 -1
  37. package/dist/styles.js.map +0 -1
  38. package/dist/vendors.js +0 -1
package/dist/types.d.ts CHANGED
@@ -28,3 +28,60 @@ export interface SendOptions {
28
28
  export interface BmxChatApiAdapter {
29
29
  sendMessage: (history: ChatMessage[], input: string, options?: SendOptions) => Promise<ChatMessage>;
30
30
  }
31
+ /**
32
+ * Pinecone RAG Adapter Configuration.
33
+ */
34
+ export interface PineconeRAGAdapterConfig {
35
+ openAIApiKey: string;
36
+ pineconeApiKey: string;
37
+ /** Example: https://myindex-abc123.svc.us-east1-aws.pinecone.io */
38
+ pineconeIndexUrl: string;
39
+ namespace?: string;
40
+ topK?: number;
41
+ chatModel?: OpenAIModel;
42
+ embeddingModel?: string;
43
+ openAIBaseURL?: string;
44
+ enableStreaming?: boolean;
45
+ maxContextTokens?: number;
46
+ minScoreThreshold?: number;
47
+ debug?: boolean;
48
+ /**
49
+ * Optional dynamic context provider for live data (e.g., token prices).
50
+ * Return blocks that will be appended to retrieved context before prompting.
51
+ */
52
+ dynamicContext?: (input: string, options?: {
53
+ signal?: AbortSignal;
54
+ }) => Promise<Array<{
55
+ title?: string;
56
+ url?: string;
57
+ text: string;
58
+ }>>;
59
+ }
60
+ export type OpenAIEmbeddingResponse = {
61
+ data: Array<{
62
+ embedding: number[];
63
+ }>;
64
+ };
65
+ export type PineconeQueryMatch = {
66
+ id: string;
67
+ score?: number;
68
+ metadata?: Record<string, unknown>;
69
+ };
70
+ export type OpenAIModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-turbo" | "gpt-3.5-turbo" | "gpt-4" | "gpt-4.1" | "gpt-4.1-mini" | "o1-mini" | "o1-preview";
71
+ /**
72
+ * Typed shape for the subset of OpenAI's Chat Completions response we use.
73
+ */
74
+ export type OpenAIChatCompletionResponse = {
75
+ choices: Array<{
76
+ message?: {
77
+ role?: string;
78
+ content?: string;
79
+ };
80
+ }>;
81
+ };
82
+ /**
83
+ * Lightweight typed result returned by getChatCompletion.
84
+ */
85
+ export type ChatCompletionResult = {
86
+ content: string;
87
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bmx-labs/chat-widget",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "private": false,
5
5
  "description": "BMX Chat Widget for React/Next.js with RAG capabilities",
6
6
  "license": "GNU AGPLv3",
@@ -60,6 +60,13 @@
60
60
  "webpack": "^5.95.0",
61
61
  "webpack-cli": "^5.1.4"
62
62
  },
63
+ "scripts": {
64
+ "build": "webpack --config webpack.config.js --mode=production",
65
+ "build:dev": "webpack --config webpack.config.js --mode=development",
66
+ "dev": "webpack --config webpack.config.js --mode=development --watch",
67
+ "clean": "rm -rf dist",
68
+ "prepublishOnly": "npm run build"
69
+ },
63
70
  "keywords": [
64
71
  "chat-widget",
65
72
  "react",
@@ -68,11 +75,5 @@
68
75
  "rag",
69
76
  "pinecone",
70
77
  "bmx"
71
- ],
72
- "scripts": {
73
- "build": "webpack --config webpack.config.js --mode=production",
74
- "build:dev": "webpack --config webpack.config.js --mode=development",
75
- "dev": "webpack --config webpack.config.js --mode=development --watch",
76
- "clean": "rm -rf dist"
77
- }
78
- }
78
+ ]
79
+ }
@@ -1,16 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- interface AnthropicAdapterConfig {
3
- apiKey: string;
4
- model?: string;
5
- baseURL?: string;
6
- }
7
- export declare class AnthropicAdapter implements BmxChatApiAdapter {
8
- private apiKey;
9
- private model;
10
- private baseURL;
11
- constructor(config: AnthropicAdapterConfig);
12
- sendMessage(history: ChatMessage[], input: string, options?: {
13
- signal?: AbortSignal;
14
- }): Promise<ChatMessage>;
15
- }
16
- export {};
@@ -1,19 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export interface ContextAdapterConfig {
3
- apiKey: string;
4
- model?: string;
5
- baseURL?: string;
6
- contextData?: string;
7
- contextPrompt?: string;
8
- }
9
- export declare class ContextAdapter implements BmxChatApiAdapter {
10
- private apiKey;
11
- private model;
12
- private baseURL;
13
- private contextData;
14
- private contextPrompt;
15
- constructor(config: ContextAdapterConfig);
16
- sendMessage(history: ChatMessage[], input: string, options?: {
17
- signal?: AbortSignal;
18
- }): Promise<ChatMessage>;
19
- }
@@ -1,20 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- interface CustomAPIAdapterConfig {
3
- endpoint: string;
4
- apiKey?: string;
5
- headers?: Record<string, string>;
6
- transformRequest?: (history: ChatMessage[], input: string) => any;
7
- transformResponse?: (response: any) => string;
8
- }
9
- export declare class CustomAPIAdapter implements BmxChatApiAdapter {
10
- private endpoint;
11
- private apiKey?;
12
- private headers;
13
- private transformRequest;
14
- private transformResponse;
15
- constructor(config: CustomAPIAdapterConfig);
16
- sendMessage(history: ChatMessage[], input: string, options?: {
17
- signal?: AbortSignal;
18
- }): Promise<ChatMessage>;
19
- }
20
- export {};
@@ -1,20 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export interface KnowledgeBaseAdapterConfig {
3
- apiKey: string;
4
- model?: string;
5
- baseURL?: string;
6
- knowledgeBase: Record<string, string>;
7
- maxContextLength?: number;
8
- }
9
- export declare class KnowledgeBaseAdapter implements BmxChatApiAdapter {
10
- private apiKey;
11
- private model;
12
- private baseURL;
13
- private knowledgeBase;
14
- private maxContextLength;
15
- constructor(config: KnowledgeBaseAdapterConfig);
16
- private findRelevantKnowledge;
17
- sendMessage(history: ChatMessage[], input: string, options?: {
18
- signal?: AbortSignal;
19
- }): Promise<ChatMessage>;
20
- }
@@ -1,6 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export declare class MockAdapter implements BmxChatApiAdapter {
3
- sendMessage(history: ChatMessage[], input: string, options?: {
4
- signal?: AbortSignal;
5
- }): Promise<ChatMessage>;
6
- }
@@ -1,16 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export type OpenAIModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-turbo" | "gpt-3.5-turbo" | "gpt-4" | "o1-mini" | "o1-preview";
3
- export interface MorphexAdapterConfig {
4
- apiKey: string;
5
- model?: OpenAIModel;
6
- baseURL?: string;
7
- }
8
- export declare class MorphexAdapter implements BmxChatApiAdapter {
9
- private apiKey;
10
- private model;
11
- private baseURL;
12
- constructor(config: MorphexAdapterConfig);
13
- sendMessage(history: ChatMessage[], input: string, options?: {
14
- signal?: AbortSignal;
15
- }): Promise<ChatMessage>;
16
- }
@@ -1,17 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export type OpenAIModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-turbo" | "gpt-3.5-turbo" | "gpt-4" | "o1-mini" | "o1-preview";
3
- interface OpenAIAdapterConfig {
4
- apiKey: string;
5
- model?: OpenAIModel;
6
- baseURL?: string;
7
- }
8
- export declare class OpenAIAdapter implements BmxChatApiAdapter {
9
- private apiKey;
10
- private model;
11
- private baseURL;
12
- constructor(config: OpenAIAdapterConfig);
13
- sendMessage(history: ChatMessage[], input: string, options?: {
14
- signal?: AbortSignal;
15
- }): Promise<ChatMessage>;
16
- }
17
- export {};
@@ -1,29 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export interface Document {
3
- id: string;
4
- content: string;
5
- metadata?: Record<string, any>;
6
- }
7
- export interface RAGAdapterConfig {
8
- apiKey: string;
9
- model?: string;
10
- baseURL?: string;
11
- documents: Document[];
12
- chunkSize?: number;
13
- topK?: number;
14
- }
15
- export declare class RAGAdapter implements BmxChatApiAdapter {
16
- private apiKey;
17
- private model;
18
- private baseURL;
19
- private documents;
20
- private chunkSize;
21
- private topK;
22
- constructor(config: RAGAdapterConfig);
23
- private chunkText;
24
- private simpleSimilarity;
25
- private retrieveRelevantChunks;
26
- sendMessage(history: ChatMessage[], input: string, options?: {
27
- signal?: AbortSignal;
28
- }): Promise<ChatMessage>;
29
- }
@@ -1,9 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export interface RestRAGAdapterConfig {
3
- baseURL?: string;
4
- }
5
- export declare class RestRAGAdapter implements BmxChatApiAdapter {
6
- private baseURL;
7
- constructor(config?: RestRAGAdapterConfig);
8
- sendMessage(history: ChatMessage[], input: string): Promise<ChatMessage>;
9
- }
@@ -1,6 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../types";
2
- export declare class TestAdapter implements BmxChatApiAdapter {
3
- sendMessage(history: ChatMessage[], input: string, options?: {
4
- signal?: AbortSignal;
5
- }): Promise<ChatMessage>;
6
- }
@@ -1,19 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../../types";
2
- export interface ContextAdapterConfig {
3
- apiKey: string;
4
- model?: string;
5
- baseURL?: string;
6
- contextData?: string;
7
- contextPrompt?: string;
8
- }
9
- export declare class ContextAdapter implements BmxChatApiAdapter {
10
- private apiKey;
11
- private model;
12
- private baseURL;
13
- private contextData;
14
- private contextPrompt;
15
- constructor(config: ContextAdapterConfig);
16
- sendMessage(history: ChatMessage[], input: string, options?: {
17
- signal?: AbortSignal;
18
- }): Promise<ChatMessage>;
19
- }
@@ -1,20 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../../types";
2
- export interface KnowledgeBaseAdapterConfig {
3
- apiKey: string;
4
- model?: string;
5
- baseURL?: string;
6
- knowledgeBase: Record<string, string>;
7
- maxContextLength?: number;
8
- }
9
- export declare class KnowledgeBaseAdapter implements BmxChatApiAdapter {
10
- private apiKey;
11
- private model;
12
- private baseURL;
13
- private knowledgeBase;
14
- private maxContextLength;
15
- constructor(config: KnowledgeBaseAdapterConfig);
16
- private findRelevantKnowledge;
17
- sendMessage(history: ChatMessage[], input: string, options?: {
18
- signal?: AbortSignal;
19
- }): Promise<ChatMessage>;
20
- }
@@ -1,16 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../../types";
2
- export type OpenAIModel = "gpt-4o-mini" | "gpt-4o" | "gpt-4-turbo" | "gpt-3.5-turbo" | "gpt-4" | "o1-mini" | "o1-preview";
3
- export interface MorphexAdapterConfig {
4
- apiKey: string;
5
- model?: OpenAIModel;
6
- baseURL?: string;
7
- }
8
- export declare class MorphexAdapter implements BmxChatApiAdapter {
9
- private apiKey;
10
- private model;
11
- private baseURL;
12
- constructor(config: MorphexAdapterConfig);
13
- sendMessage(history: ChatMessage[], input: string, options?: {
14
- signal?: AbortSignal;
15
- }): Promise<ChatMessage>;
16
- }
@@ -1,29 +0,0 @@
1
- import type { BmxChatApiAdapter, ChatMessage } from "../../types";
2
- export interface Document {
3
- id: string;
4
- content: string;
5
- metadata?: Record<string, any>;
6
- }
7
- export interface RAGAdapterConfig {
8
- apiKey: string;
9
- model?: string;
10
- baseURL?: string;
11
- documents: Document[];
12
- chunkSize?: number;
13
- topK?: number;
14
- }
15
- export declare class RAGAdapter implements BmxChatApiAdapter {
16
- private apiKey;
17
- private model;
18
- private baseURL;
19
- private documents;
20
- private chunkSize;
21
- private topK;
22
- constructor(config: RAGAdapterConfig);
23
- private chunkText;
24
- private simpleSimilarity;
25
- private retrieveRelevantChunks;
26
- sendMessage(history: ChatMessage[], input: string, options?: {
27
- signal?: AbortSignal;
28
- }): Promise<ChatMessage>;
29
- }
@@ -1,7 +0,0 @@
1
- import type { BmxChatApiAdapter } from "../types";
2
- export interface RestAdapterOptions {
3
- baseUrl: string;
4
- path?: string;
5
- headers?: Record<string, string>;
6
- }
7
- export declare function createRestApiAdapter(options: RestAdapterOptions): BmxChatApiAdapter;
@@ -1,3 +0,0 @@
1
- export declare const LazyOrb: import("react").LazyExoticComponent<typeof import("./ogl/Orb").default>;
2
- export declare const LazyIridescence: import("react").LazyExoticComponent<typeof import("./ogl/Iridescence").default>;
3
- export declare const LazyReactMarkdown: import("react").LazyExoticComponent<typeof import("react-markdown").default>;
@@ -1,8 +0,0 @@
1
- interface OrbProps {
2
- hue?: number;
3
- hoverIntensity?: number;
4
- rotateOnHover?: boolean;
5
- forceHoverState?: boolean;
6
- }
7
- export default function Orb({ hue, hoverIntensity, rotateOnHover, forceHoverState, }: OrbProps): import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,10 +0,0 @@
1
- interface OrbButtonProps {
2
- open: boolean;
3
- onClick: () => void;
4
- hue?: number;
5
- hoverIntensity?: number;
6
- rotateOnHover?: boolean;
7
- forceHoverState?: boolean;
8
- }
9
- export declare function OrbButton({ open, onClick, hue, hoverIntensity, rotateOnHover, forceHoverState, }: OrbButtonProps): import("react/jsx-runtime").JSX.Element;
10
- export {};
@@ -1,8 +0,0 @@
1
- interface SimpleIridescenceProps {
2
- color?: [number, number, number];
3
- mouseReact?: boolean;
4
- amplitude?: number;
5
- speed?: number;
6
- }
7
- export declare function SimpleIridescence({ color, mouseReact, amplitude, speed, }: SimpleIridescenceProps): import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,8 +0,0 @@
1
- interface SimpleOrbProps {
2
- hue?: number;
3
- hoverIntensity?: number;
4
- rotateOnHover?: boolean;
5
- forceHoverState?: boolean;
6
- }
7
- export declare function SimpleOrb({ hue, hoverIntensity, rotateOnHover, forceHoverState, }: SimpleOrbProps): import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,11 +0,0 @@
1
- type Props = {
2
- hueShift?: number;
3
- noiseIntensity?: number;
4
- scanlineIntensity?: number;
5
- speed?: number;
6
- scanlineFrequency?: number;
7
- warpAmount?: number;
8
- resolutionScale?: number;
9
- };
10
- export default function DarkVeil({ hueShift, noiseIntensity, scanlineIntensity, speed, scanlineFrequency, warpAmount, resolutionScale, }: Props): import("react/jsx-runtime").JSX.Element;
11
- export {};