vpschatbotwidget 1.0.3 → 1.2.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/dist-lib/types/App.d.ts +1 -0
- package/dist-lib/types/chatbot/api/chatbot-api.d.ts +14 -3
- package/dist-lib/types/chatbot/api/chatbot-api.test.d.ts +1 -0
- package/dist-lib/types/chatbot/api/chatbot-types.d.ts +35 -0
- package/dist-lib/types/chatbot/core/AgentReasoning.d.ts +8 -0
- package/dist-lib/types/chatbot/core/ChatContext.d.ts +6 -1
- package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +3 -2
- package/dist-lib/types/chatbot/core/ChatProvider.d.ts +15 -1
- package/dist-lib/types/chatbot/core/ChatTypingIndicator.d.ts +1 -0
- package/dist-lib/types/chatbot/core/GroundedSources.d.ts +14 -0
- package/dist-lib/types/chatbot/core/grounding.test.d.ts +1 -0
- package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +14 -1
- package/dist-lib/types/chatbot/index.d.ts +1 -1
- package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +14 -1
- package/dist-lib/vps-chatbot.cjs +53 -20
- package/dist-lib/vps-chatbot.js +1552 -980
- package/package.json +1 -1
- package/src/chatbot/api/chatbot-api.test.ts +48 -0
- package/src/chatbot/api/chatbot-api.ts +199 -5
- package/src/chatbot/api/chatbot-types.ts +39 -0
- package/src/chatbot/chatbot.test.tsx +24 -1
- package/src/chatbot/core/AgentReasoning.tsx +65 -0
- package/src/chatbot/core/ChatContext.tsx +6 -0
- package/src/chatbot/core/ChatInput.tsx +14 -1
- package/src/chatbot/core/ChatMarkdown.tsx +288 -54
- package/src/chatbot/core/ChatMessage.tsx +53 -45
- package/src/chatbot/core/ChatMessageList.tsx +1 -1
- package/src/chatbot/core/ChatProvider.tsx +184 -28
- package/src/chatbot/core/ChatTypingIndicator.tsx +11 -5
- package/src/chatbot/core/GroundedSources.tsx +179 -0
- package/src/chatbot/core/grounding.test.tsx +21 -0
- package/src/chatbot/embedded/EmbeddedChatbot.tsx +36 -4
- package/src/chatbot/index.ts +3 -0
- package/src/chatbot/widget/ChatbotWidget.tsx +36 -4
- package/src/index.css +927 -68
|
@@ -15,7 +15,15 @@ export interface ChatbotWidgetProps {
|
|
|
15
15
|
/** Environment badge stage. Omit for production. */
|
|
16
16
|
envStage?: EnvStage;
|
|
17
17
|
envPulse?: boolean;
|
|
18
|
-
/**
|
|
18
|
+
/** Direct role name (e.g. "VPS Admin", "Client User", "Captain") */
|
|
19
|
+
role?: string;
|
|
20
|
+
/** Direct role ID for server-side RAG access control */
|
|
21
|
+
roleId?: number;
|
|
22
|
+
/** Direct client experience ("web" | "mobile" | "admin") */
|
|
23
|
+
client?: "mobile" | "web" | "admin";
|
|
24
|
+
/** Optional custom initial welcome message */
|
|
25
|
+
welcomeMessage?: string;
|
|
26
|
+
/** Backend or proxy API base URL */
|
|
19
27
|
apiBaseUrl?: string;
|
|
20
28
|
/** Alias for apiBaseUrl */
|
|
21
29
|
apiUrl?: string;
|
|
@@ -29,11 +37,16 @@ export interface ChatbotWidgetProps {
|
|
|
29
37
|
disableSuggestions?: boolean;
|
|
30
38
|
/** Initial welcome message to trigger on mount */
|
|
31
39
|
initialMessage?: string;
|
|
40
|
+
/** If true, hides the "Inspect Sources" toggle button and drawer in grounded sources */
|
|
41
|
+
hideInspectSources?: boolean;
|
|
42
|
+
/** Whether to show grounded sources (default: true) */
|
|
43
|
+
showGroundedSources?: boolean;
|
|
44
|
+
modelId?: string;
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
const ChatbotWidgetView: React.FC<Omit<
|
|
35
48
|
ChatbotWidgetProps,
|
|
36
|
-
"apiBaseUrl" | "apiUrl" | "proxyUrl" | "userContext" | "suggestions" | "disableSuggestions" | "initialMessage"
|
|
49
|
+
"apiBaseUrl" | "apiUrl" | "proxyUrl" | "userContext" | "suggestions" | "disableSuggestions" | "initialMessage" | "hideInspectSources" | "showGroundedSources"
|
|
37
50
|
>> = ({
|
|
38
51
|
defaultOpen = false,
|
|
39
52
|
open,
|
|
@@ -69,22 +82,34 @@ export const ChatbotWidget: React.FC<ChatbotWidgetProps> = ({
|
|
|
69
82
|
apiUrl,
|
|
70
83
|
proxyUrl,
|
|
71
84
|
userContext,
|
|
85
|
+
role,
|
|
86
|
+
roleId,
|
|
87
|
+
client,
|
|
88
|
+
welcomeMessage,
|
|
72
89
|
suggestions,
|
|
73
90
|
disableSuggestions,
|
|
74
91
|
initialMessage,
|
|
92
|
+
hideInspectSources,
|
|
93
|
+
showGroundedSources,
|
|
94
|
+
modelId,
|
|
75
95
|
...viewProps
|
|
76
96
|
}) => {
|
|
77
97
|
const existingContext = useOptionalChatContext();
|
|
78
98
|
const explicitUrl = apiBaseUrl ?? apiUrl ?? proxyUrl;
|
|
79
99
|
|
|
80
|
-
// If already inside ChatProvider and no conflicting apiBaseUrl or userContext override is passed, reuse context
|
|
81
100
|
const canReuseContext =
|
|
82
101
|
Boolean(existingContext) &&
|
|
83
102
|
(!explicitUrl || resolveApiBaseUrl(explicitUrl) === resolveApiBaseUrl(existingContext?.apiBaseUrl)) &&
|
|
84
103
|
!userContext &&
|
|
104
|
+
role === undefined &&
|
|
105
|
+
roleId === undefined &&
|
|
106
|
+
client === undefined &&
|
|
107
|
+
welcomeMessage === undefined &&
|
|
85
108
|
!suggestions &&
|
|
86
109
|
disableSuggestions === undefined &&
|
|
87
|
-
!initialMessage
|
|
110
|
+
!initialMessage &&
|
|
111
|
+
hideInspectSources === undefined &&
|
|
112
|
+
showGroundedSources === undefined && modelId === undefined;
|
|
88
113
|
|
|
89
114
|
if (canReuseContext) {
|
|
90
115
|
return <ChatbotWidgetView {...viewProps} />;
|
|
@@ -94,9 +119,16 @@ export const ChatbotWidget: React.FC<ChatbotWidgetProps> = ({
|
|
|
94
119
|
<ChatProvider
|
|
95
120
|
apiBaseUrl={explicitUrl}
|
|
96
121
|
userContext={userContext}
|
|
122
|
+
role={role}
|
|
123
|
+
roleId={roleId}
|
|
124
|
+
client={client}
|
|
125
|
+
welcomeMessage={welcomeMessage}
|
|
97
126
|
suggestions={suggestions}
|
|
98
127
|
disableSuggestions={disableSuggestions}
|
|
99
128
|
initialMessage={initialMessage}
|
|
129
|
+
hideInspectSources={hideInspectSources}
|
|
130
|
+
showGroundedSources={showGroundedSources}
|
|
131
|
+
modelId={modelId}
|
|
100
132
|
>
|
|
101
133
|
<ChatbotWidgetView {...viewProps} />
|
|
102
134
|
</ChatProvider>
|