@retrivora-ai/rag-engine 0.1.7 → 0.1.9
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/dist/{ChromaDBProvider-QNI7UCX4.mjs → ChromaDBProvider-T7TK3ONZ.mjs} +2 -2
- package/dist/{MilvusProvider-OO6QGZDZ.mjs → MilvusProvider-Y5FV5EAE.mjs} +2 -2
- package/dist/{MongoDBProvider-WWVJG3WT.mjs → MongoDBProvider-QHMGD2LZ.mjs} +2 -2
- package/dist/{PineconeProvider-ZRAFNFEC.mjs → PineconeProvider-A47MRRYJ.mjs} +2 -2
- package/dist/{PostgreSQLProvider-ZNXA67IM.mjs → PostgreSQLProvider-PJ5ER5Z4.mjs} +1 -1
- package/dist/{QdrantProvider-VAED5VA7.mjs → QdrantProvider-OLPJK7CY.mjs} +2 -2
- package/dist/{RagConfig-hBGXJmSx.d.mts → RagConfig-D_rSf8ep.d.mts} +1 -1
- package/dist/{RagConfig-hBGXJmSx.d.ts → RagConfig-D_rSf8ep.d.ts} +1 -1
- package/dist/{RedisProvider-ASONNYBI.mjs → RedisProvider-ANEJ3BHR.mjs} +2 -2
- package/dist/UniversalVectorProvider-QJIV2AJJ.mjs +9 -0
- package/dist/{WeaviateProvider-PSDCUGC7.mjs → WeaviateProvider-WIK2QN23.mjs} +2 -2
- package/dist/{chunk-7YQWGERZ.mjs → chunk-2VR5ZMXV.mjs} +740 -193
- package/dist/{chunk-QEYVWVT5.mjs → chunk-5HXNKSCR.mjs} +1 -1
- package/dist/{chunk-ZM6TYIDH.mjs → chunk-BMHJTWSU.mjs} +4 -2
- package/dist/{chunk-UKDXCXW7.mjs → chunk-EDLTMSNY.mjs} +1 -1
- package/dist/{chunk-I4E63NIC.mjs → chunk-FWCSY2DS.mjs} +14 -1
- package/dist/{chunk-VPNRDXIA.mjs → chunk-HOMXEE3M.mjs} +17 -11
- package/dist/{chunk-V75V7BT2.mjs → chunk-RUKZC3ON.mjs} +3 -3
- package/dist/{chunk-7NXI6ZWX.mjs → chunk-VEJNRS4B.mjs} +9 -6
- package/dist/{chunk-HUGLYKD6.mjs → chunk-VKE5ZW7Y.mjs} +28 -10
- package/dist/chunk-VV2ML6TM.mjs +156 -0
- package/dist/{chunk-CWQQHAF6.mjs → chunk-W2PQR3UK.mjs} +4 -6
- package/dist/handlers/index.d.mts +2 -2
- package/dist/handlers/index.d.ts +2 -2
- package/dist/handlers/index.js +877 -625
- package/dist/handlers/index.mjs +3 -4
- package/dist/index-BJ8CUArE.d.mts +114 -0
- package/dist/index-DtNprGGj.d.ts +114 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +67 -58
- package/dist/index.mjs +74 -47
- package/dist/server.d.mts +601 -17
- package/dist/server.d.ts +601 -17
- package/dist/server.js +1426 -708
- package/dist/server.mjs +429 -18
- package/package.json +11 -2
- package/src/app/constants.tsx +220 -0
- package/src/app/page.tsx +193 -363
- package/src/app/types.ts +30 -0
- package/src/components/ChatWindow.tsx +3 -11
- package/src/config/ConfigBuilder.ts +373 -0
- package/src/config/EmbeddingStrategy.ts +147 -0
- package/src/config/serverConfig.ts +51 -18
- package/src/core/ConfigValidator.ts +67 -50
- package/src/core/Pipeline.ts +28 -26
- package/src/core/PluginManager.ts +277 -0
- package/src/core/ProviderHealthCheck.ts +75 -139
- package/src/core/ProviderRegistry.ts +38 -15
- package/src/providers/vectordb/ChromaDBProvider.ts +37 -12
- package/src/providers/vectordb/MilvusProvider.ts +25 -10
- package/src/providers/vectordb/MultiTablePostgresProvider.ts +164 -0
- package/src/providers/vectordb/PineconeProvider.ts +17 -2
- package/src/providers/vectordb/QdrantProvider.ts +3 -6
- package/src/providers/vectordb/RedisProvider.ts +34 -11
- package/src/providers/vectordb/UniversalVectorProvider.ts +220 -0
- package/src/providers/vectordb/WeaviateProvider.ts +17 -10
- package/src/server.ts +29 -10
- package/dist/LLMFactory-JFOY2V4X.mjs +0 -8
- package/dist/chunk-JI6VD5TJ.mjs +0 -387
- package/dist/index-Bx182KKn.d.ts +0 -64
- package/dist/index-Ck2pt7-8.d.mts +0 -64
- package/src/test-refactor.ts +0 -59
package/dist/handlers/index.mjs
CHANGED
|
@@ -3,10 +3,9 @@ import {
|
|
|
3
3
|
createHealthHandler,
|
|
4
4
|
createIngestHandler,
|
|
5
5
|
createUploadHandler
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-I4E63NIC.mjs";
|
|
6
|
+
} from "../chunk-2VR5ZMXV.mjs";
|
|
7
|
+
import "../chunk-EDLTMSNY.mjs";
|
|
8
|
+
import "../chunk-FWCSY2DS.mjs";
|
|
10
9
|
export {
|
|
11
10
|
createChatHandler,
|
|
12
11
|
createHealthHandler,
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { c as VectorDBConfig, L as LLMConfig, E as EmbeddingConfig, a as RagConfig, C as ChatResponse } from './RagConfig-D_rSf8ep.mjs';
|
|
2
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ProviderHealthCheck.ts — Pre-flight validation for vector DB and LLM providers.
|
|
6
|
+
*
|
|
7
|
+
* Performs connectivity tests, credential validation, and capability checks
|
|
8
|
+
* before initializing providers.
|
|
9
|
+
*
|
|
10
|
+
* Note: Option keys used here mirror each Provider constructor's expected keys.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface HealthCheckResult {
|
|
14
|
+
healthy: boolean;
|
|
15
|
+
provider: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
capabilities?: Record<string, unknown>;
|
|
18
|
+
error?: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
}
|
|
21
|
+
declare class ProviderHealthCheck {
|
|
22
|
+
/**
|
|
23
|
+
* Validates vector database configuration before initialization.
|
|
24
|
+
*/
|
|
25
|
+
static checkVectorProvider(config: VectorDBConfig): Promise<HealthCheckResult>;
|
|
26
|
+
private static checkPinecone;
|
|
27
|
+
private static checkPostgres;
|
|
28
|
+
private static checkMongoDB;
|
|
29
|
+
/**
|
|
30
|
+
* Milvus health check — uses baseUrl/uri (matching MilvusProvider constructor).
|
|
31
|
+
*/
|
|
32
|
+
private static checkMilvus;
|
|
33
|
+
/**
|
|
34
|
+
* Qdrant health check — uses baseUrl (matching QdrantProvider constructor).
|
|
35
|
+
*/
|
|
36
|
+
private static checkQdrant;
|
|
37
|
+
/**
|
|
38
|
+
* ChromaDB health check — uses baseUrl/host (matching ChromaDBProvider constructor).
|
|
39
|
+
*/
|
|
40
|
+
private static checkChromaDB;
|
|
41
|
+
/**
|
|
42
|
+
* Redis health check — Redis is TCP-only (no HTTP endpoint).
|
|
43
|
+
* We report healthy=true with a note; actual connectivity is validated at first operation.
|
|
44
|
+
*/
|
|
45
|
+
private static checkRedis;
|
|
46
|
+
/**
|
|
47
|
+
* Weaviate health check — uses baseUrl/url (matching WeaviateProvider constructor).
|
|
48
|
+
*/
|
|
49
|
+
private static checkWeaviate;
|
|
50
|
+
private static checkRestAPI;
|
|
51
|
+
/**
|
|
52
|
+
* Validates LLM provider configuration.
|
|
53
|
+
*/
|
|
54
|
+
static checkLLMProvider(config: LLMConfig): Promise<HealthCheckResult>;
|
|
55
|
+
private static checkOpenAI;
|
|
56
|
+
private static checkAnthropic;
|
|
57
|
+
private static checkOllama;
|
|
58
|
+
private static checkLLMRestAPI;
|
|
59
|
+
/**
|
|
60
|
+
* Runs comprehensive health checks on all configured providers in parallel.
|
|
61
|
+
*/
|
|
62
|
+
static checkAll(vectorDbConfig: VectorDBConfig, llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): Promise<{
|
|
63
|
+
vectorDb: HealthCheckResult;
|
|
64
|
+
llm: HealthCheckResult;
|
|
65
|
+
embedding?: HealthCheckResult;
|
|
66
|
+
allHealthy: boolean;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* createChatHandler — factory that returns a Next.js App Router POST handler
|
|
72
|
+
*/
|
|
73
|
+
declare function createChatHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
74
|
+
error: string;
|
|
75
|
+
}> | NextResponse<ChatResponse>>;
|
|
76
|
+
/**
|
|
77
|
+
* createIngestHandler — factory for the document ingestion endpoint.
|
|
78
|
+
*/
|
|
79
|
+
declare function createIngestHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
80
|
+
error: string;
|
|
81
|
+
}> | NextResponse<{
|
|
82
|
+
results: {
|
|
83
|
+
docId: string | number;
|
|
84
|
+
chunksIngested: number;
|
|
85
|
+
}[];
|
|
86
|
+
}>>;
|
|
87
|
+
/**
|
|
88
|
+
* createHealthHandler — factory for the health-check endpoint.
|
|
89
|
+
*/
|
|
90
|
+
declare function createHealthHandler(config?: Partial<RagConfig>): () => Promise<NextResponse<{
|
|
91
|
+
timestamp: string;
|
|
92
|
+
vectorDb: HealthCheckResult;
|
|
93
|
+
llm: HealthCheckResult;
|
|
94
|
+
embedding?: HealthCheckResult;
|
|
95
|
+
allHealthy: boolean;
|
|
96
|
+
status: string;
|
|
97
|
+
}> | NextResponse<{
|
|
98
|
+
status: string;
|
|
99
|
+
error: string;
|
|
100
|
+
}>>;
|
|
101
|
+
/**
|
|
102
|
+
* createUploadHandler — factory for the file upload ingestion endpoint.
|
|
103
|
+
*/
|
|
104
|
+
declare function createUploadHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
105
|
+
error: string;
|
|
106
|
+
}> | NextResponse<{
|
|
107
|
+
message: string;
|
|
108
|
+
results: {
|
|
109
|
+
docId: string | number;
|
|
110
|
+
chunksIngested: number;
|
|
111
|
+
}[];
|
|
112
|
+
}>>;
|
|
113
|
+
|
|
114
|
+
export { type HealthCheckResult as H, ProviderHealthCheck as P, createHealthHandler as a, createIngestHandler as b, createChatHandler as c, createUploadHandler as d };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { c as VectorDBConfig, L as LLMConfig, E as EmbeddingConfig, a as RagConfig, C as ChatResponse } from './RagConfig-D_rSf8ep.js';
|
|
2
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* ProviderHealthCheck.ts — Pre-flight validation for vector DB and LLM providers.
|
|
6
|
+
*
|
|
7
|
+
* Performs connectivity tests, credential validation, and capability checks
|
|
8
|
+
* before initializing providers.
|
|
9
|
+
*
|
|
10
|
+
* Note: Option keys used here mirror each Provider constructor's expected keys.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
interface HealthCheckResult {
|
|
14
|
+
healthy: boolean;
|
|
15
|
+
provider: string;
|
|
16
|
+
version?: string;
|
|
17
|
+
capabilities?: Record<string, unknown>;
|
|
18
|
+
error?: string;
|
|
19
|
+
timestamp: number;
|
|
20
|
+
}
|
|
21
|
+
declare class ProviderHealthCheck {
|
|
22
|
+
/**
|
|
23
|
+
* Validates vector database configuration before initialization.
|
|
24
|
+
*/
|
|
25
|
+
static checkVectorProvider(config: VectorDBConfig): Promise<HealthCheckResult>;
|
|
26
|
+
private static checkPinecone;
|
|
27
|
+
private static checkPostgres;
|
|
28
|
+
private static checkMongoDB;
|
|
29
|
+
/**
|
|
30
|
+
* Milvus health check — uses baseUrl/uri (matching MilvusProvider constructor).
|
|
31
|
+
*/
|
|
32
|
+
private static checkMilvus;
|
|
33
|
+
/**
|
|
34
|
+
* Qdrant health check — uses baseUrl (matching QdrantProvider constructor).
|
|
35
|
+
*/
|
|
36
|
+
private static checkQdrant;
|
|
37
|
+
/**
|
|
38
|
+
* ChromaDB health check — uses baseUrl/host (matching ChromaDBProvider constructor).
|
|
39
|
+
*/
|
|
40
|
+
private static checkChromaDB;
|
|
41
|
+
/**
|
|
42
|
+
* Redis health check — Redis is TCP-only (no HTTP endpoint).
|
|
43
|
+
* We report healthy=true with a note; actual connectivity is validated at first operation.
|
|
44
|
+
*/
|
|
45
|
+
private static checkRedis;
|
|
46
|
+
/**
|
|
47
|
+
* Weaviate health check — uses baseUrl/url (matching WeaviateProvider constructor).
|
|
48
|
+
*/
|
|
49
|
+
private static checkWeaviate;
|
|
50
|
+
private static checkRestAPI;
|
|
51
|
+
/**
|
|
52
|
+
* Validates LLM provider configuration.
|
|
53
|
+
*/
|
|
54
|
+
static checkLLMProvider(config: LLMConfig): Promise<HealthCheckResult>;
|
|
55
|
+
private static checkOpenAI;
|
|
56
|
+
private static checkAnthropic;
|
|
57
|
+
private static checkOllama;
|
|
58
|
+
private static checkLLMRestAPI;
|
|
59
|
+
/**
|
|
60
|
+
* Runs comprehensive health checks on all configured providers in parallel.
|
|
61
|
+
*/
|
|
62
|
+
static checkAll(vectorDbConfig: VectorDBConfig, llmConfig: LLMConfig, embeddingConfig?: EmbeddingConfig): Promise<{
|
|
63
|
+
vectorDb: HealthCheckResult;
|
|
64
|
+
llm: HealthCheckResult;
|
|
65
|
+
embedding?: HealthCheckResult;
|
|
66
|
+
allHealthy: boolean;
|
|
67
|
+
}>;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* createChatHandler — factory that returns a Next.js App Router POST handler
|
|
72
|
+
*/
|
|
73
|
+
declare function createChatHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
74
|
+
error: string;
|
|
75
|
+
}> | NextResponse<ChatResponse>>;
|
|
76
|
+
/**
|
|
77
|
+
* createIngestHandler — factory for the document ingestion endpoint.
|
|
78
|
+
*/
|
|
79
|
+
declare function createIngestHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
80
|
+
error: string;
|
|
81
|
+
}> | NextResponse<{
|
|
82
|
+
results: {
|
|
83
|
+
docId: string | number;
|
|
84
|
+
chunksIngested: number;
|
|
85
|
+
}[];
|
|
86
|
+
}>>;
|
|
87
|
+
/**
|
|
88
|
+
* createHealthHandler — factory for the health-check endpoint.
|
|
89
|
+
*/
|
|
90
|
+
declare function createHealthHandler(config?: Partial<RagConfig>): () => Promise<NextResponse<{
|
|
91
|
+
timestamp: string;
|
|
92
|
+
vectorDb: HealthCheckResult;
|
|
93
|
+
llm: HealthCheckResult;
|
|
94
|
+
embedding?: HealthCheckResult;
|
|
95
|
+
allHealthy: boolean;
|
|
96
|
+
status: string;
|
|
97
|
+
}> | NextResponse<{
|
|
98
|
+
status: string;
|
|
99
|
+
error: string;
|
|
100
|
+
}>>;
|
|
101
|
+
/**
|
|
102
|
+
* createUploadHandler — factory for the file upload ingestion endpoint.
|
|
103
|
+
*/
|
|
104
|
+
declare function createUploadHandler(config?: Partial<RagConfig>): (req: NextRequest) => Promise<NextResponse<{
|
|
105
|
+
error: string;
|
|
106
|
+
}> | NextResponse<{
|
|
107
|
+
message: string;
|
|
108
|
+
results: {
|
|
109
|
+
docId: string | number;
|
|
110
|
+
chunksIngested: number;
|
|
111
|
+
}[];
|
|
112
|
+
}>>;
|
|
113
|
+
|
|
114
|
+
export { type HealthCheckResult as H, ProviderHealthCheck as P, createHealthHandler as a, createIngestHandler as b, createChatHandler as c, createUploadHandler as d };
|
package/dist/index.d.mts
CHANGED
|
@@ -2,8 +2,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React$1, { ReactNode } from 'react';
|
|
3
3
|
import { C as ChatMessage } from './DocumentChunker-BEyzadsv.mjs';
|
|
4
4
|
export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-BEyzadsv.mjs';
|
|
5
|
-
import { V as VectorMatch, U as UIConfig } from './RagConfig-
|
|
6
|
-
export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-
|
|
5
|
+
import { V as VectorMatch, U as UIConfig } from './RagConfig-D_rSf8ep.mjs';
|
|
6
|
+
export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-D_rSf8ep.mjs';
|
|
7
7
|
|
|
8
8
|
interface ChatWidgetProps {
|
|
9
9
|
/** Position of the floating button. Defaults to bottom-right. */
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import React$1, { ReactNode } from 'react';
|
|
3
3
|
import { C as ChatMessage } from './DocumentChunker-BEyzadsv.js';
|
|
4
4
|
export { a as ChatOptions, b as Chunk, c as ChunkOptions, E as EmbedOptions, I as ILLMProvider } from './DocumentChunker-BEyzadsv.js';
|
|
5
|
-
import { V as VectorMatch, U as UIConfig } from './RagConfig-
|
|
6
|
-
export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-
|
|
5
|
+
import { V as VectorMatch, U as UIConfig } from './RagConfig-D_rSf8ep.js';
|
|
6
|
+
export { C as ChatResponse, E as EmbeddingConfig, I as IngestDocument, L as LLMConfig, R as RAGConfig, a as RagConfig, b as UpsertDocument, c as VectorDBConfig } from './RagConfig-D_rSf8ep.js';
|
|
7
7
|
|
|
8
8
|
interface ChatWidgetProps {
|
|
9
9
|
/** Position of the floating button. Defaults to bottom-right. */
|
package/dist/index.js
CHANGED
|
@@ -56,11 +56,11 @@ module.exports = __toCommonJS(index_exports);
|
|
|
56
56
|
|
|
57
57
|
// src/components/ChatWidget.tsx
|
|
58
58
|
var import_react6 = require("react");
|
|
59
|
-
var
|
|
59
|
+
var import_lucide_react5 = require("lucide-react");
|
|
60
60
|
|
|
61
61
|
// src/components/ChatWindow.tsx
|
|
62
62
|
var import_react5 = require("react");
|
|
63
|
-
var
|
|
63
|
+
var import_lucide_react4 = require("lucide-react");
|
|
64
64
|
|
|
65
65
|
// src/components/MessageBubble.tsx
|
|
66
66
|
var import_react2 = __toESM(require("react"));
|
|
@@ -335,8 +335,25 @@ function useRagChat(projectId, options = {}) {
|
|
|
335
335
|
};
|
|
336
336
|
}
|
|
337
337
|
|
|
338
|
+
// src/app/constants.tsx
|
|
339
|
+
var import_lucide_react3 = require("lucide-react");
|
|
340
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
341
|
+
var CHAT_SUGGESTIONS = [
|
|
342
|
+
"What can you help me with?",
|
|
343
|
+
"Summarise the key topics",
|
|
344
|
+
"Show me an example"
|
|
345
|
+
];
|
|
346
|
+
var BORDER_RADIUS_MAP = {
|
|
347
|
+
none: "rounded-none",
|
|
348
|
+
sm: "rounded-sm",
|
|
349
|
+
md: "rounded-md",
|
|
350
|
+
lg: "rounded-lg",
|
|
351
|
+
xl: "rounded-xl",
|
|
352
|
+
full: "rounded-3xl"
|
|
353
|
+
};
|
|
354
|
+
|
|
338
355
|
// src/components/ChatWindow.tsx
|
|
339
|
-
var
|
|
356
|
+
var import_jsx_runtime5 = (
|
|
340
357
|
// eslint-disable-next-line @next/next/no-img-element
|
|
341
358
|
require("react/jsx-runtime")
|
|
342
359
|
);
|
|
@@ -378,87 +395,79 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
378
395
|
clear();
|
|
379
396
|
};
|
|
380
397
|
const isEmpty = messages.length === 0;
|
|
381
|
-
const
|
|
382
|
-
none: "rounded-none",
|
|
383
|
-
sm: "rounded-sm",
|
|
384
|
-
md: "rounded-md",
|
|
385
|
-
lg: "rounded-lg",
|
|
386
|
-
xl: "rounded-xl",
|
|
387
|
-
full: "rounded-3xl"
|
|
388
|
-
};
|
|
389
|
-
const currentRadius = borderRadiusMap[ui.borderRadius || "xl"];
|
|
398
|
+
const currentRadius = BORDER_RADIUS_MAP[ui.borderRadius || "xl"];
|
|
390
399
|
const isGlass = ui.visualStyle !== "solid";
|
|
391
|
-
return /* @__PURE__ */ (0,
|
|
400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
392
401
|
"div",
|
|
393
402
|
{
|
|
394
403
|
className: `flex flex-col border border-slate-200 dark:border-white/10 shadow-2xl transition-all duration-300 ${currentRadius} ${isGlass ? "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl" : "bg-white dark:bg-[#0f0f1a]"} ${className}`,
|
|
395
404
|
style: __spreadValues({ "--primary": ui.primaryColor, "--accent": ui.accentColor }, style),
|
|
396
405
|
children: [
|
|
397
|
-
/* @__PURE__ */ (0,
|
|
406
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
398
407
|
"div",
|
|
399
408
|
{
|
|
400
409
|
className: "flex items-center justify-between px-5 py-4 border-b border-slate-200 dark:border-white/10",
|
|
401
410
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}15, ${ui.accentColor}10)` },
|
|
402
411
|
children: [
|
|
403
|
-
/* @__PURE__ */ (0,
|
|
404
|
-
ui.logoUrl ? /* @__PURE__ */ (0,
|
|
412
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
413
|
+
ui.logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("img", { src: ui.logoUrl, alt: "logo", className: "w-8 h-8 rounded-lg object-cover" }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
405
414
|
"div",
|
|
406
415
|
{
|
|
407
416
|
className: `w-9 h-9 flex items-center justify-center shadow-md ${ui.borderRadius === "full" ? "rounded-full" : "rounded-xl"}`,
|
|
408
417
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
409
|
-
children: /* @__PURE__ */ (0,
|
|
418
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.Bot, { className: "w-5 h-5 text-white" })
|
|
410
419
|
}
|
|
411
420
|
),
|
|
412
|
-
/* @__PURE__ */ (0,
|
|
413
|
-
/* @__PURE__ */ (0,
|
|
414
|
-
ui.poweredBy && /* @__PURE__ */ (0,
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
422
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("h2", { className: "text-slate-900 dark:text-white font-semibold text-sm leading-tight", children: ui.title }),
|
|
423
|
+
ui.poweredBy && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-slate-500 dark:text-white/40 text-[11px] leading-tight", children: `Powered by ${ui.poweredBy}` })
|
|
415
424
|
] })
|
|
416
425
|
] }),
|
|
417
|
-
/* @__PURE__ */ (0,
|
|
418
|
-
/* @__PURE__ */ (0,
|
|
419
|
-
/* @__PURE__ */ (0,
|
|
426
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
427
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("span", { className: "flex items-center gap-1 text-[10px] text-emerald-500 dark:text-emerald-400", children: [
|
|
428
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "w-1.5 h-1.5 rounded-full bg-emerald-500 dark:bg-emerald-400 animate-pulse" }),
|
|
420
429
|
"Online"
|
|
421
430
|
] }),
|
|
422
|
-
mounted && messages.length > 0 && /* @__PURE__ */ (0,
|
|
431
|
+
mounted && messages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
423
432
|
"button",
|
|
424
433
|
{
|
|
425
434
|
onClick: clearHistory,
|
|
426
435
|
title: "Clear conversation",
|
|
427
436
|
className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer",
|
|
428
|
-
children: /* @__PURE__ */ (0,
|
|
437
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.Trash2, { className: "w-3.5 h-3.5" })
|
|
429
438
|
}
|
|
430
439
|
),
|
|
431
|
-
showClose && onClose && /* @__PURE__ */ (0,
|
|
440
|
+
showClose && onClose && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
432
441
|
"button",
|
|
433
442
|
{
|
|
434
443
|
onClick: onClose,
|
|
435
444
|
title: "Close chat",
|
|
436
445
|
className: "w-7 h-7 rounded-lg flex items-center justify-center text-slate-400 hover:text-slate-600 dark:text-white/40 dark:hover:text-white/70 hover:bg-slate-100 dark:hover:bg-white/10 transition-all cursor-pointer",
|
|
437
|
-
children: /* @__PURE__ */ (0,
|
|
446
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.X, { className: "w-4 h-4" })
|
|
438
447
|
}
|
|
439
448
|
)
|
|
440
449
|
] })
|
|
441
450
|
]
|
|
442
451
|
}
|
|
443
452
|
),
|
|
444
|
-
/* @__PURE__ */ (0,
|
|
453
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex-1 overflow-y-auto px-4 py-4 space-y-5 scrollbar-thin scrollbar-thumb-slate-200 dark:scrollbar-thumb-white/10 scrollbar-track-transparent min-h-0 bg-slate-50 dark:bg-transparent", children: [
|
|
445
454
|
!mounted || isEmpty ? (
|
|
446
455
|
/* Welcome state */
|
|
447
|
-
/* @__PURE__ */ (0,
|
|
448
|
-
/* @__PURE__ */ (0,
|
|
456
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "h-full flex flex-col items-center justify-center text-center gap-4 px-6 py-12", children: [
|
|
457
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
449
458
|
"div",
|
|
450
459
|
{
|
|
451
460
|
className: `w-16 h-16 flex items-center justify-center shadow-lg ${ui.borderRadius === "full" ? "rounded-full" : "rounded-2xl"}`,
|
|
452
461
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
453
|
-
children: /* @__PURE__ */ (0,
|
|
462
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.Sparkles, { className: "w-8 h-8 text-white" })
|
|
454
463
|
}
|
|
455
464
|
),
|
|
456
|
-
/* @__PURE__ */ (0,
|
|
457
|
-
/* @__PURE__ */ (0,
|
|
458
|
-
/* @__PURE__ */ (0,
|
|
465
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { children: [
|
|
466
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-slate-800 dark:text-white/80 font-medium leading-relaxed", children: ui.welcomeMessage }),
|
|
467
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-slate-500 dark:text-white/30 text-sm mt-2", children: "Ask a question to get started" })
|
|
459
468
|
] }),
|
|
460
|
-
/* @__PURE__ */ (0,
|
|
461
|
-
(suggestion) => /* @__PURE__ */ (0,
|
|
469
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "flex flex-wrap gap-2 justify-center mt-2", children: CHAT_SUGGESTIONS.map(
|
|
470
|
+
(suggestion) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
462
471
|
"button",
|
|
463
472
|
{
|
|
464
473
|
onClick: () => {
|
|
@@ -473,7 +482,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
473
482
|
)
|
|
474
483
|
) })
|
|
475
484
|
] })
|
|
476
|
-
) : messages.map((msg) => /* @__PURE__ */ (0,
|
|
485
|
+
) : messages.map((msg) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
477
486
|
MessageBubble,
|
|
478
487
|
{
|
|
479
488
|
message: msg,
|
|
@@ -483,7 +492,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
483
492
|
},
|
|
484
493
|
msg.id
|
|
485
494
|
)),
|
|
486
|
-
isLoading && /* @__PURE__ */ (0,
|
|
495
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
487
496
|
MessageBubble,
|
|
488
497
|
{
|
|
489
498
|
message: { role: "assistant", content: "" },
|
|
@@ -492,15 +501,15 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
492
501
|
accentColor: ui.accentColor
|
|
493
502
|
}
|
|
494
503
|
),
|
|
495
|
-
error && /* @__PURE__ */ (0,
|
|
496
|
-
/* @__PURE__ */ (0,
|
|
497
|
-
/* @__PURE__ */ (0,
|
|
504
|
+
error && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "flex items-center gap-2 text-rose-500 dark:text-rose-400 text-sm bg-rose-50 dark:bg-rose-400/10 border border-rose-200 dark:border-rose-400/20 rounded-xl px-4 py-3", children: [
|
|
505
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.TriangleAlert, { className: "w-4 h-4 flex-shrink-0" }),
|
|
506
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: error })
|
|
498
507
|
] }),
|
|
499
|
-
/* @__PURE__ */ (0,
|
|
508
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ref: bottomRef })
|
|
500
509
|
] }),
|
|
501
|
-
/* @__PURE__ */ (0,
|
|
502
|
-
/* @__PURE__ */ (0,
|
|
503
|
-
/* @__PURE__ */ (0,
|
|
510
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `px-4 pb-4 pt-2 border-t border-slate-200 dark:border-white/10 ${isGlass ? "bg-transparent" : "bg-white dark:bg-[#0f0f1a]"}`, children: [
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: `flex items-end gap-2 bg-slate-50 dark:bg-white/5 border border-slate-200 dark:border-white/10 p-2 focus-within:border-slate-300 dark:focus-within:border-white/20 transition-all ${ui.borderRadius === "full" ? "rounded-3xl" : "rounded-2xl"}`, children: [
|
|
512
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
504
513
|
"textarea",
|
|
505
514
|
{
|
|
506
515
|
ref: inputRef,
|
|
@@ -514,7 +523,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
514
523
|
style: { scrollbarWidth: "none" }
|
|
515
524
|
}
|
|
516
525
|
),
|
|
517
|
-
/* @__PURE__ */ (0,
|
|
526
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
518
527
|
"button",
|
|
519
528
|
{
|
|
520
529
|
onClick: sendMessage,
|
|
@@ -524,11 +533,11 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
524
533
|
background: input.trim() && !isLoading ? `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` : "rgba(148, 163, 184, 0.2)"
|
|
525
534
|
// slate-400/20 for light mode disabled
|
|
526
535
|
},
|
|
527
|
-
children: /* @__PURE__ */ (0,
|
|
536
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_lucide_react4.ArrowUp, { className: "w-4 h-4 text-white" })
|
|
528
537
|
}
|
|
529
538
|
)
|
|
530
539
|
] }),
|
|
531
|
-
/* @__PURE__ */ (0,
|
|
540
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "text-center text-[10px] text-slate-400 dark:text-white/20 mt-2", children: "Press Enter to send \xB7 Shift+Enter for new line" })
|
|
532
541
|
] })
|
|
533
542
|
]
|
|
534
543
|
}
|
|
@@ -536,7 +545,7 @@ function ChatWindow({ className = "", style, onClose, showClose = false }) {
|
|
|
536
545
|
}
|
|
537
546
|
|
|
538
547
|
// src/components/ChatWidget.tsx
|
|
539
|
-
var
|
|
548
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
540
549
|
function ChatWidget({ position = "bottom-right" }) {
|
|
541
550
|
const { ui } = useConfig();
|
|
542
551
|
const [isOpen, setIsOpen] = (0, import_react6.useState)(false);
|
|
@@ -549,14 +558,14 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
549
558
|
setIsOpen(true);
|
|
550
559
|
setHasUnread(false);
|
|
551
560
|
};
|
|
552
|
-
return /* @__PURE__ */ (0,
|
|
553
|
-
/* @__PURE__ */ (0,
|
|
561
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
562
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
554
563
|
"div",
|
|
555
564
|
{
|
|
556
565
|
className: `fixed z-[9998] w-[380px] max-w-[calc(100vw-3rem)] transition-all duration-300 ease-in-out ${windowPositionClass} ${isOpen ? "opacity-100 translate-y-0 pointer-events-auto" : "opacity-0 translate-y-4 pointer-events-none"}`,
|
|
557
566
|
style: { height: "600px", maxHeight: "calc(100vh - 6rem)" },
|
|
558
567
|
children: [
|
|
559
|
-
/* @__PURE__ */ (0,
|
|
568
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
560
569
|
ChatWindow,
|
|
561
570
|
{
|
|
562
571
|
className: "h-full relative z-10",
|
|
@@ -564,7 +573,7 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
564
573
|
onClose: () => setIsOpen(false)
|
|
565
574
|
}
|
|
566
575
|
),
|
|
567
|
-
/* @__PURE__ */ (0,
|
|
576
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
568
577
|
"div",
|
|
569
578
|
{
|
|
570
579
|
className: `absolute -bottom-1.5 w-4 h-4 rotate-45 border-r border-b border-slate-200 dark:border-white/10 z-0 ${ui.visualStyle === "solid" ? "bg-white dark:bg-[#0f0f1a]" : "bg-white/90 dark:bg-[#0f0f1a]/90 backdrop-blur-xl"} ${position === "bottom-left" ? "left-5" : "right-5"}`
|
|
@@ -573,7 +582,7 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
573
582
|
]
|
|
574
583
|
}
|
|
575
584
|
),
|
|
576
|
-
/* @__PURE__ */ (0,
|
|
585
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
577
586
|
"button",
|
|
578
587
|
{
|
|
579
588
|
onClick: isOpen ? () => setIsOpen(false) : handleOpen,
|
|
@@ -581,21 +590,21 @@ function ChatWidget({ position = "bottom-right" }) {
|
|
|
581
590
|
style: { background: `linear-gradient(135deg, ${ui.primaryColor}, ${ui.accentColor})` },
|
|
582
591
|
"aria-label": "Open chat",
|
|
583
592
|
children: [
|
|
584
|
-
/* @__PURE__ */ (0,
|
|
593
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
585
594
|
"span",
|
|
586
595
|
{
|
|
587
596
|
className: "absolute inset-0 rounded-full animate-ping opacity-20",
|
|
588
597
|
style: { background: ui.primaryColor }
|
|
589
598
|
}
|
|
590
599
|
),
|
|
591
|
-
/* @__PURE__ */ (0,
|
|
600
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
592
601
|
"span",
|
|
593
602
|
{
|
|
594
603
|
className: `transition-transform duration-300 ${isOpen ? "rotate-90 scale-90" : "rotate-0 scale-100"}`,
|
|
595
|
-
children: isOpen ? /* @__PURE__ */ (0,
|
|
604
|
+
children: isOpen ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.X, { className: "w-6 h-6 text-white" }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_lucide_react5.MessageSquare, { className: "w-6 h-6 text-white" })
|
|
596
605
|
}
|
|
597
606
|
),
|
|
598
|
-
hasUnread && !isOpen && /* @__PURE__ */ (0,
|
|
607
|
+
hasUnread && !isOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "absolute top-0 right-0 w-4 h-4 bg-rose-500 rounded-full border-2 border-white flex items-center justify-center text-[9px] font-bold text-white", children: "1" })
|
|
599
608
|
]
|
|
600
609
|
}
|
|
601
610
|
)
|