vpschatbotwidget 1.1.0 → 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/chatbot/api/chatbot-api.d.ts +7 -4
- package/dist-lib/types/chatbot/api/chatbot-api.test.d.ts +1 -0
- package/dist-lib/types/chatbot/api/chatbot-types.d.ts +14 -0
- package/dist-lib/types/chatbot/core/AgentReasoning.d.ts +0 -1
- package/dist-lib/types/chatbot/core/ChatContext.d.ts +4 -1
- package/dist-lib/types/chatbot/core/ChatMarkdown.d.ts +2 -1
- package/dist-lib/types/chatbot/core/ChatProvider.d.ts +2 -0
- package/dist-lib/types/chatbot/core/grounding.test.d.ts +1 -0
- package/dist-lib/types/chatbot/embedded/EmbeddedChatbot.d.ts +1 -0
- package/dist-lib/types/chatbot/index.d.ts +1 -1
- package/dist-lib/types/chatbot/widget/ChatbotWidget.d.ts +1 -0
- package/dist-lib/vps-chatbot.cjs +53 -24
- package/dist-lib/vps-chatbot.js +1181 -840
- package/package.json +1 -1
- package/src/chatbot/api/chatbot-api.test.ts +48 -0
- package/src/chatbot/api/chatbot-api.ts +141 -49
- package/src/chatbot/api/chatbot-types.ts +16 -0
- package/src/chatbot/chatbot.test.tsx +24 -1
- package/src/chatbot/core/AgentReasoning.tsx +28 -23
- package/src/chatbot/core/ChatContext.tsx +4 -0
- package/src/chatbot/core/ChatInput.tsx +14 -1
- package/src/chatbot/core/ChatMarkdown.tsx +12 -3
- package/src/chatbot/core/ChatMessage.tsx +16 -4
- package/src/chatbot/core/ChatProvider.tsx +84 -15
- package/src/chatbot/core/ChatTypingIndicator.tsx +2 -7
- package/src/chatbot/core/GroundedSources.tsx +4 -6
- package/src/chatbot/core/grounding.test.tsx +21 -0
- package/src/chatbot/embedded/EmbeddedChatbot.tsx +4 -1
- package/src/chatbot/index.ts +2 -0
- package/src/chatbot/widget/ChatbotWidget.tsx +4 -1
- package/src/index.css +38 -162
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatAccessContext, ChatMessage, ChatMessageDto, SessionCreated, Source, SourceDto, Ticket, ToolCall, ToolCallDto, TokenUsage, TokenUsageDto } from "./chatbot-types";
|
|
1
|
+
import type { ChatAccessContext, ChatMessage, ChatMessageDto, SessionCreated, Source, SourceDto, Ticket, ToolCall, ToolCallDto, TokenUsage, TokenUsageDto, ModelCatalog } from "./chatbot-types";
|
|
2
2
|
export declare function resolveApiBaseUrl(customUrl?: string): string;
|
|
3
3
|
export declare function buildApiUrl(baseUrl: string | undefined, path: string): string;
|
|
4
4
|
export declare function normalizeSource(dto: SourceDto): Source;
|
|
@@ -7,22 +7,25 @@ export declare function normalizeUsage(dto: TokenUsageDto): TokenUsage;
|
|
|
7
7
|
export declare function normalizeChatMessage(dto: ChatMessageDto): ChatMessage;
|
|
8
8
|
export interface ChatApiClient {
|
|
9
9
|
apiBaseUrl: string;
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
listModels?(): Promise<ModelCatalog | null>;
|
|
11
|
+
createSession(signal?: AbortSignal): Promise<SessionCreated>;
|
|
12
|
+
sendMessage(sessionId: string, message: string, access?: ChatAccessContext, signal?: AbortSignal): Promise<{
|
|
12
13
|
requestId: string;
|
|
13
14
|
sessionId: string;
|
|
14
15
|
answer: string;
|
|
15
16
|
sources: Source[];
|
|
16
17
|
toolCalls: ToolCall[];
|
|
17
18
|
usage: TokenUsage;
|
|
19
|
+
durationMs?: number;
|
|
18
20
|
}>;
|
|
19
|
-
sendMessageStream?(sessionId: string, message: string, access?: ChatAccessContext, onProgress?: (stage: string) => void): Promise<{
|
|
21
|
+
sendMessageStream?(sessionId: string, message: string, access?: ChatAccessContext, onProgress?: (stage: string) => void, onToken?: (token: string) => void, signal?: AbortSignal): Promise<{
|
|
20
22
|
requestId: string;
|
|
21
23
|
sessionId: string;
|
|
22
24
|
answer: string;
|
|
23
25
|
sources: Source[];
|
|
24
26
|
toolCalls: ToolCall[];
|
|
25
27
|
usage: TokenUsage;
|
|
28
|
+
durationMs?: number;
|
|
26
29
|
}>;
|
|
27
30
|
getHistory(sessionId: string): Promise<ChatMessage[]>;
|
|
28
31
|
closeSession(sessionId: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -25,6 +25,7 @@ export interface ChatMessage {
|
|
|
25
25
|
createdAt: string;
|
|
26
26
|
status?: MessageStatus;
|
|
27
27
|
progressText?: string;
|
|
28
|
+
durationMs?: number;
|
|
28
29
|
sources?: Source[];
|
|
29
30
|
toolCalls?: ToolCall[];
|
|
30
31
|
usage?: TokenUsage;
|
|
@@ -44,6 +45,18 @@ export interface ChatUserContext {
|
|
|
44
45
|
export interface ChatAccessContext {
|
|
45
46
|
roleId?: number;
|
|
46
47
|
client?: "mobile" | "web" | "admin";
|
|
48
|
+
modelId?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface ModelOption {
|
|
51
|
+
id: string;
|
|
52
|
+
label: string;
|
|
53
|
+
model: string;
|
|
54
|
+
configured: boolean;
|
|
55
|
+
}
|
|
56
|
+
export interface ModelCatalog {
|
|
57
|
+
defaultModelId: string;
|
|
58
|
+
complexModelId?: string | null;
|
|
59
|
+
models: ModelOption[];
|
|
47
60
|
}
|
|
48
61
|
export interface Ticket {
|
|
49
62
|
ticketId: string;
|
|
@@ -117,6 +130,7 @@ export interface ChatResponseDto {
|
|
|
117
130
|
sources: SourceDto[];
|
|
118
131
|
tool_calls?: ToolCallDto[];
|
|
119
132
|
usage: TokenUsageDto;
|
|
133
|
+
duration_ms?: number;
|
|
120
134
|
role?: RoleDto | null;
|
|
121
135
|
}
|
|
122
136
|
export interface RoleDto {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChatMessage, ChatUserContext, Suggestion, Ticket } from "../api/chatbot-types";
|
|
1
|
+
import type { ChatMessage, ChatUserContext, Suggestion, Ticket, ModelOption } from "../api/chatbot-types";
|
|
2
2
|
export type ChatUiStatus = "idle" | "connecting" | "awaiting" | "error";
|
|
3
3
|
export interface PendingTicket {
|
|
4
4
|
subject: string;
|
|
@@ -24,6 +24,9 @@ export interface ChatContextValue {
|
|
|
24
24
|
confirmTicket: (customerIdOrEmail?: string) => Promise<void>;
|
|
25
25
|
cancelTicket: () => void;
|
|
26
26
|
resetConversation: () => Promise<void>;
|
|
27
|
+
models: ModelOption[];
|
|
28
|
+
selectedModelId: string;
|
|
29
|
+
selectModel: (modelId: string) => void;
|
|
27
30
|
}
|
|
28
31
|
export declare const ChatContext: import("react").Context<ChatContextValue | null>;
|
|
29
32
|
export declare function useChatContext(): ChatContextValue;
|
|
@@ -27,5 +27,7 @@ export interface ChatProviderProps {
|
|
|
27
27
|
hideInspectSources?: boolean;
|
|
28
28
|
/** Whether to render grounded sources (default: true) */
|
|
29
29
|
showGroundedSources?: boolean;
|
|
30
|
+
/** Configured model alias, or auto for server-side routing. */
|
|
31
|
+
modelId?: string;
|
|
30
32
|
}
|
|
31
33
|
export declare const ChatProvider: React.FC<ChatProviderProps>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,5 +6,5 @@ export { ChatbotWidget, type ChatbotWidgetProps } from "./widget/ChatbotWidget";
|
|
|
6
6
|
export { EmbeddedChatbot, type EmbeddedChatbotProps } from "./embedded/EmbeddedChatbot";
|
|
7
7
|
export { chatApi, createChatApi, buildApiUrl, resolveApiBaseUrl, type ChatApiClient, } from "./api/chatbot-api";
|
|
8
8
|
export { ColorPalette } from "./config/colors";
|
|
9
|
-
export type { ChatUserContext, ChatAccessContext, ChatMessage, Suggestion, Ticket, Source, ToolCall, TokenUsage, ChatRole, MessageStatus, } from "./api/chatbot-types";
|
|
9
|
+
export type { ChatUserContext, ChatAccessContext, ChatMessage, Suggestion, Ticket, Source, ToolCall, TokenUsage, ChatRole, MessageStatus, ModelOption, ModelCatalog, } from "./api/chatbot-types";
|
|
10
10
|
export type { EnvStage } from "../components/EnvBadge";
|