assistant-robot 0.0.1-alpha → 0.0.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/.eslintrc.json +10 -0
- package/dist/AssistantModel.d.ts +31 -0
- package/dist/LanguageModel.d.ts +23 -0
- package/dist/LanguageModel.js +1 -66
- package/dist/LanguageModel.mjs +37 -34
- package/dist/QuestionManager.d.ts +9 -0
- package/dist/UserDetector.d.ts +18 -0
- package/dist/constants.d.ts +29 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +1 -325
- package/dist/index.mjs +1779 -227
- package/dist/type.d.ts +57 -0
- package/dist/utils-ePOYkfFK.js +64 -0
- package/dist/utils-vFpckT4x.mjs +136 -0
- package/dist/utils.d.ts +6 -0
- package/index.d.ts +3 -0
- package/package.json +12 -3
- package/tsconfig.json +26 -0
- package/dist/utils-1rt7_Dvg.js +0 -153
- package/dist/utils-7giLo_Tq.mjs +0 -154
package/dist/type.d.ts
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
import { LanguageModel } from "./LanguageModel";
|
2
|
+
export interface ILanguageModelOptions {
|
3
|
+
[prop: string]: any;
|
4
|
+
}
|
5
|
+
interface ILanguageModelSubclass<T extends LanguageModel> {
|
6
|
+
new (options: ILanguageModelOptions): T;
|
7
|
+
}
|
8
|
+
export interface ILanguageModelConfig<T extends LanguageModel> extends ILanguageModelOptions {
|
9
|
+
Model: ILanguageModelSubclass<T>;
|
10
|
+
}
|
11
|
+
export interface IChatBoxConfig {
|
12
|
+
hide?: boolean;
|
13
|
+
chatBoxClassName?: string;
|
14
|
+
}
|
15
|
+
export interface IModelConfig {
|
16
|
+
position: [number, number, number];
|
17
|
+
rotation: [number, number, number];
|
18
|
+
helloActionName: string;
|
19
|
+
idleActionName: string;
|
20
|
+
helloContent: string;
|
21
|
+
}
|
22
|
+
export interface IModelSceneConfig {
|
23
|
+
backgroundColor: number;
|
24
|
+
backgroundAlpha: number;
|
25
|
+
camera: {
|
26
|
+
fov: number;
|
27
|
+
near: number;
|
28
|
+
far: number;
|
29
|
+
position: [number, number, number];
|
30
|
+
lookAt: [number, number, number];
|
31
|
+
};
|
32
|
+
ambientLight: {
|
33
|
+
color: number;
|
34
|
+
intensity: number;
|
35
|
+
};
|
36
|
+
directionalLight: {
|
37
|
+
color: number;
|
38
|
+
intensity: number;
|
39
|
+
position: [number, number, number];
|
40
|
+
};
|
41
|
+
}
|
42
|
+
export type TRobotModelConfig = Partial<IModelSceneConfig> & {
|
43
|
+
modelConfig?: Partial<IModelConfig>;
|
44
|
+
modelUrl?: string;
|
45
|
+
};
|
46
|
+
export interface IUserDetectorConfig {
|
47
|
+
solutionPath?: string;
|
48
|
+
}
|
49
|
+
export interface IAssistantRobotConfig<T extends LanguageModel> {
|
50
|
+
className: string;
|
51
|
+
languageModel: ILanguageModelConfig<T>;
|
52
|
+
chatBox: IChatBoxConfig;
|
53
|
+
robotModel: TRobotModelConfig;
|
54
|
+
userDetector: IUserDetectorConfig;
|
55
|
+
}
|
56
|
+
export type TCallback = () => void;
|
57
|
+
export {};
|
@@ -0,0 +1,64 @@
|
|
1
|
+
"use strict";const _={position:[0,0,0],rotation:[0,Math.PI,0],helloActionName:"hello",idleActionName:"idle",helloContent:"Hi, you can talk to me!"},T={backgroundColor:0,backgroundAlpha:0,camera:{fov:50,near:.1,far:10,position:[0,0,2],lookAt:[0,0,0]},ambientLight:{color:16777215,intensity:.5},directionalLight:{color:16777215,intensity:2,position:[10,10,0]}},A={big:{width:640,height:480},small:{width:360,height:270}},e="assistant-robot-model-container",i="assistant_tip_container",d='<div class="assistant-robot-container ',O=`">
|
2
|
+
<style>
|
3
|
+
.assistant-robot-container{
|
4
|
+
width: 100%;
|
5
|
+
height: 100%;
|
6
|
+
display: flex;
|
7
|
+
flex-direction: column;
|
8
|
+
}
|
9
|
+
.${e}{
|
10
|
+
flex: 1;
|
11
|
+
position:relative;
|
12
|
+
width:100%;
|
13
|
+
}
|
14
|
+
.${i}{
|
15
|
+
position: absolute;
|
16
|
+
top: 2px;
|
17
|
+
left: 50%;
|
18
|
+
min-width: 100px;
|
19
|
+
border: 1px solid #aaaaaa;
|
20
|
+
border-radius: 6px;
|
21
|
+
background: #fff;
|
22
|
+
transform: translate(-50%);
|
23
|
+
padding: 12px 20px;
|
24
|
+
text-align: center;
|
25
|
+
}
|
26
|
+
.${i}::after{
|
27
|
+
content: '';
|
28
|
+
display: block;
|
29
|
+
position: absolute;
|
30
|
+
bottom: -6px;
|
31
|
+
left: 50%;
|
32
|
+
width: 8px;
|
33
|
+
height: 8px;
|
34
|
+
transform: rotate(45deg);
|
35
|
+
border-bottom: 1px solid #aaaaaa;
|
36
|
+
border-right: 1px solid #aaaaaa;
|
37
|
+
background: #fff;
|
38
|
+
}
|
39
|
+
</style>
|
40
|
+
<div class="${e}">
|
41
|
+
<div class="${i}">HI!</div>
|
42
|
+
|
43
|
+
</div>
|
44
|
+
<div>
|
45
|
+
`,a="assistant-robot-input",l="assistant-robot-btn",E='<div class="assistant-robot-chartbox',p=`">
|
46
|
+
<style>
|
47
|
+
.assistant-robot-chartbox{
|
48
|
+
width: 100%;
|
49
|
+
display: flex;
|
50
|
+
flex-wrap: wrap;
|
51
|
+
}
|
52
|
+
.assistant-robot-input{
|
53
|
+
flex: 1;
|
54
|
+
min-width: 200px;
|
55
|
+
background: rgba(0,0,0,0);
|
56
|
+
border: 1px solid #aaaaaa;
|
57
|
+
}
|
58
|
+
.assistant-robot-btn{
|
59
|
+
flex: 0 0 auto;
|
60
|
+
}
|
61
|
+
</style>
|
62
|
+
<input class="${a}" type="text" />
|
63
|
+
<button class="${l}">ask</button>
|
64
|
+
</div>`;var c=(t=>(t[t.loading=1]="loading",t[t.ready=2]="ready",t[t.error=3]="error",t))(c||{});const b=50,I=2e3;function f(){return/iPhone|iPad|iPod/i.test(navigator.userAgent)}function N(){return/Android/i.test(navigator.userAgent)}function h(){return N()||f()}function S(t){return new DOMParser().parseFromString(t,"text/html").body.firstElementChild}function C(t){if(!Array.isArray(t)||t.length===0)return null;let n=-1/0,r=null;for(let s=0;s<t.length;s++){const o=t[s];o&&typeof o.score=="number"&&o.score>n&&(n=o.score,r=o)}return r}exports.ASSISTANT_MODEL_CONTAINER_CLASS=e;exports.ASSISTANT_TIP_CONTAINER=i;exports.CONTAINER_BODY=O;exports.CONTAINER_HEAD=d;exports.ELanguageModelStatus=c;exports.MODEL_CONFIG=_;exports.MODEL_SCENE_CONFIG=T;exports.ONE_LETTER_READ_TIME=b;exports.READ_WAIT_TIME=I;exports.ROBOT_CHAT_BOX_BODY=p;exports.ROBOT_CHAT_BOX_HEAD=E;exports.ROBOT_CHAT_BTN_CLASS=l;exports.ROBOT_CHAT_INPUT_CLASS=a;exports.TARGET_FPS=60;exports.VIDEO_SIZE=A;exports.findHighestScoreItem=C;exports.isMobile=h;exports.parseHTML=S;
|
@@ -0,0 +1,136 @@
|
|
1
|
+
const b = 60, f = {
|
2
|
+
position: [0, 0, 0],
|
3
|
+
rotation: [0, Math.PI, 0],
|
4
|
+
helloActionName: "hello",
|
5
|
+
idleActionName: "idle",
|
6
|
+
helloContent: "Hi, you can talk to me!"
|
7
|
+
}, h = {
|
8
|
+
backgroundColor: 0,
|
9
|
+
backgroundAlpha: 0,
|
10
|
+
camera: {
|
11
|
+
fov: 50,
|
12
|
+
near: 0.1,
|
13
|
+
far: 10,
|
14
|
+
position: [0, 0, 2],
|
15
|
+
lookAt: [0, 0, 0]
|
16
|
+
},
|
17
|
+
ambientLight: {
|
18
|
+
color: 16777215,
|
19
|
+
intensity: 0.5
|
20
|
+
},
|
21
|
+
directionalLight: {
|
22
|
+
color: 16777215,
|
23
|
+
intensity: 2,
|
24
|
+
position: [10, 10, 0]
|
25
|
+
}
|
26
|
+
}, A = {
|
27
|
+
big: { width: 640, height: 480 },
|
28
|
+
small: { width: 360, height: 270 }
|
29
|
+
}, r = "assistant-robot-model-container", n = "assistant_tip_container", _ = '<div class="assistant-robot-container ', x = `">
|
30
|
+
<style>
|
31
|
+
.assistant-robot-container{
|
32
|
+
width: 100%;
|
33
|
+
height: 100%;
|
34
|
+
display: flex;
|
35
|
+
flex-direction: column;
|
36
|
+
}
|
37
|
+
.${r}{
|
38
|
+
flex: 1;
|
39
|
+
position:relative;
|
40
|
+
width:100%;
|
41
|
+
}
|
42
|
+
.${n}{
|
43
|
+
position: absolute;
|
44
|
+
top: 2px;
|
45
|
+
left: 50%;
|
46
|
+
min-width: 100px;
|
47
|
+
border: 1px solid #aaaaaa;
|
48
|
+
border-radius: 6px;
|
49
|
+
background: #fff;
|
50
|
+
transform: translate(-50%);
|
51
|
+
padding: 12px 20px;
|
52
|
+
text-align: center;
|
53
|
+
}
|
54
|
+
.${n}::after{
|
55
|
+
content: '';
|
56
|
+
display: block;
|
57
|
+
position: absolute;
|
58
|
+
bottom: -6px;
|
59
|
+
left: 50%;
|
60
|
+
width: 8px;
|
61
|
+
height: 8px;
|
62
|
+
transform: rotate(45deg);
|
63
|
+
border-bottom: 1px solid #aaaaaa;
|
64
|
+
border-right: 1px solid #aaaaaa;
|
65
|
+
background: #fff;
|
66
|
+
}
|
67
|
+
</style>
|
68
|
+
<div class="${r}">
|
69
|
+
<div class="${n}">HI!</div>
|
70
|
+
|
71
|
+
</div>
|
72
|
+
<div>
|
73
|
+
`, e = "assistant-robot-input", c = "assistant-robot-btn", T = '<div class="assistant-robot-chartbox', O = `">
|
74
|
+
<style>
|
75
|
+
.assistant-robot-chartbox{
|
76
|
+
width: 100%;
|
77
|
+
display: flex;
|
78
|
+
flex-wrap: wrap;
|
79
|
+
}
|
80
|
+
.assistant-robot-input{
|
81
|
+
flex: 1;
|
82
|
+
min-width: 200px;
|
83
|
+
background: rgba(0,0,0,0);
|
84
|
+
border: 1px solid #aaaaaa;
|
85
|
+
}
|
86
|
+
.assistant-robot-btn{
|
87
|
+
flex: 0 0 auto;
|
88
|
+
}
|
89
|
+
</style>
|
90
|
+
<input class="${e}" type="text" />
|
91
|
+
<button class="${c}">ask</button>
|
92
|
+
</div>`;
|
93
|
+
var l = /* @__PURE__ */ ((t) => (t[t.loading = 1] = "loading", t[t.ready = 2] = "ready", t[t.error = 3] = "error", t))(l || {});
|
94
|
+
const u = 50, m = 2e3;
|
95
|
+
function d() {
|
96
|
+
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
97
|
+
}
|
98
|
+
function p() {
|
99
|
+
return /Android/i.test(navigator.userAgent);
|
100
|
+
}
|
101
|
+
function I() {
|
102
|
+
return p() || d();
|
103
|
+
}
|
104
|
+
function g(t) {
|
105
|
+
return new DOMParser().parseFromString(t, "text/html").body.firstElementChild;
|
106
|
+
}
|
107
|
+
function y(t) {
|
108
|
+
if (!Array.isArray(t) || t.length === 0)
|
109
|
+
return null;
|
110
|
+
let s = -1 / 0, i = null;
|
111
|
+
for (let a = 0; a < t.length; a++) {
|
112
|
+
const o = t[a];
|
113
|
+
o && typeof o.score == "number" && o.score > s && (s = o.score, i = o);
|
114
|
+
}
|
115
|
+
return i;
|
116
|
+
}
|
117
|
+
export {
|
118
|
+
n as A,
|
119
|
+
_ as C,
|
120
|
+
l as E,
|
121
|
+
h as M,
|
122
|
+
u as O,
|
123
|
+
m as R,
|
124
|
+
b as T,
|
125
|
+
A as V,
|
126
|
+
f as a,
|
127
|
+
T as b,
|
128
|
+
O as c,
|
129
|
+
c as d,
|
130
|
+
e,
|
131
|
+
x as f,
|
132
|
+
r as g,
|
133
|
+
y as h,
|
134
|
+
I as i,
|
135
|
+
g as p
|
136
|
+
};
|
package/dist/utils.d.ts
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { Answer } from "@tensorflow-models/qna/dist/question_and_answer";
|
2
|
+
export declare function isiOS(): boolean;
|
3
|
+
export declare function isAndroid(): boolean;
|
4
|
+
export declare function isMobile(): boolean;
|
5
|
+
export declare function parseHTML(htmlString: string): Element | null;
|
6
|
+
export declare function findHighestScoreItem(data: Answer[]): Answer | null;
|
package/index.d.ts
ADDED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "assistant-robot",
|
3
|
-
"version": "0.0.1
|
3
|
+
"version": "0.0.1",
|
4
4
|
"description": "An assistant widget, have a 3D robot which can interact with user, have a simple LLM which can chat with user.",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"module": "dist/index.mjs",
|
@@ -21,15 +21,24 @@
|
|
21
21
|
"three": "^0.158.0"
|
22
22
|
},
|
23
23
|
"devDependencies": {
|
24
|
+
"@types/three": "^0.159.0",
|
25
|
+
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
26
|
+
"@typescript-eslint/parser": "^6.13.2",
|
27
|
+
"eslint": "^8.55.0",
|
28
|
+
"typescript": "^5.3.2",
|
24
29
|
"vite": "^5.0.4"
|
25
30
|
},
|
26
31
|
"scripts": {
|
27
32
|
"dev": "vite example",
|
28
|
-
"build": "vite build
|
33
|
+
"build": "vite build && tsc",
|
34
|
+
"lint": "eslint . --ext ts --report-unused-disable-directives --max-warnings 0",
|
29
35
|
"preview": "vite preview"
|
30
36
|
},
|
31
37
|
"keywords": [
|
32
38
|
"assistant",
|
39
|
+
"robot",
|
40
|
+
"web-component",
|
41
|
+
"html",
|
33
42
|
"LLM",
|
34
43
|
"AI",
|
35
44
|
"3D",
|
@@ -37,5 +46,5 @@
|
|
37
46
|
"UI"
|
38
47
|
],
|
39
48
|
"author": "ymrdf",
|
40
|
-
"license": "
|
49
|
+
"license": "MIT"
|
41
50
|
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES2020",
|
4
|
+
"useDefineForClassFields": true,
|
5
|
+
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
6
|
+
"module": "ESNext",
|
7
|
+
"skipLibCheck": true,
|
8
|
+
|
9
|
+
/* Bundler mode */
|
10
|
+
"moduleResolution": "Node",
|
11
|
+
"allowImportingTsExtensions": true,
|
12
|
+
"resolveJsonModule": true,
|
13
|
+
"isolatedModules": true,
|
14
|
+
"emitDeclarationOnly": true,
|
15
|
+
|
16
|
+
/* Linting */
|
17
|
+
"strict": true,
|
18
|
+
"noUnusedLocals": true,
|
19
|
+
"noUnusedParameters": true,
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
21
|
+
|
22
|
+
"declaration": true, // Ensure this option is set to true
|
23
|
+
"outDir": "dist" // Specify your output directory
|
24
|
+
},
|
25
|
+
"include": ["index.d.ts","src/**/*.ts"]
|
26
|
+
}
|
package/dist/utils-1rt7_Dvg.js
DELETED
@@ -1,153 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
const TARGET_FPS = 60;
|
3
|
-
const MODEL_CONFIG = {
|
4
|
-
position: [0, 0, 0],
|
5
|
-
rotation: [0, Math.PI, 0]
|
6
|
-
};
|
7
|
-
const MODEL_SCENE_CONFIG = {
|
8
|
-
backgroundColor: 0,
|
9
|
-
backgroundAlpha: 0,
|
10
|
-
camera: {
|
11
|
-
fov: 50,
|
12
|
-
near: 0.1,
|
13
|
-
far: 10,
|
14
|
-
position: [0, 0, 2],
|
15
|
-
lookAt: [0, 0, 0]
|
16
|
-
},
|
17
|
-
ambientLight: {
|
18
|
-
color: 16777215,
|
19
|
-
intensity: 0.5
|
20
|
-
},
|
21
|
-
directionalLight: {
|
22
|
-
color: 16777215,
|
23
|
-
intensity: 2,
|
24
|
-
position: [10, 10, 0]
|
25
|
-
}
|
26
|
-
};
|
27
|
-
const VIDEO_SIZE = {
|
28
|
-
big: { width: 640, height: 480 },
|
29
|
-
small: { width: 360, height: 270 }
|
30
|
-
};
|
31
|
-
const ASSISTANT_MODEL_CONTAINER_CLASS = "assistant-robot-model-container";
|
32
|
-
const ASSISTANT_TIP_CONTAINER = "assistant_tip_container";
|
33
|
-
const CONTAINER_HEAD = `<div class="assistant-robot-container `;
|
34
|
-
const CONTAINER_BODY = `">
|
35
|
-
<style>
|
36
|
-
.assistant-robot-container{
|
37
|
-
width: 100%;
|
38
|
-
height: 100%;
|
39
|
-
display: flex;
|
40
|
-
flex-direction: column;
|
41
|
-
}
|
42
|
-
.${ASSISTANT_MODEL_CONTAINER_CLASS}{
|
43
|
-
flex: 1;
|
44
|
-
position:relative;
|
45
|
-
width:100%;
|
46
|
-
}
|
47
|
-
.${ASSISTANT_TIP_CONTAINER}{
|
48
|
-
position: absolute;
|
49
|
-
top: 2px;
|
50
|
-
left: 50%;
|
51
|
-
min-width: 100px;
|
52
|
-
border: 1px solid #aaaaaa;
|
53
|
-
border-radius: 6px;
|
54
|
-
background: #fff;
|
55
|
-
transform: translate(-50%);
|
56
|
-
padding: 12px 20px;
|
57
|
-
text-align: center;
|
58
|
-
}
|
59
|
-
.${ASSISTANT_TIP_CONTAINER}::after{
|
60
|
-
content: '';
|
61
|
-
display: block;
|
62
|
-
position: absolute;
|
63
|
-
bottom: -6px;
|
64
|
-
left: 50%;
|
65
|
-
width: 8px;
|
66
|
-
height: 8px;
|
67
|
-
transform: rotate(45deg);
|
68
|
-
border-bottom: 1px solid #aaaaaa;
|
69
|
-
border-right: 1px solid #aaaaaa;
|
70
|
-
background: #fff;
|
71
|
-
}
|
72
|
-
</style>
|
73
|
-
<div class="${ASSISTANT_MODEL_CONTAINER_CLASS}">
|
74
|
-
<div class="${ASSISTANT_TIP_CONTAINER}">HI!</div>
|
75
|
-
|
76
|
-
</div>
|
77
|
-
<div>
|
78
|
-
`;
|
79
|
-
const ROBOT_CHAT_INPUT_CLASS = "assistant-robot-input";
|
80
|
-
const ROBOT_CHAT_BTN_CLASS = "assistant-robot-btn";
|
81
|
-
const ROBOT_CHAT_BOX_HEAD = '<div class="assistant-robot-chartbox';
|
82
|
-
const ROBOT_CHAT_BOX_BODY = `">
|
83
|
-
<style>
|
84
|
-
.assistant-robot-chartbox{
|
85
|
-
width: 100%;
|
86
|
-
display: flex;
|
87
|
-
flex-wrap: wrap;
|
88
|
-
}
|
89
|
-
.assistant-robot-input{
|
90
|
-
flex: 1;
|
91
|
-
min-width: 200px;
|
92
|
-
background: rgba(0,0,0,0);
|
93
|
-
border: 1px solid #aaaaaa;
|
94
|
-
}
|
95
|
-
.assistant-robot-btn{
|
96
|
-
flex: 0 0 auto;
|
97
|
-
}
|
98
|
-
</style>
|
99
|
-
<input class="${ROBOT_CHAT_INPUT_CLASS}" type="text" />
|
100
|
-
<button class="${ROBOT_CHAT_BTN_CLASS}">ask</button>
|
101
|
-
</div>`;
|
102
|
-
const LanguageModelStatus = {
|
103
|
-
loading: 1,
|
104
|
-
ready: 2,
|
105
|
-
error: 3
|
106
|
-
};
|
107
|
-
function isiOS() {
|
108
|
-
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
109
|
-
}
|
110
|
-
function isAndroid() {
|
111
|
-
return /Android/i.test(navigator.userAgent);
|
112
|
-
}
|
113
|
-
function isMobile() {
|
114
|
-
return isAndroid() || isiOS();
|
115
|
-
}
|
116
|
-
function parseHTML(htmlString) {
|
117
|
-
const parser = new DOMParser();
|
118
|
-
const doc = parser.parseFromString(htmlString, "text/html");
|
119
|
-
return doc.body.firstElementChild;
|
120
|
-
}
|
121
|
-
function findHighestScoreItem(data) {
|
122
|
-
if (!Array.isArray(data) || data.length === 0) {
|
123
|
-
return null;
|
124
|
-
}
|
125
|
-
let maxScore = -Infinity;
|
126
|
-
let maxScoreItem = null;
|
127
|
-
for (let i = 0; i < data.length; i++) {
|
128
|
-
const currentItem = data[i];
|
129
|
-
if (currentItem && typeof currentItem.score === "number") {
|
130
|
-
if (currentItem.score > maxScore) {
|
131
|
-
maxScore = currentItem.score;
|
132
|
-
maxScoreItem = currentItem;
|
133
|
-
}
|
134
|
-
}
|
135
|
-
}
|
136
|
-
return maxScoreItem;
|
137
|
-
}
|
138
|
-
exports.ASSISTANT_MODEL_CONTAINER_CLASS = ASSISTANT_MODEL_CONTAINER_CLASS;
|
139
|
-
exports.ASSISTANT_TIP_CONTAINER = ASSISTANT_TIP_CONTAINER;
|
140
|
-
exports.CONTAINER_BODY = CONTAINER_BODY;
|
141
|
-
exports.CONTAINER_HEAD = CONTAINER_HEAD;
|
142
|
-
exports.LanguageModelStatus = LanguageModelStatus;
|
143
|
-
exports.MODEL_CONFIG = MODEL_CONFIG;
|
144
|
-
exports.MODEL_SCENE_CONFIG = MODEL_SCENE_CONFIG;
|
145
|
-
exports.ROBOT_CHAT_BOX_BODY = ROBOT_CHAT_BOX_BODY;
|
146
|
-
exports.ROBOT_CHAT_BOX_HEAD = ROBOT_CHAT_BOX_HEAD;
|
147
|
-
exports.ROBOT_CHAT_BTN_CLASS = ROBOT_CHAT_BTN_CLASS;
|
148
|
-
exports.ROBOT_CHAT_INPUT_CLASS = ROBOT_CHAT_INPUT_CLASS;
|
149
|
-
exports.TARGET_FPS = TARGET_FPS;
|
150
|
-
exports.VIDEO_SIZE = VIDEO_SIZE;
|
151
|
-
exports.findHighestScoreItem = findHighestScoreItem;
|
152
|
-
exports.isMobile = isMobile;
|
153
|
-
exports.parseHTML = parseHTML;
|
package/dist/utils-7giLo_Tq.mjs
DELETED
@@ -1,154 +0,0 @@
|
|
1
|
-
const TARGET_FPS = 60;
|
2
|
-
const MODEL_CONFIG = {
|
3
|
-
position: [0, 0, 0],
|
4
|
-
rotation: [0, Math.PI, 0]
|
5
|
-
};
|
6
|
-
const MODEL_SCENE_CONFIG = {
|
7
|
-
backgroundColor: 0,
|
8
|
-
backgroundAlpha: 0,
|
9
|
-
camera: {
|
10
|
-
fov: 50,
|
11
|
-
near: 0.1,
|
12
|
-
far: 10,
|
13
|
-
position: [0, 0, 2],
|
14
|
-
lookAt: [0, 0, 0]
|
15
|
-
},
|
16
|
-
ambientLight: {
|
17
|
-
color: 16777215,
|
18
|
-
intensity: 0.5
|
19
|
-
},
|
20
|
-
directionalLight: {
|
21
|
-
color: 16777215,
|
22
|
-
intensity: 2,
|
23
|
-
position: [10, 10, 0]
|
24
|
-
}
|
25
|
-
};
|
26
|
-
const VIDEO_SIZE = {
|
27
|
-
big: { width: 640, height: 480 },
|
28
|
-
small: { width: 360, height: 270 }
|
29
|
-
};
|
30
|
-
const ASSISTANT_MODEL_CONTAINER_CLASS = "assistant-robot-model-container";
|
31
|
-
const ASSISTANT_TIP_CONTAINER = "assistant_tip_container";
|
32
|
-
const CONTAINER_HEAD = `<div class="assistant-robot-container `;
|
33
|
-
const CONTAINER_BODY = `">
|
34
|
-
<style>
|
35
|
-
.assistant-robot-container{
|
36
|
-
width: 100%;
|
37
|
-
height: 100%;
|
38
|
-
display: flex;
|
39
|
-
flex-direction: column;
|
40
|
-
}
|
41
|
-
.${ASSISTANT_MODEL_CONTAINER_CLASS}{
|
42
|
-
flex: 1;
|
43
|
-
position:relative;
|
44
|
-
width:100%;
|
45
|
-
}
|
46
|
-
.${ASSISTANT_TIP_CONTAINER}{
|
47
|
-
position: absolute;
|
48
|
-
top: 2px;
|
49
|
-
left: 50%;
|
50
|
-
min-width: 100px;
|
51
|
-
border: 1px solid #aaaaaa;
|
52
|
-
border-radius: 6px;
|
53
|
-
background: #fff;
|
54
|
-
transform: translate(-50%);
|
55
|
-
padding: 12px 20px;
|
56
|
-
text-align: center;
|
57
|
-
}
|
58
|
-
.${ASSISTANT_TIP_CONTAINER}::after{
|
59
|
-
content: '';
|
60
|
-
display: block;
|
61
|
-
position: absolute;
|
62
|
-
bottom: -6px;
|
63
|
-
left: 50%;
|
64
|
-
width: 8px;
|
65
|
-
height: 8px;
|
66
|
-
transform: rotate(45deg);
|
67
|
-
border-bottom: 1px solid #aaaaaa;
|
68
|
-
border-right: 1px solid #aaaaaa;
|
69
|
-
background: #fff;
|
70
|
-
}
|
71
|
-
</style>
|
72
|
-
<div class="${ASSISTANT_MODEL_CONTAINER_CLASS}">
|
73
|
-
<div class="${ASSISTANT_TIP_CONTAINER}">HI!</div>
|
74
|
-
|
75
|
-
</div>
|
76
|
-
<div>
|
77
|
-
`;
|
78
|
-
const ROBOT_CHAT_INPUT_CLASS = "assistant-robot-input";
|
79
|
-
const ROBOT_CHAT_BTN_CLASS = "assistant-robot-btn";
|
80
|
-
const ROBOT_CHAT_BOX_HEAD = '<div class="assistant-robot-chartbox';
|
81
|
-
const ROBOT_CHAT_BOX_BODY = `">
|
82
|
-
<style>
|
83
|
-
.assistant-robot-chartbox{
|
84
|
-
width: 100%;
|
85
|
-
display: flex;
|
86
|
-
flex-wrap: wrap;
|
87
|
-
}
|
88
|
-
.assistant-robot-input{
|
89
|
-
flex: 1;
|
90
|
-
min-width: 200px;
|
91
|
-
background: rgba(0,0,0,0);
|
92
|
-
border: 1px solid #aaaaaa;
|
93
|
-
}
|
94
|
-
.assistant-robot-btn{
|
95
|
-
flex: 0 0 auto;
|
96
|
-
}
|
97
|
-
</style>
|
98
|
-
<input class="${ROBOT_CHAT_INPUT_CLASS}" type="text" />
|
99
|
-
<button class="${ROBOT_CHAT_BTN_CLASS}">ask</button>
|
100
|
-
</div>`;
|
101
|
-
const LanguageModelStatus = {
|
102
|
-
loading: 1,
|
103
|
-
ready: 2,
|
104
|
-
error: 3
|
105
|
-
};
|
106
|
-
function isiOS() {
|
107
|
-
return /iPhone|iPad|iPod/i.test(navigator.userAgent);
|
108
|
-
}
|
109
|
-
function isAndroid() {
|
110
|
-
return /Android/i.test(navigator.userAgent);
|
111
|
-
}
|
112
|
-
function isMobile() {
|
113
|
-
return isAndroid() || isiOS();
|
114
|
-
}
|
115
|
-
function parseHTML(htmlString) {
|
116
|
-
const parser = new DOMParser();
|
117
|
-
const doc = parser.parseFromString(htmlString, "text/html");
|
118
|
-
return doc.body.firstElementChild;
|
119
|
-
}
|
120
|
-
function findHighestScoreItem(data) {
|
121
|
-
if (!Array.isArray(data) || data.length === 0) {
|
122
|
-
return null;
|
123
|
-
}
|
124
|
-
let maxScore = -Infinity;
|
125
|
-
let maxScoreItem = null;
|
126
|
-
for (let i = 0; i < data.length; i++) {
|
127
|
-
const currentItem = data[i];
|
128
|
-
if (currentItem && typeof currentItem.score === "number") {
|
129
|
-
if (currentItem.score > maxScore) {
|
130
|
-
maxScore = currentItem.score;
|
131
|
-
maxScoreItem = currentItem;
|
132
|
-
}
|
133
|
-
}
|
134
|
-
}
|
135
|
-
return maxScoreItem;
|
136
|
-
}
|
137
|
-
export {
|
138
|
-
ASSISTANT_TIP_CONTAINER as A,
|
139
|
-
CONTAINER_HEAD as C,
|
140
|
-
LanguageModelStatus as L,
|
141
|
-
MODEL_SCENE_CONFIG as M,
|
142
|
-
ROBOT_CHAT_BOX_HEAD as R,
|
143
|
-
TARGET_FPS as T,
|
144
|
-
VIDEO_SIZE as V,
|
145
|
-
MODEL_CONFIG as a,
|
146
|
-
ROBOT_CHAT_BOX_BODY as b,
|
147
|
-
ROBOT_CHAT_BTN_CLASS as c,
|
148
|
-
ROBOT_CHAT_INPUT_CLASS as d,
|
149
|
-
CONTAINER_BODY as e,
|
150
|
-
ASSISTANT_MODEL_CONTAINER_CLASS as f,
|
151
|
-
findHighestScoreItem as g,
|
152
|
-
isMobile as i,
|
153
|
-
parseHTML as p
|
154
|
-
};
|