@ensembleapp/client-sdk 0.0.5 → 0.0.7
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/index.d.ts +48 -7
- package/dist/index.js +404 -111
- package/dist/index.js.map +1 -1
- package/dist/widget/widget.global.js +41 -38
- package/dist/widget/widget.global.js.map +1 -1
- package/package.json +15 -5
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,10 @@ import { ClassValue } from 'clsx';
|
|
|
8
8
|
import 'json-schema';
|
|
9
9
|
import 'zod';
|
|
10
10
|
|
|
11
|
+
type DeprecatedChatConfig = {
|
|
12
|
+
/** @deprecated use agentId instead */
|
|
13
|
+
agentExecutionId?: string;
|
|
14
|
+
};
|
|
11
15
|
interface ApiConfig {
|
|
12
16
|
/** The base URL where /chat and /chat/messages are hosted */
|
|
13
17
|
baseUrl: string;
|
|
@@ -15,15 +19,13 @@ interface ApiConfig {
|
|
|
15
19
|
token: string;
|
|
16
20
|
headers?: Record<string, string>;
|
|
17
21
|
}
|
|
18
|
-
|
|
22
|
+
type UseChatConfig = DeprecatedChatConfig & {
|
|
19
23
|
/** The server API configuration */
|
|
20
24
|
api: ApiConfig;
|
|
21
25
|
/** Thread ID for keeping conversation history */
|
|
22
26
|
threadId: string;
|
|
23
|
-
/**
|
|
27
|
+
/** Ensemble agent ID to connect to */
|
|
24
28
|
agentId?: string;
|
|
25
|
-
/** The Agent Orchestration ID that this chat connects to. Either agentId or agentExecutionId must be provided */
|
|
26
|
-
agentExecutionId?: string;
|
|
27
29
|
/** additional context (anything) that needs to be passed to the LLM */
|
|
28
30
|
dataContext?: unknown;
|
|
29
31
|
onError?: (error: Error) => void;
|
|
@@ -32,7 +34,7 @@ interface UseChatConfig {
|
|
|
32
34
|
onFinish?: (message: any) => void;
|
|
33
35
|
onData?: (data: any) => void;
|
|
34
36
|
onMessage?: (message: UIMessage) => void;
|
|
35
|
-
}
|
|
37
|
+
};
|
|
36
38
|
interface ChatMessage {
|
|
37
39
|
id: string;
|
|
38
40
|
role: 'user' | 'assistant';
|
|
@@ -67,6 +69,37 @@ declare function useChat({ api, threadId, agentId, agentExecutionId, dataContext
|
|
|
67
69
|
setMessages: (messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[] | ((messages: UIMessage<unknown, ai.UIDataTypes, ai.UITools>[]) => UIMessage<unknown, ai.UIDataTypes, ai.UITools>[])) => void;
|
|
68
70
|
};
|
|
69
71
|
|
|
72
|
+
type FeedbackRating = 'positive' | 'negative';
|
|
73
|
+
interface MessageFeedback {
|
|
74
|
+
id: string;
|
|
75
|
+
messageId: string;
|
|
76
|
+
rating: FeedbackRating;
|
|
77
|
+
improvementText?: string;
|
|
78
|
+
createdAt: Date;
|
|
79
|
+
}
|
|
80
|
+
interface FeedbackState {
|
|
81
|
+
rating: FeedbackRating;
|
|
82
|
+
comment?: string;
|
|
83
|
+
}
|
|
84
|
+
interface UseFeedbackConfig {
|
|
85
|
+
api: ApiConfig;
|
|
86
|
+
threadId: string;
|
|
87
|
+
agentId?: string;
|
|
88
|
+
agentExecutionId?: string;
|
|
89
|
+
}
|
|
90
|
+
interface SubmitFeedbackParams {
|
|
91
|
+
messageId: string;
|
|
92
|
+
rating: FeedbackRating;
|
|
93
|
+
improvementText?: string;
|
|
94
|
+
}
|
|
95
|
+
declare function useFeedback({ api, threadId, agentId, agentExecutionId, }: UseFeedbackConfig): {
|
|
96
|
+
submitFeedback: ({ messageId, rating, improvementText }: SubmitFeedbackParams) => Promise<MessageFeedback | null>;
|
|
97
|
+
getFeedbackForMessage: (messageId: string) => FeedbackState | undefined;
|
|
98
|
+
hasFeedback: (messageId: string) => boolean;
|
|
99
|
+
isSubmitting: string | null;
|
|
100
|
+
error: Error | null;
|
|
101
|
+
};
|
|
102
|
+
|
|
70
103
|
interface ChatWidgetStyles {
|
|
71
104
|
primaryColor?: string;
|
|
72
105
|
primaryTextColor?: string;
|
|
@@ -98,6 +131,12 @@ interface ChatWidgetSpeechToTextOptions {
|
|
|
98
131
|
onError?: (message: string) => void;
|
|
99
132
|
finalDelay?: number;
|
|
100
133
|
}
|
|
134
|
+
interface ChatWidgetFeedbackOptions {
|
|
135
|
+
/** Enable feedback buttons on assistant messages. Default: true */
|
|
136
|
+
enabled?: boolean;
|
|
137
|
+
/** Require comment when giving negative feedback. Default: false */
|
|
138
|
+
requireCommentForNegative?: boolean;
|
|
139
|
+
}
|
|
101
140
|
interface ChatWidgetConfig extends UseChatConfig {
|
|
102
141
|
/** Title for the Chat window */
|
|
103
142
|
title?: string;
|
|
@@ -110,8 +149,10 @@ interface ChatWidgetConfig extends UseChatConfig {
|
|
|
110
149
|
voice?: ChatWidgetVoiceOptions;
|
|
111
150
|
speechToText?: ChatWidgetSpeechToTextOptions;
|
|
112
151
|
widgets?: UIWidgetDefinition[];
|
|
152
|
+
/** Feedback options for assistant messages. Enabled by default. */
|
|
153
|
+
feedback?: ChatWidgetFeedbackOptions;
|
|
113
154
|
}
|
|
114
|
-
declare function ChatWidget({ api, threadId, agentId, agentExecutionId, dataContext, onError, onAuthError, onFinish, onMessage, title, introMessage, inputPlaceholder, className, styles: styleProps, voice, speechToText, widgets, }: ChatWidgetConfig): react_jsx_runtime.JSX.Element;
|
|
155
|
+
declare function ChatWidget({ api, threadId, agentId, agentExecutionId, dataContext, onError, onAuthError, onFinish, onMessage, title, introMessage, inputPlaceholder, className, styles: styleProps, voice, speechToText, widgets, feedback, }: ChatWidgetConfig): react_jsx_runtime.JSX.Element;
|
|
115
156
|
|
|
116
157
|
interface PopupAnchorConfig {
|
|
117
158
|
enabled?: boolean;
|
|
@@ -190,4 +231,4 @@ declare const defaultChatWidgets: UIWidgetDefinition[];
|
|
|
190
231
|
|
|
191
232
|
declare function cn(...inputs: ClassValue[]): string;
|
|
192
233
|
|
|
193
|
-
export { type ApiConfig, type ChatMessage, ChatWidget, type ChatWidgetInstance, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type EmbeddableChatWidgetConfig, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, UIWidget, UIWidgetDefinition, type UseChatConfig, cn, createChatWidget, defaultChatWidgets, registerChatWidgets, useChat };
|
|
234
|
+
export { type ApiConfig, type ChatMessage, ChatWidget, type ChatWidgetFeedbackOptions, type ChatWidgetInstance, type ChatWidgetConfig as ChatWidgetProps, type ChatWidgetSpeechToTextOptions, type ChatWidgetStyles, type ChatWidgetVoiceOptions, type EmbeddableChatWidgetConfig, type FeedbackRating, type FeedbackState, type MessageFeedback, type PopupAnchorConfig, PopupChatWidget, type PopupChatWidgetProps, type SubmitFeedbackParams, UIWidget, UIWidgetDefinition, type UseChatConfig, type UseFeedbackConfig, cn, createChatWidget, defaultChatWidgets, registerChatWidgets, useChat, useFeedback };
|