@usecrow/ui 0.1.24 → 0.1.25
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.cjs +18 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -185,6 +185,8 @@ interface WidgetConfigResponse {
|
|
|
185
185
|
persistAnonymousConversations?: boolean;
|
|
186
186
|
/** Custom welcome message shown when chat opens. Null uses SDK default. */
|
|
187
187
|
welcomeMessage?: string | null;
|
|
188
|
+
/** AI model to use for this product */
|
|
189
|
+
model?: string;
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
/** Identity data passed to the identify function */
|
|
@@ -547,13 +549,15 @@ interface UseChatOptions {
|
|
|
547
549
|
persistAnonymousConversations?: boolean;
|
|
548
550
|
/** Custom welcome message (uses SDK default if not provided) */
|
|
549
551
|
welcomeMessage?: string;
|
|
552
|
+
/** AI model to use for this chat (defaults to DEFAULT_MODEL) */
|
|
553
|
+
selectedModel?: string;
|
|
550
554
|
onVerificationStatus?: (isVerified: boolean) => void;
|
|
551
555
|
onConversationId?: (id: string) => void;
|
|
552
556
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
553
557
|
onToolCall?: (toolCall: ToolCallEvent) => void;
|
|
554
558
|
onRestoredConversation?: (conversationId: string) => void;
|
|
555
559
|
}
|
|
556
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
|
|
560
|
+
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
|
|
557
561
|
messages: Message[];
|
|
558
562
|
isLoading: boolean;
|
|
559
563
|
activeToolCalls: ToolCall[];
|
|
@@ -659,6 +663,8 @@ interface UseWidgetStylesResult {
|
|
|
659
663
|
persistAnonymousConversations: boolean | undefined;
|
|
660
664
|
/** Custom welcome message (undefined uses SDK default) */
|
|
661
665
|
welcomeMessage: string | undefined;
|
|
666
|
+
/** AI model configured for this product */
|
|
667
|
+
selectedModel: string | undefined;
|
|
662
668
|
/** Refetch styles from API */
|
|
663
669
|
refetch: () => Promise<void>;
|
|
664
670
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -185,6 +185,8 @@ interface WidgetConfigResponse {
|
|
|
185
185
|
persistAnonymousConversations?: boolean;
|
|
186
186
|
/** Custom welcome message shown when chat opens. Null uses SDK default. */
|
|
187
187
|
welcomeMessage?: string | null;
|
|
188
|
+
/** AI model to use for this product */
|
|
189
|
+
model?: string;
|
|
188
190
|
}
|
|
189
191
|
|
|
190
192
|
/** Identity data passed to the identify function */
|
|
@@ -547,13 +549,15 @@ interface UseChatOptions {
|
|
|
547
549
|
persistAnonymousConversations?: boolean;
|
|
548
550
|
/** Custom welcome message (uses SDK default if not provided) */
|
|
549
551
|
welcomeMessage?: string;
|
|
552
|
+
/** AI model to use for this chat (defaults to DEFAULT_MODEL) */
|
|
553
|
+
selectedModel?: string;
|
|
550
554
|
onVerificationStatus?: (isVerified: boolean) => void;
|
|
551
555
|
onConversationId?: (id: string) => void;
|
|
552
556
|
onWorkflowEvent?: (event: WorkflowEvent) => void;
|
|
553
557
|
onToolCall?: (toolCall: ToolCallEvent) => void;
|
|
554
558
|
onRestoredConversation?: (conversationId: string) => void;
|
|
555
559
|
}
|
|
556
|
-
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
|
|
560
|
+
declare function useChat({ productId, apiUrl, persistAnonymousConversations, welcomeMessage, selectedModel: initialSelectedModel, onVerificationStatus, onConversationId, onWorkflowEvent, onToolCall, onRestoredConversation, }: UseChatOptions): {
|
|
557
561
|
messages: Message[];
|
|
558
562
|
isLoading: boolean;
|
|
559
563
|
activeToolCalls: ToolCall[];
|
|
@@ -659,6 +663,8 @@ interface UseWidgetStylesResult {
|
|
|
659
663
|
persistAnonymousConversations: boolean | undefined;
|
|
660
664
|
/** Custom welcome message (undefined uses SDK default) */
|
|
661
665
|
welcomeMessage: string | undefined;
|
|
666
|
+
/** AI model configured for this product */
|
|
667
|
+
selectedModel: string | undefined;
|
|
662
668
|
/** Refetch styles from API */
|
|
663
669
|
refetch: () => Promise<void>;
|
|
664
670
|
}
|
package/dist/index.js
CHANGED
|
@@ -47,6 +47,7 @@ function useChat({
|
|
|
47
47
|
apiUrl = "",
|
|
48
48
|
persistAnonymousConversations,
|
|
49
49
|
welcomeMessage,
|
|
50
|
+
selectedModel: initialSelectedModel,
|
|
50
51
|
onVerificationStatus,
|
|
51
52
|
onConversationId,
|
|
52
53
|
onWorkflowEvent,
|
|
@@ -65,9 +66,14 @@ function useChat({
|
|
|
65
66
|
const [isLoading, setIsLoading] = useState(false);
|
|
66
67
|
const [activeToolCalls, setActiveToolCalls] = useState([]);
|
|
67
68
|
const [conversationId, setConversationId] = useState(null);
|
|
68
|
-
const [selectedModel, setSelectedModel] = useState(DEFAULT_MODEL);
|
|
69
|
+
const [selectedModel, setSelectedModel] = useState(initialSelectedModel || DEFAULT_MODEL);
|
|
69
70
|
const abortControllerRef = useRef(null);
|
|
70
71
|
const hasCheckedPersistRef = useRef(false);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
if (initialSelectedModel) {
|
|
74
|
+
setSelectedModel((prev) => prev !== initialSelectedModel ? initialSelectedModel : prev);
|
|
75
|
+
}
|
|
76
|
+
}, [initialSelectedModel]);
|
|
71
77
|
useEffect(() => {
|
|
72
78
|
if (messages.length === 1 && messages[0].id === "welcome" && !conversationId) {
|
|
73
79
|
setMessages([
|
|
@@ -1102,6 +1108,9 @@ function useWidgetStyles({
|
|
|
1102
1108
|
const [welcomeMessage, setWelcomeMessage] = useState(
|
|
1103
1109
|
styleCache.get(key)?.welcomeMessage ?? void 0
|
|
1104
1110
|
);
|
|
1111
|
+
const [selectedModel, setSelectedModel] = useState(
|
|
1112
|
+
styleCache.get(key)?.model ?? void 0
|
|
1113
|
+
);
|
|
1105
1114
|
const hasFetchedRef = useRef(false);
|
|
1106
1115
|
const fetchStyles = async () => {
|
|
1107
1116
|
if (skip) return;
|
|
@@ -1116,6 +1125,7 @@ function useWidgetStyles({
|
|
|
1116
1125
|
setShowThinking(config.showThinking ?? true);
|
|
1117
1126
|
setPersistAnonymousConversations(config.persistAnonymousConversations ?? true);
|
|
1118
1127
|
setWelcomeMessage(config.welcomeMessage ?? void 0);
|
|
1128
|
+
setSelectedModel(config.model ?? void 0);
|
|
1119
1129
|
} catch (err) {
|
|
1120
1130
|
console.error("[CrowWidget] Failed to fetch styles:", err);
|
|
1121
1131
|
setError(err instanceof Error ? err : new Error(String(err)));
|
|
@@ -1133,6 +1143,7 @@ function useWidgetStyles({
|
|
|
1133
1143
|
setShowThinking(cached.showThinking ?? true);
|
|
1134
1144
|
setPersistAnonymousConversations(cached.persistAnonymousConversations ?? true);
|
|
1135
1145
|
setWelcomeMessage(cached.welcomeMessage ?? void 0);
|
|
1146
|
+
setSelectedModel(cached.model ?? void 0);
|
|
1136
1147
|
setIsLoading(false);
|
|
1137
1148
|
return;
|
|
1138
1149
|
}
|
|
@@ -1149,6 +1160,7 @@ function useWidgetStyles({
|
|
|
1149
1160
|
showThinking,
|
|
1150
1161
|
persistAnonymousConversations,
|
|
1151
1162
|
welcomeMessage,
|
|
1163
|
+
selectedModel,
|
|
1152
1164
|
refetch: fetchStyles
|
|
1153
1165
|
};
|
|
1154
1166
|
}
|
|
@@ -2744,7 +2756,8 @@ function CrowWidget({
|
|
|
2744
2756
|
browserUseEnabled,
|
|
2745
2757
|
showThinking: showThinkingFromAPI,
|
|
2746
2758
|
persistAnonymousConversations,
|
|
2747
|
-
welcomeMessage: welcomeMessageFromAPI
|
|
2759
|
+
welcomeMessage: welcomeMessageFromAPI,
|
|
2760
|
+
selectedModel: selectedModelFromAPI
|
|
2748
2761
|
} = useWidgetStyles({
|
|
2749
2762
|
productId,
|
|
2750
2763
|
apiUrl,
|
|
@@ -2753,6 +2766,7 @@ function CrowWidget({
|
|
|
2753
2766
|
});
|
|
2754
2767
|
const agentName = agentNameProp ?? agentNameFromAPI;
|
|
2755
2768
|
const welcomeMessage = welcomeMessageProp ?? welcomeMessageFromAPI;
|
|
2769
|
+
const selectedModel = selectedModelFromAPI ?? DEFAULT_MODEL;
|
|
2756
2770
|
const showThinking = showThinkingProp ?? showThinkingFromAPI;
|
|
2757
2771
|
const [autoTools, setAutoTools] = useState({});
|
|
2758
2772
|
const cssVars = stylesToCssVars(styles);
|
|
@@ -2775,7 +2789,7 @@ function CrowWidget({
|
|
|
2775
2789
|
productId,
|
|
2776
2790
|
apiUrl,
|
|
2777
2791
|
conversationId: null,
|
|
2778
|
-
selectedModel
|
|
2792
|
+
selectedModel
|
|
2779
2793
|
});
|
|
2780
2794
|
const conversations = useConversations({ productId, apiUrl });
|
|
2781
2795
|
const [shouldRestoreHistory, setShouldRestoreHistory] = useState(false);
|
|
@@ -2785,6 +2799,7 @@ function CrowWidget({
|
|
|
2785
2799
|
apiUrl,
|
|
2786
2800
|
persistAnonymousConversations,
|
|
2787
2801
|
welcomeMessage,
|
|
2802
|
+
selectedModel,
|
|
2788
2803
|
onVerificationStatus: (isVerified) => {
|
|
2789
2804
|
setIsVerifiedUser(isVerified);
|
|
2790
2805
|
},
|