@clikvn/agent-widget-embedded 0.0.1-dev
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/.eslintrc +34 -0
- package/.prettierrc +8 -0
- package/README.md +20 -0
- package/base.json +21 -0
- package/dist/commons/constants/index.d.ts +2 -0
- package/dist/commons/constants/index.d.ts.map +1 -0
- package/dist/commons/constants/variables.d.ts +5 -0
- package/dist/commons/constants/variables.d.ts.map +1 -0
- package/dist/components/Agent/index.d.ts +3 -0
- package/dist/components/Agent/index.d.ts.map +1 -0
- package/dist/components/Chat/Chat.d.ts +10 -0
- package/dist/components/Chat/Chat.d.ts.map +1 -0
- package/dist/components/Chat/Icons.d.ts +120 -0
- package/dist/components/Chat/Icons.d.ts.map +1 -0
- package/dist/components/Chat/Markdown.d.ts +7 -0
- package/dist/components/Chat/Markdown.d.ts.map +1 -0
- package/dist/components/Chat/Message.d.ts +15 -0
- package/dist/components/Chat/Message.d.ts.map +1 -0
- package/dist/components/Chat/MultimodalInput.d.ts +24 -0
- package/dist/components/Chat/MultimodalInput.d.ts.map +1 -0
- package/dist/components/Chat/Overview.d.ts +8 -0
- package/dist/components/Chat/Overview.d.ts.map +1 -0
- package/dist/components/Chat/PreviewAttachment.d.ts +6 -0
- package/dist/components/Chat/PreviewAttachment.d.ts.map +1 -0
- package/dist/components/Chat/ui/Button.d.ts +12 -0
- package/dist/components/Chat/ui/Button.d.ts.map +1 -0
- package/dist/components/Chat/ui/Textarea.d.ts +6 -0
- package/dist/components/Chat/ui/Textarea.d.ts.map +1 -0
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/features/AgentWidget/index.d.ts +16 -0
- package/dist/features/AgentWidget/index.d.ts.map +1 -0
- package/dist/hooks/useChat.d.ts +25 -0
- package/dist/hooks/useChat.d.ts.map +1 -0
- package/dist/hooks/useChatData.d.ts +18 -0
- package/dist/hooks/useChatData.d.ts.map +1 -0
- package/dist/hooks/useConfiguration.d.ts +20 -0
- package/dist/hooks/useConfiguration.d.ts.map +1 -0
- package/dist/hooks/useConnection.d.ts +15 -0
- package/dist/hooks/useConnection.d.ts.map +1 -0
- package/dist/hooks/useScrollToBottom.d.ts +6 -0
- package/dist/hooks/useScrollToBottom.d.ts.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/models/FlowiseClient.d.ts +20 -0
- package/dist/models/FlowiseClient.d.ts.map +1 -0
- package/dist/models.d.ts +2 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/register.d.ts +30 -0
- package/dist/register.d.ts.map +1 -0
- package/dist/services/apis.d.ts +7 -0
- package/dist/services/apis.d.ts.map +1 -0
- package/dist/services/bot.service.d.ts +3 -0
- package/dist/services/bot.service.d.ts.map +1 -0
- package/dist/services/chat.service.d.ts +32 -0
- package/dist/services/chat.service.d.ts.map +1 -0
- package/dist/services/user.service.d.ts +3 -0
- package/dist/services/user.service.d.ts.map +1 -0
- package/dist/types/agentType.d.ts +11 -0
- package/dist/types/agentType.d.ts.map +1 -0
- package/dist/types/bot.type.d.ts +11 -0
- package/dist/types/bot.type.d.ts.map +1 -0
- package/dist/types/chat.type.d.ts +10 -0
- package/dist/types/chat.type.d.ts.map +1 -0
- package/dist/types/common.type.d.ts +11 -0
- package/dist/types/common.type.d.ts.map +1 -0
- package/dist/types/flowise.type.d.ts +90 -0
- package/dist/types/flowise.type.d.ts.map +1 -0
- package/dist/types/user.type.d.ts +14 -0
- package/dist/types/user.type.d.ts.map +1 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/commonUtils.d.ts +7 -0
- package/dist/utils/commonUtils.d.ts.map +1 -0
- package/dist/utils/functionUtils.d.ts +3 -0
- package/dist/utils/functionUtils.d.ts.map +1 -0
- package/dist/utils/requestUtils.d.ts +16 -0
- package/dist/utils/requestUtils.d.ts.map +1 -0
- package/dist/utils/streamUtils.d.ts +5 -0
- package/dist/utils/streamUtils.d.ts.map +1 -0
- package/dist/web.d.ts +18 -0
- package/dist/web.d.ts.map +1 -0
- package/dist/web.js +1 -0
- package/dist/window.d.ts +29 -0
- package/dist/window.d.ts.map +1 -0
- package/package.json +91 -0
- package/rollup.config.js +56 -0
- package/src/assets/common.css +148 -0
- package/src/assets/tailwindcss.css +3 -0
- package/src/commons/constants/index.ts +1 -0
- package/src/commons/constants/variables.ts +20 -0
- package/src/components/Agent/index.tsx +14 -0
- package/src/components/Chat/Chat.tsx +84 -0
- package/src/components/Chat/Icons.tsx +883 -0
- package/src/components/Chat/Markdown.tsx +324 -0
- package/src/components/Chat/Message.tsx +185 -0
- package/src/components/Chat/MultimodalInput.tsx +371 -0
- package/src/components/Chat/Overview.tsx +47 -0
- package/src/components/Chat/PreviewAttachment.tsx +41 -0
- package/src/components/Chat/ui/Button.tsx +55 -0
- package/src/components/Chat/ui/Textarea.tsx +23 -0
- package/src/constants.ts +1 -0
- package/src/env.d.ts +10 -0
- package/src/features/AgentWidget/index.tsx +47 -0
- package/src/global.d.ts +1 -0
- package/src/hooks/useChat.ts +225 -0
- package/src/hooks/useChatData.tsx +68 -0
- package/src/hooks/useConfiguration.tsx +54 -0
- package/src/hooks/useScrollToBottom.ts +31 -0
- package/src/index.ts +1 -0
- package/src/models/FlowiseClient.ts +103 -0
- package/src/models.ts +1 -0
- package/src/register.tsx +66 -0
- package/src/services/apis.ts +10 -0
- package/src/services/bot.service.ts +15 -0
- package/src/services/chat.service.ts +164 -0
- package/src/types/bot.type.ts +10 -0
- package/src/types/chat.type.ts +11 -0
- package/src/types/common.type.ts +11 -0
- package/src/types/flowise.type.ts +99 -0
- package/src/types/user.type.ts +15 -0
- package/src/types.ts +0 -0
- package/src/utils/commonUtils.ts +47 -0
- package/src/utils/functionUtils.ts +17 -0
- package/src/utils/requestUtils.ts +113 -0
- package/src/utils/streamUtils.ts +18 -0
- package/src/web.ts +6 -0
- package/src/window.ts +55 -0
- package/tailwind.config.cjs +122 -0
- package/tsconfig.json +24 -0
package/dist/window.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { EVENT_TYPE } from './models';
|
|
2
|
+
type VoiceAgentWidget = {
|
|
3
|
+
apiHost: string;
|
|
4
|
+
agentId: string;
|
|
5
|
+
overrideConfig?: {
|
|
6
|
+
chatId?: string | undefined;
|
|
7
|
+
} & Record<string, unknown>;
|
|
8
|
+
theme?: {
|
|
9
|
+
avatar?: string;
|
|
10
|
+
} & Record<string, unknown>;
|
|
11
|
+
listeners?: Record<EVENT_TYPE, (props: any) => void>;
|
|
12
|
+
};
|
|
13
|
+
export declare const initWidget: (props: VoiceAgentWidget & {
|
|
14
|
+
id?: string;
|
|
15
|
+
}) => void;
|
|
16
|
+
export declare const destroy: () => void;
|
|
17
|
+
type AgentWidget = {
|
|
18
|
+
initWidget: typeof initWidget;
|
|
19
|
+
destroy: typeof destroy;
|
|
20
|
+
};
|
|
21
|
+
export declare const parseAgentVoice: () => {
|
|
22
|
+
initWidget: (props: VoiceAgentWidget & {
|
|
23
|
+
id?: string;
|
|
24
|
+
}) => void;
|
|
25
|
+
destroy: () => void;
|
|
26
|
+
};
|
|
27
|
+
export declare const injectAgentVoiceInWindow: (agent: AgentWidget) => void;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=window.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"window.d.ts","sourceRoot":"","sources":["../src/window.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAItC,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE;QACf,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KAC7B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,KAAK,CAAC,EAAE;QACN,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC;CACtD,CAAC;AACF,eAAO,MAAM,UAAU,UAAW,gBAAgB,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,SAYnE,CAAC;AAEF,eAAO,MAAM,OAAO,YAEnB,CAAC;AAEF,KAAK,WAAW,GAAG;IACjB,UAAU,EAAE,OAAO,UAAU,CAAC;IAC9B,OAAO,EAAE,OAAO,OAAO,CAAC;CACzB,CAAC;AAQF,eAAO,MAAM,eAAe;wBA7BM,gBAAgB,GAAG;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE;;CAgClE,CAAC;AAEH,eAAO,MAAM,wBAAwB,UAAW,WAAW,SAG1D,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@clikvn/agent-widget-embedded",
|
|
3
|
+
"description": "This is agent widget",
|
|
4
|
+
"version": "0.0.1-dev",
|
|
5
|
+
"author": "Clik JSC",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "rollup --watch --config rollup.config.js",
|
|
12
|
+
"build": "rollup --config rollup.config.js",
|
|
13
|
+
"lint": "eslint src",
|
|
14
|
+
"lint:fix": "eslint --fix src",
|
|
15
|
+
"prettier": "prettier --write .",
|
|
16
|
+
"pub": "publish --access public"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@fortawesome/fontawesome-svg-core": "^6.6.0",
|
|
20
|
+
"@fortawesome/free-brands-svg-icons": "^6.6.0",
|
|
21
|
+
"@fortawesome/free-regular-svg-icons": "^6.6.0",
|
|
22
|
+
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
|
23
|
+
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
24
|
+
"@radix-ui/react-slot": "^1.1.1",
|
|
25
|
+
"@tailwindcss/typography": "^0.5.15",
|
|
26
|
+
"@testing-library/jest-dom": "^5.14.1",
|
|
27
|
+
"@testing-library/react": "^13.0.0",
|
|
28
|
+
"@testing-library/user-event": "^13.2.1",
|
|
29
|
+
"@types/jest": "^29.5.14",
|
|
30
|
+
"@types/node": "^22.9.0",
|
|
31
|
+
"@types/react": "^18.3.12",
|
|
32
|
+
"@types/react-dom": "^18.3.1",
|
|
33
|
+
"class-variance-authority": "^0.7.1",
|
|
34
|
+
"clsx": "^2.1.1",
|
|
35
|
+
"framer-motion": "^11.18.0",
|
|
36
|
+
"react": "^18.3.1",
|
|
37
|
+
"react-dom": "^18.3.1",
|
|
38
|
+
"react-markdown": "^9.0.3",
|
|
39
|
+
"react-scripts": "5.0.1",
|
|
40
|
+
"remark-gfm": "^4.0.0",
|
|
41
|
+
"swr": "^2.3.0",
|
|
42
|
+
"tailwind-merge": "^2.6.0",
|
|
43
|
+
"tailwindcss": "^3.4.15",
|
|
44
|
+
"tailwindcss-animate": "^1.0.7",
|
|
45
|
+
"typescript": "^5.6.3",
|
|
46
|
+
"usehooks-ts": "^3.1.0",
|
|
47
|
+
"web-vitals": "^2.1.0"
|
|
48
|
+
},
|
|
49
|
+
"eslintConfig": {
|
|
50
|
+
"extends": [
|
|
51
|
+
"react-app",
|
|
52
|
+
"react-app/jest"
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
"browserslist": {
|
|
56
|
+
"production": [
|
|
57
|
+
">0.2%",
|
|
58
|
+
"not dead",
|
|
59
|
+
"not op_mini all"
|
|
60
|
+
],
|
|
61
|
+
"development": [
|
|
62
|
+
"last 1 chrome version",
|
|
63
|
+
"last 1 firefox version",
|
|
64
|
+
"last 1 safari version"
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"devDependencies": {
|
|
68
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
69
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
70
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
71
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
72
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^8.20.0",
|
|
74
|
+
"@typescript-eslint/parser": "^8.20.0",
|
|
75
|
+
"autoprefixer": "^10.4.20",
|
|
76
|
+
"eslint": "^8.57.0",
|
|
77
|
+
"eslint-config-prettier": "^10.0.1",
|
|
78
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
79
|
+
"prettier": "^3.4.2",
|
|
80
|
+
"rollup": "^4.26.0",
|
|
81
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
82
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
83
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
84
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
85
|
+
"rollup-plugin-typescript-paths": "^1.5.0",
|
|
86
|
+
"rollup-plugin-uglify": "^6.0.4"
|
|
87
|
+
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=18.18.0"
|
|
90
|
+
}
|
|
91
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
2
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
3
|
+
import typescript from '@rollup/plugin-typescript';
|
|
4
|
+
import { terser } from 'rollup-plugin-terser';
|
|
5
|
+
import postcss from 'rollup-plugin-postcss';
|
|
6
|
+
import { babel } from '@rollup/plugin-babel';
|
|
7
|
+
import autoprefixer from 'autoprefixer';
|
|
8
|
+
import { typescriptPaths } from 'rollup-plugin-typescript-paths';
|
|
9
|
+
import json from '@rollup/plugin-json';
|
|
10
|
+
import { uglify } from 'rollup-plugin-uglify';
|
|
11
|
+
import replace from 'rollup-plugin-replace';
|
|
12
|
+
import tailwindcss from 'tailwindcss';
|
|
13
|
+
|
|
14
|
+
const extensions = ['.ts', '.tsx', '.js'];
|
|
15
|
+
|
|
16
|
+
const indexConfig = {
|
|
17
|
+
context: 'this',
|
|
18
|
+
plugins: [
|
|
19
|
+
resolve({ extensions, browser: true }),
|
|
20
|
+
commonjs(),
|
|
21
|
+
uglify(),
|
|
22
|
+
json(),
|
|
23
|
+
babel({
|
|
24
|
+
babelHelpers: 'bundled',
|
|
25
|
+
exclude: 'node_modules/**',
|
|
26
|
+
extensions,
|
|
27
|
+
}),
|
|
28
|
+
replace({
|
|
29
|
+
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
30
|
+
}),
|
|
31
|
+
postcss({
|
|
32
|
+
plugins: [autoprefixer(), tailwindcss()],
|
|
33
|
+
extract: false,
|
|
34
|
+
modules: false,
|
|
35
|
+
autoModules: false,
|
|
36
|
+
minimize: true,
|
|
37
|
+
inject: false,
|
|
38
|
+
}),
|
|
39
|
+
typescript(),
|
|
40
|
+
typescriptPaths({ preserveExtensions: true }),
|
|
41
|
+
terser({ output: { comments: false } }),
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const configs = [
|
|
46
|
+
{
|
|
47
|
+
...indexConfig,
|
|
48
|
+
input: './src/web.ts',
|
|
49
|
+
output: {
|
|
50
|
+
file: 'dist/web.js',
|
|
51
|
+
format: 'esm',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
export default configs;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
@tailwind base;
|
|
2
|
+
@tailwind components;
|
|
3
|
+
@tailwind utilities;
|
|
4
|
+
|
|
5
|
+
:root {
|
|
6
|
+
--foreground-rgb: 0, 0, 0;
|
|
7
|
+
--background-start-rgb: 214, 219, 220;
|
|
8
|
+
--background-end-rgb: 255, 255, 255;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@media (prefers-color-scheme: dark) {
|
|
12
|
+
:root {
|
|
13
|
+
--foreground-rgb: 255, 255, 255;
|
|
14
|
+
--background-start-rgb: 0, 0, 0;
|
|
15
|
+
--background-end-rgb: 0, 0, 0;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@layer utilities {
|
|
20
|
+
.text-balance {
|
|
21
|
+
text-wrap: balance;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@layer base {
|
|
26
|
+
:root {
|
|
27
|
+
--background: 0 0% 100%;
|
|
28
|
+
--foreground: 240 10% 3.9%;
|
|
29
|
+
--card: 0 0% 100%;
|
|
30
|
+
--card-foreground: 240 10% 3.9%;
|
|
31
|
+
--popover: 0 0% 100%;
|
|
32
|
+
--popover-foreground: 240 10% 3.9%;
|
|
33
|
+
--primary: 217 100% 45%;
|
|
34
|
+
--primary-foreground: 0 0% 98%;
|
|
35
|
+
--secondary: 213 100% 96%;
|
|
36
|
+
--secondary-foreground: 240 5.9% 10%;
|
|
37
|
+
--muted: 240 4.8% 95.9%;
|
|
38
|
+
--muted-foreground: 240 3.8% 46.1%;
|
|
39
|
+
--accent: 240 4.8% 95.9%;
|
|
40
|
+
--accent-foreground: 240 5.9% 10%;
|
|
41
|
+
--destructive: 0 84.2% 60.2%;
|
|
42
|
+
--destructive-foreground: 0 0% 98%;
|
|
43
|
+
--border: 214 32% 91%;
|
|
44
|
+
--input: 240 5.9% 90%;
|
|
45
|
+
--ring: 240 10% 3.9%;
|
|
46
|
+
--chart-1: 12 76% 61%;
|
|
47
|
+
--chart-2: 173 58% 39%;
|
|
48
|
+
--chart-3: 197 37% 24%;
|
|
49
|
+
--chart-4: 43 74% 66%;
|
|
50
|
+
--chart-5: 27 87% 67%;
|
|
51
|
+
--radius: 0.5rem;
|
|
52
|
+
--sidebar-background: 0 0% 98%;
|
|
53
|
+
--sidebar-foreground: 240 10% 3.9%;
|
|
54
|
+
--sidebar-primary: 240 5.9% 10%;
|
|
55
|
+
--sidebar-primary-foreground: 0 0% 98%;
|
|
56
|
+
--sidebar-accent: 240 5.9% 94%;
|
|
57
|
+
--sidebar-accent-foreground: 240 5.9% 10%;
|
|
58
|
+
--sidebar-border: 220 13% 91%;
|
|
59
|
+
--sidebar-ring: 217.2 91.2% 59.8%;
|
|
60
|
+
}
|
|
61
|
+
.dark {
|
|
62
|
+
--background: 240 10% 3.9%;
|
|
63
|
+
--foreground: 0 0% 98%;
|
|
64
|
+
--card: 240 10% 3.9%;
|
|
65
|
+
--card-foreground: 0 0% 98%;
|
|
66
|
+
--popover: 240 10% 3.9%;
|
|
67
|
+
--popover-foreground: 0 0% 98%;
|
|
68
|
+
--primary: 208.69 100% 24.18%;
|
|
69
|
+
--primary-foreground: 207 100% 96%;
|
|
70
|
+
--secondary: 240 3.7% 15.9%;
|
|
71
|
+
--secondary-foreground: 0 0% 98%;
|
|
72
|
+
--muted: 240 3.7% 15.9%;
|
|
73
|
+
--muted-foreground: 240 5% 64.9%;
|
|
74
|
+
--accent: 240 3.7% 15.9%;
|
|
75
|
+
--accent-foreground: 0 0% 98%;
|
|
76
|
+
--destructive: 0 62.8% 30.6%;
|
|
77
|
+
--destructive-foreground: 0 0% 98%;
|
|
78
|
+
--border: 240 3.7% 15.9%;
|
|
79
|
+
--input: 240 3.7% 15.9%;
|
|
80
|
+
--ring: 240 4.9% 83.9%;
|
|
81
|
+
--chart-1: 220 70% 50%;
|
|
82
|
+
--chart-2: 160 60% 45%;
|
|
83
|
+
--chart-3: 30 80% 55%;
|
|
84
|
+
--chart-4: 280 65% 60%;
|
|
85
|
+
--chart-5: 340 75% 55%;
|
|
86
|
+
--sidebar-background: 240 5.9% 10%;
|
|
87
|
+
--sidebar-foreground: 240 4.8% 95.9%;
|
|
88
|
+
--sidebar-primary: 224.3 76.3% 48%;
|
|
89
|
+
--sidebar-primary-foreground: 0 0% 100%;
|
|
90
|
+
--sidebar-accent: 240 3.7% 15.9%;
|
|
91
|
+
--sidebar-accent-foreground: 240 4.8% 95.9%;
|
|
92
|
+
--sidebar-border: 240 3.7% 15.9%;
|
|
93
|
+
--sidebar-ring: 217.2 91.2% 59.8%;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
@layer base {
|
|
98
|
+
* {
|
|
99
|
+
@apply border-border;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
body {
|
|
103
|
+
@apply bg-background text-foreground;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
@font-face {
|
|
107
|
+
/*font-family: "geist";*/
|
|
108
|
+
font-family: 'Be Vietnam Pro', sans-serif;
|
|
109
|
+
font-style: normal;
|
|
110
|
+
font-weight: 100 900;
|
|
111
|
+
/*src: url(/fonts/geist.woff2) format("woff2");*/
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
@font-face {
|
|
115
|
+
/*font-family: "geist-mono";*/
|
|
116
|
+
font-family: 'Be Vietnam Pro', sans-serif;
|
|
117
|
+
font-style: normal;
|
|
118
|
+
font-weight: 100 900;
|
|
119
|
+
/*src: url(/fonts/geist-mono.woff2) format("woff2");*/
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.skeleton {
|
|
124
|
+
* {
|
|
125
|
+
pointer-events: none !important;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
*[class^='text-'] {
|
|
129
|
+
color: transparent;
|
|
130
|
+
@apply rounded-md bg-foreground/20 select-none animate-pulse;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.skeleton-bg {
|
|
134
|
+
@apply bg-foreground/10;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.skeleton-div {
|
|
138
|
+
@apply bg-foreground/20 animate-pulse;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.ProseMirror {
|
|
143
|
+
outline: none;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.suggestion-highlight {
|
|
147
|
+
@apply bg-blue-200 hover:bg-blue-300 dark:hover:bg-blue-400/50 dark:text-blue-50 dark:bg-blue-500/40;
|
|
148
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './variables';
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const BE_API = '';
|
|
2
|
+
|
|
3
|
+
export const LANGUAGE_HEADER: { [key: string]: string } = {
|
|
4
|
+
vi: 'vn',
|
|
5
|
+
en: 'en',
|
|
6
|
+
jp: 'jp',
|
|
7
|
+
kr: 'kr',
|
|
8
|
+
cn: 'cn',
|
|
9
|
+
es: 'es',
|
|
10
|
+
fr: 'fr',
|
|
11
|
+
de: 'de',
|
|
12
|
+
ru: 'ru',
|
|
13
|
+
th: 'th',
|
|
14
|
+
tw: 'tw',
|
|
15
|
+
sg: 'sg',
|
|
16
|
+
my: 'my',
|
|
17
|
+
kh: 'kh',
|
|
18
|
+
au: 'au',
|
|
19
|
+
global: 'global',
|
|
20
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useChatData } from '../../hooks/useChatData';
|
|
2
|
+
import { useConfiguration } from '../../hooks/useConfiguration';
|
|
3
|
+
import { Chat } from '../Chat/Chat';
|
|
4
|
+
|
|
5
|
+
const Agent = () => {
|
|
6
|
+
const { agentId } = useConfiguration();
|
|
7
|
+
const { chatId, initialMessages } = useChatData();
|
|
8
|
+
|
|
9
|
+
return (
|
|
10
|
+
<Chat agentId={agentId} id={chatId} initialMessages={initialMessages} />
|
|
11
|
+
);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export default Agent;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { FC, useState } from 'react';
|
|
2
|
+
import { ChatMessageType, IFileUpload } from '../../types/flowise.type';
|
|
3
|
+
import { PreviewMessage, ThinkingMessage } from './Message';
|
|
4
|
+
import { useChat } from '../../hooks/useChat';
|
|
5
|
+
import { useScrollToBottom } from '../../hooks/useScrollToBottom';
|
|
6
|
+
import { MultimodalInput } from './MultimodalInput';
|
|
7
|
+
import { Overview } from './Overview';
|
|
8
|
+
import { useConfiguration } from '../../hooks/useConfiguration';
|
|
9
|
+
|
|
10
|
+
type PropsType = {
|
|
11
|
+
id?: string;
|
|
12
|
+
initialMessages?: ChatMessageType[];
|
|
13
|
+
agentId?: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const Chat: FC<PropsType> = ({ id, agentId, initialMessages = [] }) => {
|
|
17
|
+
const {
|
|
18
|
+
messages = [],
|
|
19
|
+
setMessages,
|
|
20
|
+
handleSubmit,
|
|
21
|
+
input = '',
|
|
22
|
+
setInput,
|
|
23
|
+
isLoading,
|
|
24
|
+
stop,
|
|
25
|
+
chatId,
|
|
26
|
+
append,
|
|
27
|
+
bot,
|
|
28
|
+
} = useChat({ id, initialMessages, agentId });
|
|
29
|
+
const { apiHost } = useConfiguration();
|
|
30
|
+
const [messagesContainerRef, messagesEndRef] =
|
|
31
|
+
useScrollToBottom<HTMLDivElement>();
|
|
32
|
+
const [attachments, setAttachments] = useState<Array<IFileUpload>>([]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<div className="flex flex-col min-w-0 h-dvh bg-background">
|
|
37
|
+
<div
|
|
38
|
+
ref={messagesContainerRef}
|
|
39
|
+
className="flex flex-col min-w-0 gap-6 flex-1 overflow-y-scroll pt-4"
|
|
40
|
+
>
|
|
41
|
+
{(messages?.length || 0) === 0 && <Overview bot={bot} />}
|
|
42
|
+
|
|
43
|
+
{(messages || []).map((message, index) => (
|
|
44
|
+
<PreviewMessage
|
|
45
|
+
key={message.id}
|
|
46
|
+
bot={bot}
|
|
47
|
+
chatId={id}
|
|
48
|
+
message={message}
|
|
49
|
+
isLoading={isLoading && (messages || []).length - 1 === index}
|
|
50
|
+
/>
|
|
51
|
+
))}
|
|
52
|
+
|
|
53
|
+
{isLoading &&
|
|
54
|
+
messages.length > 0 &&
|
|
55
|
+
messages[messages.length - 1].role === 'userMessage' && (
|
|
56
|
+
<ThinkingMessage bot={bot} />
|
|
57
|
+
)}
|
|
58
|
+
|
|
59
|
+
<div
|
|
60
|
+
ref={messagesEndRef}
|
|
61
|
+
className="shrink-0 min-w-[24px] min-h-[24px]"
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
<form className="flex mx-auto px-4 bg-background pb-4 md:pb-6 gap-2 w-full md:max-w-3xl">
|
|
65
|
+
<MultimodalInput
|
|
66
|
+
input={input}
|
|
67
|
+
setInput={setInput}
|
|
68
|
+
chatId={chatId}
|
|
69
|
+
handleSubmit={handleSubmit}
|
|
70
|
+
isLoading={isLoading}
|
|
71
|
+
stop={stop}
|
|
72
|
+
messages={messages}
|
|
73
|
+
setMessages={setMessages}
|
|
74
|
+
append={append}
|
|
75
|
+
attachments={attachments}
|
|
76
|
+
setAttachments={setAttachments}
|
|
77
|
+
bot={bot}
|
|
78
|
+
apiHost={apiHost}
|
|
79
|
+
/>
|
|
80
|
+
</form>
|
|
81
|
+
</div>
|
|
82
|
+
</>
|
|
83
|
+
);
|
|
84
|
+
};
|