@retrivora-ai/rag-engine 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/.env.example +77 -0
- package/README.md +149 -0
- package/dist/DocumentChunker-BUrIrcPk.d.mts +43 -0
- package/dist/DocumentChunker-BUrIrcPk.d.ts +43 -0
- package/dist/RAGPipeline-BmkIv1HD.d.mts +298 -0
- package/dist/RAGPipeline-BmkIv1HD.d.ts +298 -0
- package/dist/chunk-NCG2JKXB.mjs +1254 -0
- package/dist/chunk-ZPXLQR5Q.mjs +67 -0
- package/dist/handlers/index.d.mts +68 -0
- package/dist/handlers/index.d.ts +68 -0
- package/dist/handlers/index.js +1319 -0
- package/dist/handlers/index.mjs +13 -0
- package/dist/index.d.mts +93 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.js +612 -0
- package/dist/index.mjs +551 -0
- package/dist/server.d.mts +211 -0
- package/dist/server.d.ts +211 -0
- package/dist/server.js +1457 -0
- package/dist/server.mjs +148 -0
- package/package.json +90 -0
- package/src/app/api/chat/route.ts +4 -0
- package/src/app/api/health/route.ts +4 -0
- package/src/app/api/ingest/route.ts +26 -0
- package/src/app/favicon.ico +0 -0
- package/src/app/globals.css +163 -0
- package/src/app/layout.tsx +35 -0
- package/src/app/page.tsx +506 -0
- package/src/components/ChatWidget.tsx +91 -0
- package/src/components/ChatWindow.tsx +248 -0
- package/src/components/ConfigProvider.tsx +56 -0
- package/src/components/MessageBubble.tsx +99 -0
- package/src/components/SourceCard.tsx +66 -0
- package/src/components/ThemeProvider.tsx +8 -0
- package/src/components/ThemeToggle.tsx +29 -0
- package/src/config/RagConfig.ts +159 -0
- package/src/config/UniversalProfiles.ts +83 -0
- package/src/config/serverConfig.ts +142 -0
- package/src/handlers/index.ts +202 -0
- package/src/hooks/useHydrated.ts +13 -0
- package/src/hooks/useRagChat.ts +167 -0
- package/src/hooks/useStoredMessages.ts +53 -0
- package/src/index.ts +27 -0
- package/src/llm/ILLMProvider.ts +60 -0
- package/src/llm/LLMFactory.ts +54 -0
- package/src/llm/providers/AnthropicProvider.ts +87 -0
- package/src/llm/providers/OllamaProvider.ts +102 -0
- package/src/llm/providers/OpenAIProvider.ts +92 -0
- package/src/llm/providers/UniversalLLMAdapter.ts +154 -0
- package/src/rag/DocumentChunker.ts +105 -0
- package/src/rag/RAGPipeline.ts +196 -0
- package/src/server.ts +30 -0
- package/src/types/pdf-parse.d.ts +13 -0
- package/src/utils/DocumentParser.ts +75 -0
- package/src/utils/templateUtils.ts +78 -0
- package/src/vectordb/IVectorDB.ts +75 -0
- package/src/vectordb/VectorDBFactory.ts +41 -0
- package/src/vectordb/adapters/MongoDbAdapter.ts +175 -0
- package/src/vectordb/adapters/PgVectorAdapter.ts +159 -0
- package/src/vectordb/adapters/PineconeAdapter.ts +115 -0
- package/src/vectordb/adapters/UniversalVectorDBAdapter.ts +177 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createChatHandler,
|
|
3
|
+
createHealthHandler,
|
|
4
|
+
createIngestHandler,
|
|
5
|
+
createUploadHandler
|
|
6
|
+
} from "../chunk-NCG2JKXB.mjs";
|
|
7
|
+
import "../chunk-ZPXLQR5Q.mjs";
|
|
8
|
+
export {
|
|
9
|
+
createChatHandler,
|
|
10
|
+
createHealthHandler,
|
|
11
|
+
createIngestHandler,
|
|
12
|
+
createUploadHandler
|
|
13
|
+
};
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1, { ReactNode } from 'react';
|
|
3
|
+
import { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RAGPipeline-BmkIv1HD.mjs';
|
|
4
|
+
export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, I as ILLMProvider, d as IVectorDB, e as IngestDocument, L as LLMConfig, R as RAGConfig, f as RagConfig, g as UpsertDocument, h as VectorDBConfig } from './RAGPipeline-BmkIv1HD.mjs';
|
|
5
|
+
export { C as Chunk, a as ChunkOptions } from './DocumentChunker-BUrIrcPk.mjs';
|
|
6
|
+
|
|
7
|
+
interface ChatWidgetProps {
|
|
8
|
+
/** Position of the floating button. Defaults to bottom-right. */
|
|
9
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
10
|
+
}
|
|
11
|
+
declare function ChatWidget({ position }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
12
|
+
|
|
13
|
+
interface ChatWindowProps {
|
|
14
|
+
/** Additional className for the wrapper div */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Inline styles for the wrapper div */
|
|
17
|
+
style?: React$1.CSSProperties;
|
|
18
|
+
/** Called when the close button is clicked (for widget mode) */
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
/** Whether to show a close (X) button in the header */
|
|
21
|
+
showClose?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare function ChatWindow({ className, style, onClose, showClose }: ChatWindowProps): react_jsx_runtime.JSX.Element;
|
|
24
|
+
|
|
25
|
+
interface MessageBubbleProps {
|
|
26
|
+
message: ChatMessage;
|
|
27
|
+
sources?: VectorMatch[];
|
|
28
|
+
isStreaming?: boolean;
|
|
29
|
+
primaryColor?: string;
|
|
30
|
+
accentColor?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
|
|
34
|
+
interface SourceCardProps {
|
|
35
|
+
source: VectorMatch;
|
|
36
|
+
index: number;
|
|
37
|
+
}
|
|
38
|
+
declare function SourceCard({ source, index }: SourceCardProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
|
|
40
|
+
interface ClientConfig {
|
|
41
|
+
projectId: string;
|
|
42
|
+
ui: Required<UIConfig>;
|
|
43
|
+
}
|
|
44
|
+
declare function ConfigProvider({ config, children, }: {
|
|
45
|
+
config?: {
|
|
46
|
+
projectId?: string;
|
|
47
|
+
ui?: Partial<UIConfig>;
|
|
48
|
+
};
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
}): react_jsx_runtime.JSX.Element;
|
|
51
|
+
declare function useConfig(): ClientConfig;
|
|
52
|
+
|
|
53
|
+
type MessageRole = 'user' | 'assistant';
|
|
54
|
+
interface RagMessage {
|
|
55
|
+
id: string;
|
|
56
|
+
role: MessageRole;
|
|
57
|
+
content: string;
|
|
58
|
+
/** Retrieved source chunks (assistant messages only) */
|
|
59
|
+
sources?: VectorMatch[];
|
|
60
|
+
/** ISO timestamp */
|
|
61
|
+
createdAt: string;
|
|
62
|
+
}
|
|
63
|
+
interface UseRagChatOptions {
|
|
64
|
+
/** Override the chat API endpoint (default: /api/chat) */
|
|
65
|
+
apiUrl?: string;
|
|
66
|
+
/** Override project namespace */
|
|
67
|
+
namespace?: string;
|
|
68
|
+
/** Persist chat history to localStorage (default: true) */
|
|
69
|
+
persist?: boolean;
|
|
70
|
+
/** Called after each successful assistant reply */
|
|
71
|
+
onReply?: (message: RagMessage) => void;
|
|
72
|
+
/** Called on error */
|
|
73
|
+
onError?: (error: string) => void;
|
|
74
|
+
}
|
|
75
|
+
interface UseRagChatReturn {
|
|
76
|
+
/** All messages in the current conversation */
|
|
77
|
+
messages: RagMessage[];
|
|
78
|
+
/** Whether a response is in flight */
|
|
79
|
+
isLoading: boolean;
|
|
80
|
+
/** Current error message, or null */
|
|
81
|
+
error: string | null;
|
|
82
|
+
/** Send a user message */
|
|
83
|
+
send: (text: string) => Promise<void>;
|
|
84
|
+
/** Clear the conversation (and localStorage if persist=true) */
|
|
85
|
+
clear: () => void;
|
|
86
|
+
/** Retry the last failed send */
|
|
87
|
+
retry: () => Promise<void>;
|
|
88
|
+
/** Programmatically set the conversation (e.g. to restore from a DB) */
|
|
89
|
+
setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
|
|
90
|
+
}
|
|
91
|
+
declare function useRagChat(projectId: string, options?: UseRagChatOptions): UseRagChatReturn;
|
|
92
|
+
|
|
93
|
+
export { ChatMessage, ChatWidget, ChatWindow, type ClientConfig, ConfigProvider, MessageBubble, type RagMessage, SourceCard, UIConfig, type UseRagChatOptions, type UseRagChatReturn, VectorMatch, useConfig, useRagChat };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import React$1, { ReactNode } from 'react';
|
|
3
|
+
import { C as ChatMessage, V as VectorMatch, U as UIConfig } from './RAGPipeline-BmkIv1HD.js';
|
|
4
|
+
export { a as ChatOptions, b as ChatResponse, E as EmbedOptions, c as EmbeddingConfig, I as ILLMProvider, d as IVectorDB, e as IngestDocument, L as LLMConfig, R as RAGConfig, f as RagConfig, g as UpsertDocument, h as VectorDBConfig } from './RAGPipeline-BmkIv1HD.js';
|
|
5
|
+
export { C as Chunk, a as ChunkOptions } from './DocumentChunker-BUrIrcPk.js';
|
|
6
|
+
|
|
7
|
+
interface ChatWidgetProps {
|
|
8
|
+
/** Position of the floating button. Defaults to bottom-right. */
|
|
9
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
10
|
+
}
|
|
11
|
+
declare function ChatWidget({ position }: ChatWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
12
|
+
|
|
13
|
+
interface ChatWindowProps {
|
|
14
|
+
/** Additional className for the wrapper div */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** Inline styles for the wrapper div */
|
|
17
|
+
style?: React$1.CSSProperties;
|
|
18
|
+
/** Called when the close button is clicked (for widget mode) */
|
|
19
|
+
onClose?: () => void;
|
|
20
|
+
/** Whether to show a close (X) button in the header */
|
|
21
|
+
showClose?: boolean;
|
|
22
|
+
}
|
|
23
|
+
declare function ChatWindow({ className, style, onClose, showClose }: ChatWindowProps): react_jsx_runtime.JSX.Element;
|
|
24
|
+
|
|
25
|
+
interface MessageBubbleProps {
|
|
26
|
+
message: ChatMessage;
|
|
27
|
+
sources?: VectorMatch[];
|
|
28
|
+
isStreaming?: boolean;
|
|
29
|
+
primaryColor?: string;
|
|
30
|
+
accentColor?: string;
|
|
31
|
+
}
|
|
32
|
+
declare function MessageBubble({ message, sources, isStreaming, primaryColor, accentColor, }: MessageBubbleProps): react_jsx_runtime.JSX.Element;
|
|
33
|
+
|
|
34
|
+
interface SourceCardProps {
|
|
35
|
+
source: VectorMatch;
|
|
36
|
+
index: number;
|
|
37
|
+
}
|
|
38
|
+
declare function SourceCard({ source, index }: SourceCardProps): react_jsx_runtime.JSX.Element;
|
|
39
|
+
|
|
40
|
+
interface ClientConfig {
|
|
41
|
+
projectId: string;
|
|
42
|
+
ui: Required<UIConfig>;
|
|
43
|
+
}
|
|
44
|
+
declare function ConfigProvider({ config, children, }: {
|
|
45
|
+
config?: {
|
|
46
|
+
projectId?: string;
|
|
47
|
+
ui?: Partial<UIConfig>;
|
|
48
|
+
};
|
|
49
|
+
children: ReactNode;
|
|
50
|
+
}): react_jsx_runtime.JSX.Element;
|
|
51
|
+
declare function useConfig(): ClientConfig;
|
|
52
|
+
|
|
53
|
+
type MessageRole = 'user' | 'assistant';
|
|
54
|
+
interface RagMessage {
|
|
55
|
+
id: string;
|
|
56
|
+
role: MessageRole;
|
|
57
|
+
content: string;
|
|
58
|
+
/** Retrieved source chunks (assistant messages only) */
|
|
59
|
+
sources?: VectorMatch[];
|
|
60
|
+
/** ISO timestamp */
|
|
61
|
+
createdAt: string;
|
|
62
|
+
}
|
|
63
|
+
interface UseRagChatOptions {
|
|
64
|
+
/** Override the chat API endpoint (default: /api/chat) */
|
|
65
|
+
apiUrl?: string;
|
|
66
|
+
/** Override project namespace */
|
|
67
|
+
namespace?: string;
|
|
68
|
+
/** Persist chat history to localStorage (default: true) */
|
|
69
|
+
persist?: boolean;
|
|
70
|
+
/** Called after each successful assistant reply */
|
|
71
|
+
onReply?: (message: RagMessage) => void;
|
|
72
|
+
/** Called on error */
|
|
73
|
+
onError?: (error: string) => void;
|
|
74
|
+
}
|
|
75
|
+
interface UseRagChatReturn {
|
|
76
|
+
/** All messages in the current conversation */
|
|
77
|
+
messages: RagMessage[];
|
|
78
|
+
/** Whether a response is in flight */
|
|
79
|
+
isLoading: boolean;
|
|
80
|
+
/** Current error message, or null */
|
|
81
|
+
error: string | null;
|
|
82
|
+
/** Send a user message */
|
|
83
|
+
send: (text: string) => Promise<void>;
|
|
84
|
+
/** Clear the conversation (and localStorage if persist=true) */
|
|
85
|
+
clear: () => void;
|
|
86
|
+
/** Retry the last failed send */
|
|
87
|
+
retry: () => Promise<void>;
|
|
88
|
+
/** Programmatically set the conversation (e.g. to restore from a DB) */
|
|
89
|
+
setMessages: React.Dispatch<React.SetStateAction<RagMessage[]>>;
|
|
90
|
+
}
|
|
91
|
+
declare function useRagChat(projectId: string, options?: UseRagChatOptions): UseRagChatReturn;
|
|
92
|
+
|
|
93
|
+
export { ChatMessage, ChatWidget, ChatWindow, type ClientConfig, ConfigProvider, MessageBubble, type RagMessage, SourceCard, UIConfig, type UseRagChatOptions, type UseRagChatReturn, VectorMatch, useConfig, useRagChat };
|