@alquimia-ai/ui 1.6.1 → 1.7.1
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/components/organisms/index.d.mts +2 -2
- package/dist/components/organisms/index.d.ts +2 -2
- package/dist/components/organisms/index.js +75 -36
- package/dist/components/organisms/index.js.map +1 -1
- package/dist/components/organisms/index.mjs +76 -41
- package/dist/components/organisms/index.mjs.map +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +75 -36
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +76 -41
- package/dist/index.mjs.map +1 -1
- package/dist/types/index.d.mts +11 -1
- package/dist/types/index.d.ts +11 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/index.mjs.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Message } from 'ai';
|
|
3
|
+
import { TTSResult, Tooler, ToolFactory, RatingData } from '../../types/index.mjs';
|
|
3
4
|
import * as React$1 from 'react';
|
|
4
5
|
import { AlquimiaSDK } from '@alquimia-ai/tools/sdk';
|
|
5
|
-
import { Tooler, ToolFactory, RatingData } from '../../types/index.mjs';
|
|
6
6
|
|
|
7
7
|
interface WhisperProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
message: Message;
|
|
9
9
|
isMessageStreaming: boolean;
|
|
10
|
-
textToSpeech: (content: string) => Promise<
|
|
10
|
+
textToSpeech: (content: string) => Promise<TTSResult>;
|
|
11
11
|
}
|
|
12
12
|
declare function Whisper({ className, message, isMessageStreaming, textToSpeech, }: WhisperProps): react_jsx_runtime.JSX.Element;
|
|
13
13
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { Message } from 'ai';
|
|
3
|
+
import { TTSResult, Tooler, ToolFactory, RatingData } from '../../types/index.js';
|
|
3
4
|
import * as React$1 from 'react';
|
|
4
5
|
import { AlquimiaSDK } from '@alquimia-ai/tools/sdk';
|
|
5
|
-
import { Tooler, ToolFactory, RatingData } from '../../types/index.js';
|
|
6
6
|
|
|
7
7
|
interface WhisperProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
message: Message;
|
|
9
9
|
isMessageStreaming: boolean;
|
|
10
|
-
textToSpeech: (content: string) => Promise<
|
|
10
|
+
textToSpeech: (content: string) => Promise<TTSResult>;
|
|
11
11
|
}
|
|
12
12
|
declare function Whisper({ className, message, isMessageStreaming, textToSpeech, }: WhisperProps): react_jsx_runtime.JSX.Element;
|
|
13
13
|
|
|
@@ -95,18 +95,34 @@ function Whisper({
|
|
|
95
95
|
audioUrl && (audioUrl.currentTime = 0);
|
|
96
96
|
audioUrl?.pause();
|
|
97
97
|
};
|
|
98
|
+
const playAudio = (url) => {
|
|
99
|
+
const audio = new Audio(url);
|
|
100
|
+
audio.play();
|
|
101
|
+
setAudioUrl(audio);
|
|
102
|
+
};
|
|
98
103
|
const handleAudioPlay = () => isPlaying ? resetAudio() : audioUrl?.play();
|
|
99
104
|
const handleTextToSpeech = async (content2) => {
|
|
100
105
|
if (!audioUrl) {
|
|
101
106
|
setIsLoading(true);
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
+
try {
|
|
108
|
+
const filteredContent = parseTextToSpeech(content2);
|
|
109
|
+
const audioFile = await textToSpeech(filteredContent);
|
|
110
|
+
if (audioFile) {
|
|
111
|
+
switch (audioFile.type) {
|
|
112
|
+
case "url":
|
|
113
|
+
await playAudio(audioFile.data);
|
|
114
|
+
break;
|
|
115
|
+
case "blob":
|
|
116
|
+
await playAudio(URL.createObjectURL(audioFile.data));
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
console.error("Error obtaining audio", audioFile.message);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
} catch (error) {
|
|
123
|
+
console.error("Error in text to speech:", error);
|
|
124
|
+
} finally {
|
|
107
125
|
setIsLoading(false);
|
|
108
|
-
audio.play();
|
|
109
|
-
setAudioUrl(audio);
|
|
110
126
|
}
|
|
111
127
|
} else {
|
|
112
128
|
setIsLoading(false);
|
|
@@ -116,10 +132,22 @@ function Whisper({
|
|
|
116
132
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: cn(className), children: [
|
|
117
133
|
isMessageStreaming && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "p-2 w-[24px] h-[24px]" }),
|
|
118
134
|
!isMessageStreaming && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { onClick: () => handleTextToSpeech(content), children: [
|
|
119
|
-
isPlaying && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "p-2 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
120
|
-
|
|
135
|
+
isPlaying && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { className: "p-2 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
136
|
+
import_lucide_react.AudioLinesIcon,
|
|
137
|
+
{
|
|
138
|
+
size: 20,
|
|
139
|
+
className: "animate-[wave_0.7s_infinite_ease-in-out]"
|
|
140
|
+
}
|
|
141
|
+
) }),
|
|
142
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", { disabled: true, className: "p-2 items-center justify-center", children: [
|
|
121
143
|
" ",
|
|
122
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
144
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
145
|
+
import_lucide_react.LoaderCircleIcon,
|
|
146
|
+
{
|
|
147
|
+
size: 20,
|
|
148
|
+
className: "animate-[spin_1s_linear_infinite]"
|
|
149
|
+
}
|
|
150
|
+
)
|
|
123
151
|
] }),
|
|
124
152
|
!isLoading && !isPlaying && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
125
153
|
"button",
|
|
@@ -2725,15 +2753,6 @@ var AssistantMessageArea = React34.forwardRef(
|
|
|
2725
2753
|
role: message.role,
|
|
2726
2754
|
message,
|
|
2727
2755
|
children: [
|
|
2728
|
-
message.created_at && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-xs text-muted-foreground/80 pb-1", children: new Date(Number(message.created_at)).toLocaleString("es-ES", {
|
|
2729
|
-
day: "2-digit",
|
|
2730
|
-
month: "2-digit",
|
|
2731
|
-
year: "numeric",
|
|
2732
|
-
hour: "2-digit",
|
|
2733
|
-
minute: "2-digit",
|
|
2734
|
-
second: "2-digit",
|
|
2735
|
-
hour12: false
|
|
2736
|
-
}) }),
|
|
2737
2756
|
streamingMessageId === message.id && (isLoading || message.content.length === 0) && !message.error_code && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { children: thinkIndicator ?? /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(ThinkIndicator, {}) }),
|
|
2738
2757
|
message.error_code && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2739
2758
|
CallOutResponse,
|
|
@@ -2743,25 +2762,45 @@ var AssistantMessageArea = React34.forwardRef(
|
|
|
2743
2762
|
children: "We have an internal error, please try again later."
|
|
2744
2763
|
}
|
|
2745
2764
|
),
|
|
2746
|
-
message.tooler && !message.error_code && hasToolResult(message.tooler) && toolFactory?.createTool(
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
{
|
|
2750
|
-
role: message.role,
|
|
2751
|
-
isStreaming: streamingMessageId === message.id,
|
|
2752
|
-
handleIsTextStreaming,
|
|
2753
|
-
additionalInfo: streamingMessageId !== message.id ? message?.additionalInfo : void 0,
|
|
2754
|
-
children: message.content
|
|
2755
|
-
}
|
|
2765
|
+
message.tooler && !message.error_code && hasToolResult(message.tooler) && toolFactory?.createTool(
|
|
2766
|
+
message.tooler?.tool_summary?.name,
|
|
2767
|
+
message.tooler?.tool_output?.result
|
|
2756
2768
|
),
|
|
2757
|
-
|
|
2758
|
-
|
|
2769
|
+
message.content && !message.error_code && /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(
|
|
2770
|
+
"div",
|
|
2759
2771
|
{
|
|
2760
|
-
|
|
2761
|
-
message,
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2772
|
+
"data-role": message.role,
|
|
2773
|
+
className: "alq--callout-message-container",
|
|
2774
|
+
children: [
|
|
2775
|
+
message.created_at && streamingMessageId !== message.id && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "text-xs text-muted-foreground/80 pb-1 alq--callout-message-date", children: new Date(Number(message.created_at)).toLocaleString(
|
|
2776
|
+
"es-ES",
|
|
2777
|
+
{
|
|
2778
|
+
hour: "2-digit",
|
|
2779
|
+
minute: "2-digit",
|
|
2780
|
+
hour12: false
|
|
2781
|
+
}
|
|
2782
|
+
) }),
|
|
2783
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2784
|
+
CallOutResponse,
|
|
2785
|
+
{
|
|
2786
|
+
role: message.role,
|
|
2787
|
+
isStreaming: streamingMessageId === message.id,
|
|
2788
|
+
handleIsTextStreaming,
|
|
2789
|
+
additionalInfo: streamingMessageId !== message.id ? message?.additionalInfo : void 0,
|
|
2790
|
+
children: message.content
|
|
2791
|
+
}
|
|
2792
|
+
),
|
|
2793
|
+
actions && streamingMessageId !== message.id && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
|
|
2794
|
+
CallOutActions,
|
|
2795
|
+
{
|
|
2796
|
+
actions,
|
|
2797
|
+
message,
|
|
2798
|
+
role: message.role
|
|
2799
|
+
},
|
|
2800
|
+
message.id
|
|
2801
|
+
)
|
|
2802
|
+
]
|
|
2803
|
+
}
|
|
2765
2804
|
)
|
|
2766
2805
|
]
|
|
2767
2806
|
},
|