@contentgrowth/llm-service 0.8.6 → 0.8.8
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.
|
@@ -400,20 +400,29 @@ var ChatInputArea = forwardRef(({
|
|
|
400
400
|
const message = isControlled ? value : internalMessage;
|
|
401
401
|
const messageRef = useRef3(message);
|
|
402
402
|
messageRef.current = message;
|
|
403
|
+
const onChangeRef = useRef3(onChange);
|
|
404
|
+
useEffect3(() => {
|
|
405
|
+
onChangeRef.current = onChange;
|
|
406
|
+
}, [onChange]);
|
|
403
407
|
const { voice: globalVoice } = useChatConfig();
|
|
404
408
|
const isVoiceEnabled = (_a = globalVoice == null ? void 0 : globalVoice.enabled) != null ? _a : !!propVoiceConfig;
|
|
405
409
|
const voiceConfig = isVoiceEnabled ? propVoiceConfig || (globalVoice == null ? void 0 : globalVoice.config) : void 0;
|
|
406
|
-
const
|
|
407
|
-
|
|
410
|
+
const voiceConfigRef = useRef3(voiceConfig);
|
|
411
|
+
useEffect3(() => {
|
|
412
|
+
voiceConfigRef.current = voiceConfig;
|
|
413
|
+
}, [voiceConfig]);
|
|
414
|
+
const triggerChange = useCallback3((newValue) => {
|
|
415
|
+
console.log("[ChatInputArea] triggerChange called:", { newValue, isControlled, hasOnChange: !!onChangeRef.current, hasTextarea: !!textareaRef.current });
|
|
416
|
+
if (isControlled && onChangeRef.current) {
|
|
408
417
|
const syntheticEvent = {
|
|
409
418
|
target: { value: newValue },
|
|
410
419
|
currentTarget: { value: newValue }
|
|
411
420
|
};
|
|
412
|
-
|
|
421
|
+
onChangeRef.current(syntheticEvent);
|
|
413
422
|
} else {
|
|
414
423
|
setInternalMessage(newValue);
|
|
415
424
|
}
|
|
416
|
-
};
|
|
425
|
+
}, [isControlled]);
|
|
417
426
|
const isInputDisabled = (currentTask == null ? void 0 : currentTask.complete) || (lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.interactive) && (((_b = lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.interactiveData) == null ? void 0 : _b.function) === "form" && !(lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.isResponseSubmitted) || ((_c = lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.interactiveData) == null ? void 0 : _c.function) === "confirm" && !(lastInteractiveMessage == null ? void 0 : lastInteractiveMessage.isResponseSubmitted));
|
|
418
427
|
useProactiveResize(textareaRef, measurementRef, message, isInputDisabled || !!voiceTrigger || inputMode === "voice");
|
|
419
428
|
const handleVoiceKeyDown = (e) => {
|
|
@@ -443,20 +452,20 @@ var ChatInputArea = forwardRef(({
|
|
|
443
452
|
triggerChange(messageRef.current + (messageRef.current ? " " : "") + text);
|
|
444
453
|
}, []);
|
|
445
454
|
const handleVoiceEnd = useCallback3(() => {
|
|
446
|
-
var _a2;
|
|
455
|
+
var _a2, _b2;
|
|
447
456
|
console.log("[ChatInputArea] nativeSpeech onEnd triggered");
|
|
448
457
|
setVoiceTrigger(null);
|
|
449
|
-
(_a2 =
|
|
450
|
-
}, [
|
|
458
|
+
(_b2 = (_a2 = voiceConfigRef.current) == null ? void 0 : _a2.onVoiceEnd) == null ? void 0 : _b2.call(_a2);
|
|
459
|
+
}, []);
|
|
451
460
|
const nativeSpeech = useSpeechRecognition(handleVoiceResult, handleVoiceEnd, voiceConfig == null ? void 0 : voiceConfig.language);
|
|
452
461
|
const customRecorder = useAudioRecorder(async (blob) => {
|
|
453
|
-
var _a2;
|
|
462
|
+
var _a2, _b2, _c2;
|
|
454
463
|
console.log("[ChatInputArea] customRecorder onStop triggered");
|
|
455
464
|
setVoiceTrigger(null);
|
|
456
|
-
(_a2 =
|
|
457
|
-
if (
|
|
465
|
+
(_b2 = (_a2 = voiceConfigRef.current) == null ? void 0 : _a2.onVoiceEnd) == null ? void 0 : _b2.call(_a2);
|
|
466
|
+
if ((_c2 = voiceConfigRef.current) == null ? void 0 : _c2.onAudioCapture) {
|
|
458
467
|
try {
|
|
459
|
-
const text = await
|
|
468
|
+
const text = await voiceConfigRef.current.onAudioCapture(blob);
|
|
460
469
|
if (text) triggerChange(messageRef.current + (messageRef.current ? " " : "") + text);
|
|
461
470
|
} catch (e) {
|
|
462
471
|
console.error("[ChatInputArea] Audio capture failed", e);
|