@rapidaai/react 1.1.27
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/LICENSE +21 -0
- package/dist/chunk-32YFHJN5.mjs +59 -0
- package/dist/chunk-32YFHJN5.mjs.map +1 -0
- package/dist/chunk-3YJ3G4GZ.mjs +77 -0
- package/dist/chunk-3YJ3G4GZ.mjs.map +1 -0
- package/dist/chunk-AB3ZXSEN.mjs +27569 -0
- package/dist/chunk-AB3ZXSEN.mjs.map +1 -0
- package/dist/chunk-GFACTURU.mjs +50 -0
- package/dist/chunk-GFACTURU.mjs.map +1 -0
- package/dist/chunk-Q4OXFE34.mjs +88 -0
- package/dist/chunk-Q4OXFE34.mjs.map +1 -0
- package/dist/chunk-WT7OUEDJ.mjs +50 -0
- package/dist/chunk-WT7OUEDJ.mjs.map +1 -0
- package/dist/components/connection-status.d.mts +7 -0
- package/dist/components/connection-status.d.ts +7 -0
- package/dist/components/connection-status.js +25321 -0
- package/dist/components/connection-status.js.map +1 -0
- package/dist/components/connection-status.mjs +34 -0
- package/dist/components/connection-status.mjs.map +1 -0
- package/dist/components/device-selector.d.mts +5 -0
- package/dist/components/device-selector.d.ts +5 -0
- package/dist/components/device-selector.js +26800 -0
- package/dist/components/device-selector.js.map +1 -0
- package/dist/components/device-selector.mjs +99 -0
- package/dist/components/device-selector.mjs.map +1 -0
- package/dist/components/live-transcript.d.mts +16 -0
- package/dist/components/live-transcript.d.ts +16 -0
- package/dist/components/live-transcript.js +25376 -0
- package/dist/components/live-transcript.js.map +1 -0
- package/dist/components/live-transcript.mjs +9 -0
- package/dist/components/live-transcript.mjs.map +1 -0
- package/dist/components/text/conversations/index.d.mts +2 -0
- package/dist/components/text/conversations/index.d.ts +2 -0
- package/dist/components/text/conversations/index.js +25344 -0
- package/dist/components/text/conversations/index.js.map +1 -0
- package/dist/components/text/conversations/index.mjs +9 -0
- package/dist/components/text/conversations/index.mjs.map +1 -0
- package/dist/components/text/index.d.mts +2 -0
- package/dist/components/text/index.d.ts +2 -0
- package/dist/components/text/index.js +25344 -0
- package/dist/components/text/index.js.map +1 -0
- package/dist/components/text/index.mjs +9 -0
- package/dist/components/text/index.mjs.map +1 -0
- package/dist/components/visualization/agent-multiband-audio-visualizer.d.mts +18 -0
- package/dist/components/visualization/agent-multiband-audio-visualizer.d.ts +18 -0
- package/dist/components/visualization/agent-multiband-audio-visualizer.js +119 -0
- package/dist/components/visualization/agent-multiband-audio-visualizer.js.map +1 -0
- package/dist/components/visualization/agent-multiband-audio-visualizer.mjs +8 -0
- package/dist/components/visualization/agent-multiband-audio-visualizer.mjs.map +1 -0
- package/dist/index-0bkcyQsE.d.mts +79 -0
- package/dist/index-0bkcyQsE.d.ts +79 -0
- package/dist/index.d.mts +17707 -0
- package/dist/index.d.ts +17707 -0
- package/dist/index.js +66000 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +38213 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles/index.css +656 -0
- package/package.json +117 -0
- package/readme.md +127 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
type AgentState = "disconnected" | "connecting" | "initializing" | "listening" | "thinking" | "speaking";
|
|
7
|
+
type AgentMultibandAudioVisualizerProps = {
|
|
8
|
+
classNames?: string;
|
|
9
|
+
state: AgentState;
|
|
10
|
+
barWidth: number;
|
|
11
|
+
minBarHeight: number;
|
|
12
|
+
maxBarHeight: number;
|
|
13
|
+
barColor?: string;
|
|
14
|
+
frequencies: Float32Array[] | number[][];
|
|
15
|
+
};
|
|
16
|
+
declare const AgentMultibandAudioVisualizer: ({ classNames, state, barWidth, minBarHeight, maxBarHeight, barColor, frequencies, }: AgentMultibandAudioVisualizerProps) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { AgentMultibandAudioVisualizer, type AgentState };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @beta
|
|
5
|
+
*/
|
|
6
|
+
type AgentState = "disconnected" | "connecting" | "initializing" | "listening" | "thinking" | "speaking";
|
|
7
|
+
type AgentMultibandAudioVisualizerProps = {
|
|
8
|
+
classNames?: string;
|
|
9
|
+
state: AgentState;
|
|
10
|
+
barWidth: number;
|
|
11
|
+
minBarHeight: number;
|
|
12
|
+
maxBarHeight: number;
|
|
13
|
+
barColor?: string;
|
|
14
|
+
frequencies: Float32Array[] | number[][];
|
|
15
|
+
};
|
|
16
|
+
declare const AgentMultibandAudioVisualizer: ({ classNames, state, barWidth, minBarHeight, maxBarHeight, barColor, frequencies, }: AgentMultibandAudioVisualizerProps) => react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { AgentMultibandAudioVisualizer, type AgentState };
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/components/visualization/agent-multiband-audio-visualizer.tsx
|
|
21
|
+
var agent_multiband_audio_visualizer_exports = {};
|
|
22
|
+
__export(agent_multiband_audio_visualizer_exports, {
|
|
23
|
+
AgentMultibandAudioVisualizer: () => AgentMultibandAudioVisualizer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(agent_multiband_audio_visualizer_exports);
|
|
26
|
+
|
|
27
|
+
// src/styles/index.ts
|
|
28
|
+
var import_clsx = require("clsx");
|
|
29
|
+
var import_tailwind_merge = require("tailwind-merge");
|
|
30
|
+
var sizes = {
|
|
31
|
+
small: 600,
|
|
32
|
+
medium: 1024,
|
|
33
|
+
large: 1440,
|
|
34
|
+
xlarge: 1920
|
|
35
|
+
};
|
|
36
|
+
var media = Object.keys(sizes).reduce(
|
|
37
|
+
(acc, size) => {
|
|
38
|
+
acc[size] = () => `@media (min-width:${sizes[size]}px)`;
|
|
39
|
+
return acc;
|
|
40
|
+
},
|
|
41
|
+
{}
|
|
42
|
+
);
|
|
43
|
+
function cn(...inputs) {
|
|
44
|
+
return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// src/components/visualization/agent-multiband-audio-visualizer.tsx
|
|
48
|
+
var import_react = require("react");
|
|
49
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
50
|
+
var AgentMultibandAudioVisualizer = ({
|
|
51
|
+
classNames,
|
|
52
|
+
state,
|
|
53
|
+
barWidth,
|
|
54
|
+
minBarHeight,
|
|
55
|
+
maxBarHeight,
|
|
56
|
+
barColor = "bg-white",
|
|
57
|
+
frequencies
|
|
58
|
+
}) => {
|
|
59
|
+
const summedFrequencies = frequencies.map((bandFrequencies) => {
|
|
60
|
+
const sum = bandFrequencies.reduce((a, b) => a + b, 0);
|
|
61
|
+
return Math.sqrt(sum / bandFrequencies.length);
|
|
62
|
+
});
|
|
63
|
+
const [thinkingIndex, setThinkingIndex] = (0, import_react.useState)(
|
|
64
|
+
Math.floor(summedFrequencies.length / 2)
|
|
65
|
+
);
|
|
66
|
+
const [thinkingDirection, setThinkingDirection] = (0, import_react.useState)(
|
|
67
|
+
"right"
|
|
68
|
+
);
|
|
69
|
+
(0, import_react.useEffect)(() => {
|
|
70
|
+
if (state !== "thinking") {
|
|
71
|
+
setThinkingIndex(Math.floor(summedFrequencies.length / 2));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const timeout = setTimeout(() => {
|
|
75
|
+
if (thinkingDirection === "right") {
|
|
76
|
+
if (thinkingIndex === summedFrequencies.length - 1) {
|
|
77
|
+
setThinkingDirection("left");
|
|
78
|
+
setThinkingIndex((prev) => prev - 1);
|
|
79
|
+
} else {
|
|
80
|
+
setThinkingIndex((prev) => prev + 1);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
if (thinkingIndex === 0) {
|
|
84
|
+
setThinkingDirection("right");
|
|
85
|
+
setThinkingIndex((prev) => prev + 1);
|
|
86
|
+
} else {
|
|
87
|
+
setThinkingIndex((prev) => prev - 1);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}, 200);
|
|
91
|
+
return () => clearTimeout(timeout);
|
|
92
|
+
}, [state, summedFrequencies.length, thinkingDirection, thinkingIndex]);
|
|
93
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: cn(classNames, "flex flex-row items-center"), children: summedFrequencies.map((frequency, index) => {
|
|
94
|
+
const isCenter = index === Math.floor(summedFrequencies.length / 2);
|
|
95
|
+
let transform;
|
|
96
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
className: cn(
|
|
100
|
+
barColor,
|
|
101
|
+
"rounded-full",
|
|
102
|
+
isCenter && state === "listening" ? "animate-pulse" : ""
|
|
103
|
+
),
|
|
104
|
+
style: {
|
|
105
|
+
height: minBarHeight + frequency * (maxBarHeight - minBarHeight) + "px",
|
|
106
|
+
width: barWidth + "px",
|
|
107
|
+
transition: "background-color 0.35s ease-out, transform 0.25s ease-out",
|
|
108
|
+
transform
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"frequency-" + index
|
|
112
|
+
);
|
|
113
|
+
}) });
|
|
114
|
+
};
|
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
116
|
+
0 && (module.exports = {
|
|
117
|
+
AgentMultibandAudioVisualizer
|
|
118
|
+
});
|
|
119
|
+
//# sourceMappingURL=agent-multiband-audio-visualizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/visualization/agent-multiband-audio-visualizer.tsx","../../../src/styles/index.ts"],"sourcesContent":["/*\n * Copyright (c) 2024. Rapida\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Author: Prashant <prashant@rapida.ai>\n *\n */\nimport { cn } from \"@/rapida/styles\";\nimport { useEffect, useState } from \"react\";\n\n/**\n * @beta\n */\nexport type AgentState =\n | \"disconnected\"\n | \"connecting\"\n | \"initializing\"\n | \"listening\"\n | \"thinking\"\n | \"speaking\";\n\ntype AgentMultibandAudioVisualizerProps = {\n classNames?: string;\n state: AgentState;\n barWidth: number;\n minBarHeight: number;\n maxBarHeight: number;\n barColor?: string;\n frequencies: Float32Array[] | number[][];\n};\n\nexport const AgentMultibandAudioVisualizer = ({\n classNames,\n state,\n barWidth,\n minBarHeight,\n maxBarHeight,\n barColor = \"bg-white\",\n frequencies,\n}: AgentMultibandAudioVisualizerProps) => {\n const summedFrequencies = frequencies.map((bandFrequencies) => {\n const sum = (bandFrequencies as number[]).reduce((a, b) => a + b, 0);\n return Math.sqrt(sum / bandFrequencies.length);\n });\n\n const [thinkingIndex, setThinkingIndex] = useState(\n Math.floor(summedFrequencies.length / 2)\n );\n const [thinkingDirection, setThinkingDirection] = useState<\"left\" | \"right\">(\n \"right\"\n );\n\n useEffect(() => {\n if (state !== \"thinking\") {\n setThinkingIndex(Math.floor(summedFrequencies.length / 2));\n return;\n }\n const timeout = setTimeout(() => {\n if (thinkingDirection === \"right\") {\n if (thinkingIndex === summedFrequencies.length - 1) {\n setThinkingDirection(\"left\");\n setThinkingIndex((prev) => prev - 1);\n } else {\n setThinkingIndex((prev) => prev + 1);\n }\n } else {\n if (thinkingIndex === 0) {\n setThinkingDirection(\"right\");\n setThinkingIndex((prev) => prev + 1);\n } else {\n setThinkingIndex((prev) => prev - 1);\n }\n }\n }, 200);\n\n return () => clearTimeout(timeout);\n }, [state, summedFrequencies.length, thinkingDirection, thinkingIndex]);\n\n return (\n <div className={cn(classNames, \"flex flex-row items-center\")}>\n {summedFrequencies.map((frequency, index) => {\n const isCenter = index === Math.floor(summedFrequencies.length / 2);\n let transform;\n\n return (\n <div\n className={cn(\n barColor,\n \"rounded-full\",\n isCenter && state === \"listening\" ? \"animate-pulse\" : \"\"\n )}\n key={\"frequency-\" + index}\n style={{\n height:\n minBarHeight + frequency * (maxBarHeight - minBarHeight) + \"px\",\n width: barWidth + \"px\",\n transition:\n \"background-color 0.35s ease-out, transform 0.25s ease-out\",\n transform: transform,\n }}\n ></div>\n );\n })}\n </div>\n );\n};\n","/*\n * Copyright (c) 2024. Rapida\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n *\n * The above copyright notice and this permission notice shall be included in\n * all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *\n * Author: Prashant <prashant@rapida.ai>\n *\n */\nimport { ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/*\n * Media queries utility\n */\n\n/*\n * Inspired by https://github.com/DefinitelyTyped/DefinitelyTyped/issues/32914\n */\n\n// Update your breakpoints if you want\nexport const sizes = {\n small: 600,\n medium: 1024,\n large: 1440,\n xlarge: 1920,\n};\n\n// Iterate through the sizes and create min-width media queries\nexport const media = (Object.keys(sizes) as Array<keyof typeof sizes>).reduce(\n (acc, size) => {\n acc[size] = () => `@media (min-width:${sizes[size]}px)`;\n return acc;\n },\n {} as { [key in keyof typeof sizes]: () => string }\n);\n\n/* Example\nconst SomeDiv = styled.div`\n display: flex;\n ....\n ${media.medium} {\n display: block\n }\n`;\n*/\n\nexport function cn(...inputs: ClassValue[]) {\n return twMerge(clsx(inputs));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACwBA,kBAAiC;AACjC,4BAAwB;AAWjB,IAAM,QAAQ;AAAA,EACnB,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,QAAQ;AACV;AAGO,IAAM,QAAS,OAAO,KAAK,KAAK,EAAgC;AAAA,EACrE,CAAC,KAAK,SAAS;AACb,QAAI,IAAI,IAAI,MAAM,qBAAqB,MAAM,IAAI,CAAC;AAClD,WAAO;AAAA,EACT;AAAA,EACA,CAAC;AACH;AAYO,SAAS,MAAM,QAAsB;AAC1C,aAAO,mCAAQ,kBAAK,MAAM,CAAC;AAC7B;;;ADvCA,mBAAoC;AA6E1B;AAtDH,IAAM,gCAAgC,CAAC;AAAA,EAC5C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,MAA0C;AACxC,QAAM,oBAAoB,YAAY,IAAI,CAAC,oBAAoB;AAC7D,UAAM,MAAO,gBAA6B,OAAO,CAAC,GAAG,MAAM,IAAI,GAAG,CAAC;AACnE,WAAO,KAAK,KAAK,MAAM,gBAAgB,MAAM;AAAA,EAC/C,CAAC;AAED,QAAM,CAAC,eAAe,gBAAgB,QAAI;AAAA,IACxC,KAAK,MAAM,kBAAkB,SAAS,CAAC;AAAA,EACzC;AACA,QAAM,CAAC,mBAAmB,oBAAoB,QAAI;AAAA,IAChD;AAAA,EACF;AAEA,8BAAU,MAAM;AACd,QAAI,UAAU,YAAY;AACxB,uBAAiB,KAAK,MAAM,kBAAkB,SAAS,CAAC,CAAC;AACzD;AAAA,IACF;AACA,UAAM,UAAU,WAAW,MAAM;AAC/B,UAAI,sBAAsB,SAAS;AACjC,YAAI,kBAAkB,kBAAkB,SAAS,GAAG;AAClD,+BAAqB,MAAM;AAC3B,2BAAiB,CAAC,SAAS,OAAO,CAAC;AAAA,QACrC,OAAO;AACL,2BAAiB,CAAC,SAAS,OAAO,CAAC;AAAA,QACrC;AAAA,MACF,OAAO;AACL,YAAI,kBAAkB,GAAG;AACvB,+BAAqB,OAAO;AAC5B,2BAAiB,CAAC,SAAS,OAAO,CAAC;AAAA,QACrC,OAAO;AACL,2BAAiB,CAAC,SAAS,OAAO,CAAC;AAAA,QACrC;AAAA,MACF;AAAA,IACF,GAAG,GAAG;AAEN,WAAO,MAAM,aAAa,OAAO;AAAA,EACnC,GAAG,CAAC,OAAO,kBAAkB,QAAQ,mBAAmB,aAAa,CAAC;AAEtE,SACE,4CAAC,SAAI,WAAW,GAAG,YAAY,4BAA4B,GACxD,4BAAkB,IAAI,CAAC,WAAW,UAAU;AAC3C,UAAM,WAAW,UAAU,KAAK,MAAM,kBAAkB,SAAS,CAAC;AAClE,QAAI;AAEJ,WACE;AAAA,MAAC;AAAA;AAAA,QACC,WAAW;AAAA,UACT;AAAA,UACA;AAAA,UACA,YAAY,UAAU,cAAc,kBAAkB;AAAA,QACxD;AAAA,QAEA,OAAO;AAAA,UACL,QACE,eAAe,aAAa,eAAe,gBAAgB;AAAA,UAC7D,OAAO,WAAW;AAAA,UAClB,YACE;AAAA,UACF;AAAA,QACF;AAAA;AAAA,MARK,eAAe;AAAA,IASrB;AAAA,EAEL,CAAC,GACH;AAEJ;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React__default, { FC, HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
declare enum Feedback {
|
|
4
|
+
Helpful = "helpful",
|
|
5
|
+
NotHelpful = "not_helpful",
|
|
6
|
+
Other = "other"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
declare enum MessageRole {
|
|
13
|
+
System = "system",
|
|
14
|
+
User = "user"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
declare enum MessageStatus {
|
|
20
|
+
/**
|
|
21
|
+
* Pending status for the message
|
|
22
|
+
*/
|
|
23
|
+
Pending = "pending",
|
|
24
|
+
/**
|
|
25
|
+
* complete the message
|
|
26
|
+
*/
|
|
27
|
+
Complete = "complete"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
interface Message {
|
|
33
|
+
/**
|
|
34
|
+
* id of the message
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
/**
|
|
38
|
+
* role of the message who had sent it
|
|
39
|
+
*/
|
|
40
|
+
role: MessageRole;
|
|
41
|
+
/**
|
|
42
|
+
* list of sentences in the message
|
|
43
|
+
*/
|
|
44
|
+
messages: string[];
|
|
45
|
+
/**
|
|
46
|
+
* feedback given to the message
|
|
47
|
+
*/
|
|
48
|
+
feedback?: Feedback;
|
|
49
|
+
/**
|
|
50
|
+
*time
|
|
51
|
+
*/
|
|
52
|
+
time: Date;
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
status: MessageStatus;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Props for the Conversation component.
|
|
61
|
+
* @interface ConversationProps
|
|
62
|
+
* @extends HTMLAttributes<HTMLDivElement>
|
|
63
|
+
*/
|
|
64
|
+
interface ConversationProps extends HTMLAttributes<HTMLDivElement> {
|
|
65
|
+
/**
|
|
66
|
+
* A React component used to wrap individual messages.
|
|
67
|
+
* It should accept props of type HTMLAttributes<HTMLLIElement> and a 'message' prop of type Message.
|
|
68
|
+
*/
|
|
69
|
+
MessageWrapper: React__default.ComponentType<HTMLAttributes<HTMLLIElement> & {
|
|
70
|
+
message: Message;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* An optional array of initial messages to populate the conversation.
|
|
74
|
+
*/
|
|
75
|
+
intialConversations?: Message[];
|
|
76
|
+
}
|
|
77
|
+
declare const Conversation: FC<ConversationProps>;
|
|
78
|
+
|
|
79
|
+
export { Conversation as C, Feedback as F, type Message as M, MessageRole as a, MessageStatus as b };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React__default, { FC, HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
declare enum Feedback {
|
|
4
|
+
Helpful = "helpful",
|
|
5
|
+
NotHelpful = "not_helpful",
|
|
6
|
+
Other = "other"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
declare enum MessageRole {
|
|
13
|
+
System = "system",
|
|
14
|
+
User = "user"
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
declare enum MessageStatus {
|
|
20
|
+
/**
|
|
21
|
+
* Pending status for the message
|
|
22
|
+
*/
|
|
23
|
+
Pending = "pending",
|
|
24
|
+
/**
|
|
25
|
+
* complete the message
|
|
26
|
+
*/
|
|
27
|
+
Complete = "complete"
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
*/
|
|
32
|
+
interface Message {
|
|
33
|
+
/**
|
|
34
|
+
* id of the message
|
|
35
|
+
*/
|
|
36
|
+
id: string;
|
|
37
|
+
/**
|
|
38
|
+
* role of the message who had sent it
|
|
39
|
+
*/
|
|
40
|
+
role: MessageRole;
|
|
41
|
+
/**
|
|
42
|
+
* list of sentences in the message
|
|
43
|
+
*/
|
|
44
|
+
messages: string[];
|
|
45
|
+
/**
|
|
46
|
+
* feedback given to the message
|
|
47
|
+
*/
|
|
48
|
+
feedback?: Feedback;
|
|
49
|
+
/**
|
|
50
|
+
*time
|
|
51
|
+
*/
|
|
52
|
+
time: Date;
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
*/
|
|
56
|
+
status: MessageStatus;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Props for the Conversation component.
|
|
61
|
+
* @interface ConversationProps
|
|
62
|
+
* @extends HTMLAttributes<HTMLDivElement>
|
|
63
|
+
*/
|
|
64
|
+
interface ConversationProps extends HTMLAttributes<HTMLDivElement> {
|
|
65
|
+
/**
|
|
66
|
+
* A React component used to wrap individual messages.
|
|
67
|
+
* It should accept props of type HTMLAttributes<HTMLLIElement> and a 'message' prop of type Message.
|
|
68
|
+
*/
|
|
69
|
+
MessageWrapper: React__default.ComponentType<HTMLAttributes<HTMLLIElement> & {
|
|
70
|
+
message: Message;
|
|
71
|
+
}>;
|
|
72
|
+
/**
|
|
73
|
+
* An optional array of initial messages to populate the conversation.
|
|
74
|
+
*/
|
|
75
|
+
intialConversations?: Message[];
|
|
76
|
+
}
|
|
77
|
+
declare const Conversation: FC<ConversationProps>;
|
|
78
|
+
|
|
79
|
+
export { Conversation as C, Feedback as F, type Message as M, MessageRole as a, MessageStatus as b };
|