vuchat 1.0.0
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/.github/workflows/publish.yaml +25 -0
- package/.yarnrc.yml +2 -0
- package/Readme.md +21 -0
- package/custom.d.ts +6 -0
- package/dist/cjs/index.js +399 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types/components/Buttons/VuButton.d.ts +6 -0
- package/dist/cjs/types/components/Buttons/VuIconButton.d.ts +12 -0
- package/dist/cjs/types/components/Buttons/index.d.ts +2 -0
- package/dist/cjs/types/components/Buttons/styled.d.ts +5 -0
- package/dist/cjs/types/components/Buttons/types.d.ts +13 -0
- package/dist/cjs/types/components/ErrorComponent/index.d.ts +7 -0
- package/dist/cjs/types/components/ErrorComponent/styled.d.ts +5 -0
- package/dist/cjs/types/components/Header/index.d.ts +6 -0
- package/dist/cjs/types/components/Header/styled.d.ts +3 -0
- package/dist/cjs/types/components/Icons/VuIcon.d.ts +8 -0
- package/dist/cjs/types/components/Icons/index.d.ts +1 -0
- package/dist/cjs/types/components/SearchInput/SearchInput.d.ts +5 -0
- package/dist/cjs/types/components/SearchInput/index.d.ts +1 -0
- package/dist/cjs/types/components/SearchInput/styled.d.ts +7 -0
- package/dist/cjs/types/components/TextArea/VuTextArea.d.ts +7 -0
- package/dist/cjs/types/components/TextArea/index.d.ts +1 -0
- package/dist/cjs/types/components/TextArea/styled.d.ts +8 -0
- package/dist/cjs/types/components/api/api.d.ts +9 -0
- package/dist/cjs/types/components/api/axiosInstance.d.ts +29 -0
- package/dist/cjs/types/components/api/types.d.ts +27 -0
- package/dist/cjs/types/components/index.d.ts +5 -0
- package/dist/cjs/types/index.d.ts +2 -0
- package/dist/cjs/types/pages/VuChat.d.ts +8 -0
- package/dist/cjs/types/pages/chatbot/Chatbot.d.ts +6 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/ChatSection.d.ts +10 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.d.ts +6 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ActionButtons/styled.d.ts +2 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/Charts/Charts.d.ts +9 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/Charts/styled.d.ts +4 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.d.ts +3 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/EmptyState/styled.d.ts +4 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.d.ts +6 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/QuestionCard/styled.d.ts +4 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.d.ts +11 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseCard/styled.d.ts +8 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.d.ts +3 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.d.ts +4 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.d.ts +3 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.d.ts +2 -0
- package/dist/cjs/types/pages/chatbot/components/ChatSection/styled.d.ts +5 -0
- package/dist/cjs/types/pages/chatbot/components/RecentConversations/RecentConversations.d.ts +9 -0
- package/dist/cjs/types/pages/chatbot/components/RecentConversations/questions.d.ts +1 -0
- package/dist/cjs/types/pages/chatbot/components/RecentConversations/styled.d.ts +11 -0
- package/dist/cjs/types/pages/chatbot/index.d.ts +1 -0
- package/dist/cjs/types/pages/chatbot/styled.d.ts +14 -0
- package/dist/cjs/types/pages/index.d.ts +1 -0
- package/dist/cjs/types/pages/styled.d.ts +2 -0
- package/dist/cjs/types/utils/icons.d.ts +1 -0
- package/dist/cjs/types/utils/iconsList.d.ts +2 -0
- package/dist/cjs/types/utils/index.d.ts +2 -0
- package/dist/esm/index.js +399 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types/components/Buttons/VuButton.d.ts +6 -0
- package/dist/esm/types/components/Buttons/VuIconButton.d.ts +12 -0
- package/dist/esm/types/components/Buttons/index.d.ts +2 -0
- package/dist/esm/types/components/Buttons/styled.d.ts +5 -0
- package/dist/esm/types/components/Buttons/types.d.ts +13 -0
- package/dist/esm/types/components/ErrorComponent/index.d.ts +7 -0
- package/dist/esm/types/components/ErrorComponent/styled.d.ts +5 -0
- package/dist/esm/types/components/Header/index.d.ts +6 -0
- package/dist/esm/types/components/Header/styled.d.ts +3 -0
- package/dist/esm/types/components/Icons/VuIcon.d.ts +8 -0
- package/dist/esm/types/components/Icons/index.d.ts +1 -0
- package/dist/esm/types/components/SearchInput/SearchInput.d.ts +5 -0
- package/dist/esm/types/components/SearchInput/index.d.ts +1 -0
- package/dist/esm/types/components/SearchInput/styled.d.ts +7 -0
- package/dist/esm/types/components/TextArea/VuTextArea.d.ts +7 -0
- package/dist/esm/types/components/TextArea/index.d.ts +1 -0
- package/dist/esm/types/components/TextArea/styled.d.ts +8 -0
- package/dist/esm/types/components/api/api.d.ts +9 -0
- package/dist/esm/types/components/api/axiosInstance.d.ts +29 -0
- package/dist/esm/types/components/api/types.d.ts +27 -0
- package/dist/esm/types/components/index.d.ts +5 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/pages/VuChat.d.ts +8 -0
- package/dist/esm/types/pages/chatbot/Chatbot.d.ts +6 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/ChatSection.d.ts +10 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.d.ts +6 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/ActionButtons/styled.d.ts +2 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/Charts/Charts.d.ts +9 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/Charts/styled.d.ts +4 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.d.ts +3 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/EmptyState/styled.d.ts +4 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.d.ts +6 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/QuestionCard/styled.d.ts +4 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.d.ts +11 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseCard/styled.d.ts +8 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.d.ts +3 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.d.ts +4 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.d.ts +3 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.d.ts +2 -0
- package/dist/esm/types/pages/chatbot/components/ChatSection/styled.d.ts +5 -0
- package/dist/esm/types/pages/chatbot/components/RecentConversations/RecentConversations.d.ts +9 -0
- package/dist/esm/types/pages/chatbot/components/RecentConversations/questions.d.ts +1 -0
- package/dist/esm/types/pages/chatbot/components/RecentConversations/styled.d.ts +11 -0
- package/dist/esm/types/pages/chatbot/index.d.ts +1 -0
- package/dist/esm/types/pages/chatbot/styled.d.ts +14 -0
- package/dist/esm/types/pages/index.d.ts +1 -0
- package/dist/esm/types/pages/styled.d.ts +2 -0
- package/dist/esm/types/utils/icons.d.ts +1 -0
- package/dist/esm/types/utils/iconsList.d.ts +2 -0
- package/dist/esm/types/utils/index.d.ts +2 -0
- package/dist/types/components/Buttons/VuButton.d.ts +6 -0
- package/dist/types/components/Buttons/VuIconButton.d.ts +12 -0
- package/dist/types/components/Buttons/index.d.ts +2 -0
- package/dist/types/components/Buttons/styled.d.ts +5 -0
- package/dist/types/components/Buttons/types.d.ts +13 -0
- package/dist/types/components/ErrorComponent/index.d.ts +7 -0
- package/dist/types/components/ErrorComponent/styled.d.ts +5 -0
- package/dist/types/components/Header/index.d.ts +6 -0
- package/dist/types/components/Header/styled.d.ts +3 -0
- package/dist/types/components/Icons/VuIcon.d.ts +8 -0
- package/dist/types/components/Icons/index.d.ts +1 -0
- package/dist/types/components/SearchInput/SearchInput.d.ts +5 -0
- package/dist/types/components/SearchInput/index.d.ts +1 -0
- package/dist/types/components/SearchInput/styled.d.ts +7 -0
- package/dist/types/components/TextArea/VuTextArea.d.ts +7 -0
- package/dist/types/components/TextArea/index.d.ts +1 -0
- package/dist/types/components/TextArea/styled.d.ts +8 -0
- package/dist/types/components/api/api.d.ts +9 -0
- package/dist/types/components/api/axiosInstance.d.ts +29 -0
- package/dist/types/components/api/types.d.ts +27 -0
- package/dist/types/components/index.d.ts +5 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/pages/VuChat.d.ts +8 -0
- package/dist/types/pages/chatbot/Chatbot.d.ts +6 -0
- package/dist/types/pages/chatbot/components/ChatSection/ChatSection.d.ts +10 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.d.ts +6 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/ActionButtons/styled.d.ts +2 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/Charts/Charts.d.ts +9 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/Charts/styled.d.ts +4 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.d.ts +3 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/EmptyState/styled.d.ts +4 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.d.ts +6 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/QuestionCard/styled.d.ts +4 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.d.ts +11 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/ResponseCard/styled.d.ts +8 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.d.ts +3 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.d.ts +4 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.d.ts +3 -0
- package/dist/types/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.d.ts +2 -0
- package/dist/types/pages/chatbot/components/ChatSection/styled.d.ts +5 -0
- package/dist/types/pages/chatbot/components/RecentConversations/RecentConversations.d.ts +9 -0
- package/dist/types/pages/chatbot/components/RecentConversations/questions.d.ts +1 -0
- package/dist/types/pages/chatbot/components/RecentConversations/styled.d.ts +11 -0
- package/dist/types/pages/chatbot/index.d.ts +1 -0
- package/dist/types/pages/chatbot/styled.d.ts +14 -0
- package/dist/types/pages/index.d.ts +1 -0
- package/dist/types/pages/styled.d.ts +2 -0
- package/dist/types/utils/icons.d.ts +1 -0
- package/dist/types/utils/iconsList.d.ts +2 -0
- package/dist/types/utils/index.d.ts +2 -0
- package/dist/types.d.ts +14 -0
- package/package.json +56 -0
- package/postcss.config.ts +6 -0
- package/rollup.config-1696564443080.cjs +67 -0
- package/rollup.config.ts +67 -0
- package/src/assets/icons/add.svg +1 -0
- package/src/assets/icons/arrow-left.svg +1 -0
- package/src/assets/icons/bot.svg +35 -0
- package/src/assets/icons/bot1.svg +1 -0
- package/src/assets/icons/copy.svg +1 -0
- package/src/assets/icons/delete.svg +1 -0
- package/src/assets/icons/download.svg +8 -0
- package/src/assets/icons/error.svg +12 -0
- package/src/assets/icons/load.svg +5 -0
- package/src/assets/icons/message.svg +4 -0
- package/src/assets/icons/search.svg +1 -0
- package/src/assets/icons/send.svg +11 -0
- package/src/assets/icons/thumbs-down.svg +1 -0
- package/src/assets/icons/thumbs-up.svg +1 -0
- package/src/assets/icons/user.svg +12 -0
- package/src/components/Buttons/VuButton.tsx +26 -0
- package/src/components/Buttons/VuIconButton.tsx +31 -0
- package/src/components/Buttons/index.ts +2 -0
- package/src/components/Buttons/styled.ts +63 -0
- package/src/components/Buttons/types.ts +17 -0
- package/src/components/ErrorComponent/index.tsx +23 -0
- package/src/components/ErrorComponent/styled.ts +28 -0
- package/src/components/Header/index.tsx +35 -0
- package/src/components/Header/styled.ts +12 -0
- package/src/components/Icons/VuIcon.tsx +30 -0
- package/src/components/Icons/index.ts +1 -0
- package/src/components/SearchInput/SearchInput.tsx +21 -0
- package/src/components/SearchInput/index.ts +1 -0
- package/src/components/SearchInput/styled.ts +25 -0
- package/src/components/TextArea/VuTextArea.tsx +39 -0
- package/src/components/TextArea/index.ts +1 -0
- package/src/components/TextArea/styled.ts +39 -0
- package/src/components/api/api.ts +51 -0
- package/src/components/api/axiosInstance.ts +5 -0
- package/src/components/api/types.ts +31 -0
- package/src/components/index.ts +5 -0
- package/src/index.css +3 -0
- package/src/index.ts +2 -0
- package/src/pages/VuChat.tsx +36 -0
- package/src/pages/chatbot/Chatbot.tsx +171 -0
- package/src/pages/chatbot/components/ChatSection/ChatSection.tsx +201 -0
- package/src/pages/chatbot/components/ChatSection/components/ActionButtons/ActionButtons.tsx +30 -0
- package/src/pages/chatbot/components/ChatSection/components/ActionButtons/styled.ts +10 -0
- package/src/pages/chatbot/components/ChatSection/components/Charts/Charts.tsx +81 -0
- package/src/pages/chatbot/components/ChatSection/components/Charts/styled.ts +25 -0
- package/src/pages/chatbot/components/ChatSection/components/EmptyState/EmptyState.tsx +26 -0
- package/src/pages/chatbot/components/ChatSection/components/EmptyState/styled.ts +27 -0
- package/src/pages/chatbot/components/ChatSection/components/QuestionCard/QuestionCard.tsx +21 -0
- package/src/pages/chatbot/components/ChatSection/components/QuestionCard/styled.ts +20 -0
- package/src/pages/chatbot/components/ChatSection/components/ResponseCard/ResponseCard.tsx +181 -0
- package/src/pages/chatbot/components/ChatSection/components/ResponseCard/styled.ts +44 -0
- package/src/pages/chatbot/components/ChatSection/components/ResponseLoader/ResponseLoader.tsx +23 -0
- package/src/pages/chatbot/components/ChatSection/components/ResponseLoader/styled.ts +23 -0
- package/src/pages/chatbot/components/ChatSection/components/SuggestedQuestions/SuggestedQuestions.tsx +18 -0
- package/src/pages/chatbot/components/ChatSection/components/SuggestedQuestions/styled.ts +12 -0
- package/src/pages/chatbot/components/ChatSection/styled.ts +27 -0
- package/src/pages/chatbot/components/RecentConversations/RecentConversations.tsx +129 -0
- package/src/pages/chatbot/components/RecentConversations/questions.ts +24 -0
- package/src/pages/chatbot/components/RecentConversations/styled.ts +49 -0
- package/src/pages/chatbot/index.ts +1 -0
- package/src/pages/chatbot/styled.ts +77 -0
- package/src/pages/index.ts +1 -0
- package/src/pages/styled.ts +9 -0
- package/src/utils/icons.ts +3 -0
- package/src/utils/iconsList.tsx +14 -0
- package/src/utils/index.ts +2 -0
- package/tailwind.config.ts +18 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { useRef, useState } from "react";
|
|
2
|
+
import { VuIcon } from "../../../../../../components/Icons/VuIcon";
|
|
3
|
+
import {
|
|
4
|
+
ChartContainer,
|
|
5
|
+
Container,
|
|
6
|
+
ErrorContainer,
|
|
7
|
+
ResponseContainer,
|
|
8
|
+
SideButtonsContainer,
|
|
9
|
+
TextContainer,
|
|
10
|
+
TimeContainer,
|
|
11
|
+
} from "./styled";
|
|
12
|
+
|
|
13
|
+
import { VuIconButton } from "../../../../../../components/Buttons";
|
|
14
|
+
import React from "react";
|
|
15
|
+
import BotIcon from "../../../../../../assets/icons/bot.svg";
|
|
16
|
+
import CopyIcon from "../../../../../../assets/icons/copy.svg";
|
|
17
|
+
import ThumbsUpIcon from "../../../../../../assets/icons/thumbs-up.svg";
|
|
18
|
+
import ThumbsDownIcon from "../../../../../../assets/icons/thumbs-down.svg";
|
|
19
|
+
import { Charts } from "../Charts/Charts";
|
|
20
|
+
import { Tooltip } from "react-tooltip";
|
|
21
|
+
import { useMutation } from "react-query";
|
|
22
|
+
import { likeDislikeChat } from "../../../../../../components/api/api";
|
|
23
|
+
|
|
24
|
+
// Keeping this data for future reference.
|
|
25
|
+
|
|
26
|
+
/* const pieData = {
|
|
27
|
+
labels: ["Red", "Blue", "Yellow"],
|
|
28
|
+
datasets: [
|
|
29
|
+
{
|
|
30
|
+
label: "My First Dataset",
|
|
31
|
+
data: [300, 50, 100],
|
|
32
|
+
backgroundColor: [
|
|
33
|
+
"rgb(255, 99, 132)",
|
|
34
|
+
"rgb(54, 162, 235)",
|
|
35
|
+
"rgb(255, 205, 86)",
|
|
36
|
+
],
|
|
37
|
+
hoverOffset: 4,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
}; */
|
|
41
|
+
|
|
42
|
+
// const lineData = {
|
|
43
|
+
// labels: ["January", "February", "March", "April", "May", "June", "July"],
|
|
44
|
+
// datasets: [
|
|
45
|
+
// {
|
|
46
|
+
// label: "My First Dataset",
|
|
47
|
+
// data: [65, 59, 80, 81, 56, 55, 40],
|
|
48
|
+
// backgroundColor: [
|
|
49
|
+
// "rgba(255, 99, 132, 0.2)",
|
|
50
|
+
// "rgba(255, 159, 64, 0.2)",
|
|
51
|
+
// "rgba(255, 205, 86, 0.2)",
|
|
52
|
+
// "rgba(75, 192, 192, 0.2)",
|
|
53
|
+
// "rgba(54, 162, 235, 0.2)",
|
|
54
|
+
// "rgba(153, 102, 255, 0.2)",
|
|
55
|
+
// "rgba(201, 203, 207, 0.2)",
|
|
56
|
+
// ],
|
|
57
|
+
// borderColor: [
|
|
58
|
+
// "rgb(255, 99, 132)",
|
|
59
|
+
// "rgb(255, 159, 64)",
|
|
60
|
+
// "rgb(255, 205, 86)",
|
|
61
|
+
// "rgb(75, 192, 192)",
|
|
62
|
+
// "rgb(54, 162, 235)",
|
|
63
|
+
// "rgb(153, 102, 255)",
|
|
64
|
+
// "rgb(201, 203, 207)",
|
|
65
|
+
// ],
|
|
66
|
+
// borderWidth: 1,
|
|
67
|
+
// },
|
|
68
|
+
// ],
|
|
69
|
+
// };
|
|
70
|
+
|
|
71
|
+
interface ResponseCardProps {
|
|
72
|
+
answer: string;
|
|
73
|
+
chartData?: any;
|
|
74
|
+
onError?: boolean;
|
|
75
|
+
chatID?: number;
|
|
76
|
+
like?: number;
|
|
77
|
+
dislike?: number;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export const ResponseCard: React.FC<ResponseCardProps> = ({
|
|
81
|
+
answer,
|
|
82
|
+
chartData,
|
|
83
|
+
onError = false,
|
|
84
|
+
chatID,
|
|
85
|
+
like,
|
|
86
|
+
dislike,
|
|
87
|
+
}) => {
|
|
88
|
+
const divRef = useRef<HTMLDivElement>(null);
|
|
89
|
+
const [likeDislike, setLikeDislike] = useState<{
|
|
90
|
+
like: boolean;
|
|
91
|
+
dislike: boolean;
|
|
92
|
+
}>({
|
|
93
|
+
like: !!like,
|
|
94
|
+
dislike: !!dislike,
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const createLikeDislikeMutation = useMutation({
|
|
98
|
+
mutationFn: likeDislikeChat,
|
|
99
|
+
onSuccess: (data) => {
|
|
100
|
+
setLikeDislike({
|
|
101
|
+
like: data.like,
|
|
102
|
+
dislike: data.dislike,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const handleCopyClick = async () => {
|
|
108
|
+
if (divRef.current) {
|
|
109
|
+
const textToCopy = divRef.current.textContent || "";
|
|
110
|
+
try {
|
|
111
|
+
await navigator.clipboard.writeText(textToCopy);
|
|
112
|
+
} catch (err) {
|
|
113
|
+
console.error("Failed to copy text: ", err);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const handleLikeDislike = (like: number, dislike: number) => {
|
|
119
|
+
chatID &&
|
|
120
|
+
createLikeDislikeMutation.mutate({
|
|
121
|
+
chatID: chatID,
|
|
122
|
+
like,
|
|
123
|
+
dislike,
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
const mapChartData = () => {
|
|
128
|
+
const labels = chartData.chart_labels;
|
|
129
|
+
const data = chartData.chart_values;
|
|
130
|
+
return {
|
|
131
|
+
labels,
|
|
132
|
+
datasets: [
|
|
133
|
+
{
|
|
134
|
+
label: chartData.chart_title,
|
|
135
|
+
data,
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
return (
|
|
142
|
+
<Container>
|
|
143
|
+
<ResponseContainer>
|
|
144
|
+
<div>
|
|
145
|
+
<VuIcon svg={BotIcon} size={32} />
|
|
146
|
+
</div>
|
|
147
|
+
<TextContainer ref={divRef}>
|
|
148
|
+
{!onError ? answer : <ErrorContainer>{answer}</ErrorContainer>}
|
|
149
|
+
</TextContainer>
|
|
150
|
+
{!onError && (
|
|
151
|
+
<SideButtonsContainer>
|
|
152
|
+
<VuIconButton onClick={handleCopyClick} icon={CopyIcon} />
|
|
153
|
+
<VuIconButton
|
|
154
|
+
icon={ThumbsUpIcon}
|
|
155
|
+
data-tooltip-id="tooltip-btns"
|
|
156
|
+
data-tooltip-content="Like"
|
|
157
|
+
iconColor={likeDislike.like ? "fill-rose-500" : undefined}
|
|
158
|
+
onClick={() => handleLikeDislike(1, 0)}
|
|
159
|
+
/>
|
|
160
|
+
<VuIconButton
|
|
161
|
+
icon={ThumbsDownIcon}
|
|
162
|
+
data-tooltip-id="tooltip-btns"
|
|
163
|
+
data-tooltip-content="Dislike"
|
|
164
|
+
iconColor={likeDislike.dislike ? "fill-rose-500" : undefined}
|
|
165
|
+
onClick={() => handleLikeDislike(0, 1)}
|
|
166
|
+
/>
|
|
167
|
+
</SideButtonsContainer>
|
|
168
|
+
)}
|
|
169
|
+
</ResponseContainer>
|
|
170
|
+
{chartData && chartData.chart_possible && (
|
|
171
|
+
<ChartContainer>
|
|
172
|
+
{!chartData.error && (
|
|
173
|
+
<Charts type={chartData.chart_type} data={mapChartData()} />
|
|
174
|
+
)}
|
|
175
|
+
</ChartContainer>
|
|
176
|
+
)}
|
|
177
|
+
{/* <TimeContainer>2 Oct 2:22 PM</TimeContainer> */}
|
|
178
|
+
<Tooltip id="tooltip-btns" place="right" />
|
|
179
|
+
</Container>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import tw from "tailwind-styled-components";
|
|
2
|
+
|
|
3
|
+
export const Container = tw.div`
|
|
4
|
+
bg-white
|
|
5
|
+
px-10
|
|
6
|
+
py-5
|
|
7
|
+
w-full
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
export const ResponseContainer = tw.div`
|
|
11
|
+
flex
|
|
12
|
+
gap-x-3
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const ChartContainer = tw.div`
|
|
16
|
+
flex
|
|
17
|
+
justify-center
|
|
18
|
+
mt-4
|
|
19
|
+
w-full
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
export const TimeContainer = tw.div`
|
|
23
|
+
flex
|
|
24
|
+
justify-end
|
|
25
|
+
text-xs
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
export const TextContainer = tw.div`
|
|
29
|
+
text-sm
|
|
30
|
+
text-left
|
|
31
|
+
p-1
|
|
32
|
+
w-full
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const SideButtonsContainer = tw.div`
|
|
36
|
+
flex
|
|
37
|
+
flex-col
|
|
38
|
+
pl-7
|
|
39
|
+
gap-2
|
|
40
|
+
`
|
|
41
|
+
|
|
42
|
+
export const ErrorContainer = tw.div`
|
|
43
|
+
text-red-500
|
|
44
|
+
`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Container, ReponseLoaderWrapper, ContentContainer } from "./styled";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import SyncLoader from "react-spinners/SyncLoader";
|
|
4
|
+
//@ts-ignore
|
|
5
|
+
import Skeleton from "react-loading-skeleton";
|
|
6
|
+
import "react-loading-skeleton/dist/skeleton.css";
|
|
7
|
+
|
|
8
|
+
export const ResponseLoader: React.FC = () => {
|
|
9
|
+
return (
|
|
10
|
+
<Container>
|
|
11
|
+
<ReponseLoaderWrapper>
|
|
12
|
+
<SyncLoader color={"#000"} size={4} aria-label="Loading Spinner" />
|
|
13
|
+
<ContentContainer>
|
|
14
|
+
<p>Generating Response</p>
|
|
15
|
+
<Skeleton width={"60%"} />
|
|
16
|
+
<Skeleton width={"55%"} />
|
|
17
|
+
<Skeleton width={"50%"} />
|
|
18
|
+
<Skeleton width={"45%"} />
|
|
19
|
+
</ContentContainer>
|
|
20
|
+
</ReponseLoaderWrapper>
|
|
21
|
+
</Container>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import tw from "tailwind-styled-components";
|
|
2
|
+
|
|
3
|
+
export const Container = tw.div`
|
|
4
|
+
bg-white
|
|
5
|
+
px-10
|
|
6
|
+
py-4
|
|
7
|
+
my-5
|
|
8
|
+
w-full
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export const ReponseLoaderWrapper = tw.div`
|
|
12
|
+
flex
|
|
13
|
+
gap-x-3
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export const ContentContainer = tw.div`
|
|
17
|
+
flex
|
|
18
|
+
flex-col
|
|
19
|
+
text-sm
|
|
20
|
+
text-left
|
|
21
|
+
w-full
|
|
22
|
+
gap-2
|
|
23
|
+
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Container } from "./styled";
|
|
3
|
+
import { VuButton } from "../../../../../../components";
|
|
4
|
+
import { Questions } from "../../../RecentConversations/questions";
|
|
5
|
+
|
|
6
|
+
const SuggestedQuestions: React.FC = () => {
|
|
7
|
+
return (
|
|
8
|
+
<Container>
|
|
9
|
+
{Questions.slice(0, 6).map((question) => (
|
|
10
|
+
<VuButton $fill="text">
|
|
11
|
+
<span className="text-sm">{question}</span>
|
|
12
|
+
</VuButton>
|
|
13
|
+
))}
|
|
14
|
+
</Container>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default SuggestedQuestions;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import tw from "tailwind-styled-components";
|
|
2
|
+
|
|
3
|
+
export const Container = tw.div`
|
|
4
|
+
flex
|
|
5
|
+
flex-col
|
|
6
|
+
items-center
|
|
7
|
+
justify-center
|
|
8
|
+
px-[7.5rem]
|
|
9
|
+
py-5
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const ChartWrapper = tw.div`
|
|
13
|
+
grow
|
|
14
|
+
overflow-y-auto
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const InputContainer = tw.div`
|
|
18
|
+
bg-alice_blue
|
|
19
|
+
p-2
|
|
20
|
+
w-full
|
|
21
|
+
pl-[7.5rem]
|
|
22
|
+
pr-[8rem]`;
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
export const ConversationContainer = tw.div`
|
|
26
|
+
w-full
|
|
27
|
+
`
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import React, { useState, FC, useEffect } from "react";
|
|
2
|
+
import {
|
|
3
|
+
Container,
|
|
4
|
+
IconAndTextContainer,
|
|
5
|
+
IconAndTextSubContainer,
|
|
6
|
+
IconContainer,
|
|
7
|
+
ListContainer,
|
|
8
|
+
QuestionContainer,
|
|
9
|
+
} from "./styled";
|
|
10
|
+
|
|
11
|
+
import { Tooltip } from "react-tooltip";
|
|
12
|
+
import { VuIconButton } from "../../../../components/Buttons";
|
|
13
|
+
import { VuIcon } from "../../../../components/Icons/VuIcon";
|
|
14
|
+
import MessageIcon from "../../../../assets/icons/message.svg";
|
|
15
|
+
import DeleteIcon from "../../../../assets/icons/delete.svg";
|
|
16
|
+
import {
|
|
17
|
+
deleteConversation,
|
|
18
|
+
getConversations,
|
|
19
|
+
} from "../../../../components/api/api";
|
|
20
|
+
import { useQuery, useMutation, useQueryClient } from "react-query";
|
|
21
|
+
import ClipLoader from "react-spinners/ClipLoader";
|
|
22
|
+
import { Conversations } from "../../../../components/api/types";
|
|
23
|
+
import { LoaderContainer } from "../../styled";
|
|
24
|
+
import { ChatInfo } from "../../Chatbot";
|
|
25
|
+
|
|
26
|
+
interface Props {
|
|
27
|
+
handleSetConversationInfo: (chatInfoOld?: ChatInfo) => void;
|
|
28
|
+
searchQuery: string;
|
|
29
|
+
currentConversationInfo?: ChatInfo;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function filterData(data: Conversations, query: string) {
|
|
33
|
+
return data.filter((item) =>
|
|
34
|
+
item.chat_info[0].question.toLowerCase().includes(query.toLowerCase())
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const RecentConversations: FC<Props> = ({
|
|
39
|
+
handleSetConversationInfo,
|
|
40
|
+
searchQuery,
|
|
41
|
+
currentConversationInfo,
|
|
42
|
+
}) => {
|
|
43
|
+
const [filteredData, setFilteredData] = useState<Conversations>([]);
|
|
44
|
+
|
|
45
|
+
const queryClient = useQueryClient();
|
|
46
|
+
|
|
47
|
+
const { isLoading, status, data, refetch } = useQuery({
|
|
48
|
+
queryKey: "conversations",
|
|
49
|
+
queryFn: () => getConversations(),
|
|
50
|
+
enabled: false,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const filtered = filterData(data ?? [], searchQuery);
|
|
55
|
+
setFilteredData(filtered);
|
|
56
|
+
}, [data, searchQuery]);
|
|
57
|
+
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
refetch();
|
|
60
|
+
}, [currentConversationInfo]);
|
|
61
|
+
|
|
62
|
+
const deleteChatMutation = useMutation({
|
|
63
|
+
mutationFn: deleteConversation,
|
|
64
|
+
onSuccess: (_, conversationID) => {
|
|
65
|
+
queryClient.invalidateQueries(["conversations", conversationID]);
|
|
66
|
+
handleSetConversationInfo();
|
|
67
|
+
queryClient.invalidateQueries("conversations");
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
if (status === "loading")
|
|
72
|
+
return (
|
|
73
|
+
<LoaderContainer>
|
|
74
|
+
<ClipLoader
|
|
75
|
+
color={"#000"}
|
|
76
|
+
loading={isLoading}
|
|
77
|
+
size={25}
|
|
78
|
+
aria-label="Loading Spinner"
|
|
79
|
+
data-testid="loader"
|
|
80
|
+
/>
|
|
81
|
+
</LoaderContainer>
|
|
82
|
+
);
|
|
83
|
+
if (status === "error") return <h1>Error in Loading Recent Conversations</h1>;
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Container>
|
|
87
|
+
<div>Recent Conversations</div>
|
|
88
|
+
<ListContainer>
|
|
89
|
+
{filteredData?.map((question, index) => (
|
|
90
|
+
<IconAndTextContainer
|
|
91
|
+
key={index}
|
|
92
|
+
isSelected={currentConversationInfo?.conversationID === question.id}
|
|
93
|
+
onClick={() =>
|
|
94
|
+
handleSetConversationInfo({
|
|
95
|
+
conversationID: question.id,
|
|
96
|
+
isNew: false,
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
data-tooltip-id="question-tooltip"
|
|
100
|
+
data-tooltip-content={question.chat_info[0].question}
|
|
101
|
+
>
|
|
102
|
+
<IconAndTextSubContainer>
|
|
103
|
+
<IconContainer>
|
|
104
|
+
<VuIcon svg={MessageIcon} />
|
|
105
|
+
</IconContainer>
|
|
106
|
+
<QuestionContainer>
|
|
107
|
+
{question.chat_info[0].question}
|
|
108
|
+
</QuestionContainer>
|
|
109
|
+
</IconAndTextSubContainer>
|
|
110
|
+
{currentConversationInfo?.conversationID === question.id && (
|
|
111
|
+
<IconContainer>
|
|
112
|
+
<VuIconButton
|
|
113
|
+
name="delete"
|
|
114
|
+
icon={DeleteIcon}
|
|
115
|
+
disabled={deleteChatMutation.isLoading}
|
|
116
|
+
onClick={(e) => {
|
|
117
|
+
e.stopPropagation();
|
|
118
|
+
deleteChatMutation.mutate(question.id);
|
|
119
|
+
}}
|
|
120
|
+
/>
|
|
121
|
+
</IconContainer>
|
|
122
|
+
)}
|
|
123
|
+
</IconAndTextContainer>
|
|
124
|
+
))}
|
|
125
|
+
</ListContainer>
|
|
126
|
+
<Tooltip id="question-tooltip" />
|
|
127
|
+
</Container>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export const Questions: string[] = [
|
|
2
|
+
"What is the difference between software design and software architecture?",
|
|
3
|
+
"Explain the concept of Object-Oriented Programming (OOP).",
|
|
4
|
+
"What is the SOLID principle in software development, and why is it important?",
|
|
5
|
+
"Describe the difference between functional and imperative programming.",
|
|
6
|
+
"What is version control, and why is it essential in software development?",
|
|
7
|
+
"What is a software development life cycle (SDLC), and name some common SDLC models.",
|
|
8
|
+
"Explain the concept of a code review and its benefits.",
|
|
9
|
+
"What is the purpose of unit testing in software development?",
|
|
10
|
+
"Describe the differences between static and dynamic typing in programming languages.",
|
|
11
|
+
"What is a software bug, and how can it be prevented or mitigated?",
|
|
12
|
+
"Explain the concept of refactoring in software development.",
|
|
13
|
+
"What is the DRY (Don't Repeat Yourself) principle, and how does it relate to code quality?",
|
|
14
|
+
"Describe the role of a software architect in a development project.",
|
|
15
|
+
"What is the difference between a thread and a process in the context of multitasking?",
|
|
16
|
+
"Explain the importance of documentation in software development.",
|
|
17
|
+
"What is the difference between a library and a framework in programming?",
|
|
18
|
+
"Describe the concept of Continuous Integration (CI) and Continuous Delivery (CD).",
|
|
19
|
+
"What is the Agile software development methodology, and what are its key principles?",
|
|
20
|
+
"Explain the concept of a design pattern in software development, and give an example.",
|
|
21
|
+
"What is a RESTful API, and how does it differ from SOAP?",
|
|
22
|
+
"Describe the principles of Test-Driven Development (TDD).",
|
|
23
|
+
// Add more questions here...
|
|
24
|
+
];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import tw from "tailwind-styled-components";
|
|
2
|
+
|
|
3
|
+
interface IconAndTextContainerProps {
|
|
4
|
+
isSelected: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const Container = tw.div`
|
|
8
|
+
flex
|
|
9
|
+
flex-col
|
|
10
|
+
text-left
|
|
11
|
+
grow
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const ListContainer = tw.div`
|
|
15
|
+
my-2
|
|
16
|
+
grow
|
|
17
|
+
overflow-y-auto
|
|
18
|
+
h-32
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const IconAndTextContainer = tw.div<IconAndTextContainerProps>`
|
|
22
|
+
flex
|
|
23
|
+
justify-between
|
|
24
|
+
items-center
|
|
25
|
+
p-1.5
|
|
26
|
+
${(p) =>
|
|
27
|
+
p.isSelected
|
|
28
|
+
? `
|
|
29
|
+
bg-gainsboro
|
|
30
|
+
`
|
|
31
|
+
: `bg-white`}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export const IconAndTextSubContainer = tw.div`
|
|
35
|
+
flex
|
|
36
|
+
items-center
|
|
37
|
+
overflow-x-hidden
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
export const IconContainer = tw.span`
|
|
41
|
+
mr-2
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const QuestionContainer = tw.div`
|
|
45
|
+
truncate
|
|
46
|
+
text-sm
|
|
47
|
+
text-center
|
|
48
|
+
cursor-pointer
|
|
49
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Chatbot";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import tw from "tailwind-styled-components";
|
|
2
|
+
|
|
3
|
+
export const FlexContainerRow = tw.div`
|
|
4
|
+
flex
|
|
5
|
+
`;
|
|
6
|
+
|
|
7
|
+
export const FlexContainerCol = tw.div`
|
|
8
|
+
flex
|
|
9
|
+
flex-col
|
|
10
|
+
gap-4
|
|
11
|
+
grow
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export const Header = tw.div`
|
|
15
|
+
flex
|
|
16
|
+
justify-between
|
|
17
|
+
mb-10
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
export const HeaderIconAndText = tw.div`
|
|
21
|
+
flex
|
|
22
|
+
items-center
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
export const Container = tw.div`
|
|
26
|
+
flex
|
|
27
|
+
h-full
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export const LeftSectionContainer = tw.div`
|
|
31
|
+
flex
|
|
32
|
+
flex-col
|
|
33
|
+
`;
|
|
34
|
+
|
|
35
|
+
export const RecentConversationsContainer = tw.div`
|
|
36
|
+
grow
|
|
37
|
+
w-80
|
|
38
|
+
pr-6
|
|
39
|
+
min-w-[20rem]
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
export const RecentConversationsSubContainer = tw.div`
|
|
43
|
+
h-full
|
|
44
|
+
flex
|
|
45
|
+
flex-col
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
export const ChatContainer = tw.div`
|
|
49
|
+
flex
|
|
50
|
+
flex-col
|
|
51
|
+
bg-alice_blue
|
|
52
|
+
relative
|
|
53
|
+
py-10
|
|
54
|
+
w-full
|
|
55
|
+
`;
|
|
56
|
+
|
|
57
|
+
export const LoaderContainer = tw.div`
|
|
58
|
+
flex
|
|
59
|
+
justify-center
|
|
60
|
+
items-center
|
|
61
|
+
h-full
|
|
62
|
+
`;
|
|
63
|
+
|
|
64
|
+
export const SelectWithLabelContainer = tw.div`
|
|
65
|
+
flex
|
|
66
|
+
items-center
|
|
67
|
+
mb-2
|
|
68
|
+
pr-6
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
export const SelectContainer = tw.div`
|
|
72
|
+
grow
|
|
73
|
+
`;
|
|
74
|
+
|
|
75
|
+
export const SelectLabelContainer = tw.div`
|
|
76
|
+
mr-2
|
|
77
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./VuChat";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** @type {import('tailwindcss').Config} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
content: ["./src/**/*.{js,jsx,ts,tsx}"],
|
|
4
|
+
theme: {
|
|
5
|
+
extend: {
|
|
6
|
+
colors: {
|
|
7
|
+
primary: "#11339A",
|
|
8
|
+
white: "#FFF",
|
|
9
|
+
black: "#000",
|
|
10
|
+
light_pink: "#FFB2B8",
|
|
11
|
+
gainsboro: "#D8DEE4",
|
|
12
|
+
lavender_blush: "#FEF2F3",
|
|
13
|
+
alice_blue: "#F3F6FC",
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
plugins: [],
|
|
18
|
+
};
|