agora-appbuilder-core 4.1.0-beta-5 → 4.1.0-beta-6
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/package.json
CHANGED
|
@@ -1,16 +1,43 @@
|
|
|
1
|
-
import React, {useContext, useEffect} from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import React, {SetStateAction, useContext, useEffect, useState} from 'react';
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
TextInput,
|
|
5
|
+
StyleSheet,
|
|
6
|
+
Text,
|
|
7
|
+
Platform,
|
|
8
|
+
TouchableOpacity,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
ModalProps,
|
|
11
|
+
TouchableWithoutFeedback,
|
|
12
|
+
Modal,
|
|
13
|
+
} from 'react-native';
|
|
3
14
|
import ThemeConfig from '../../theme';
|
|
4
15
|
import {AgentContext} from './AgentControls/AgentContext';
|
|
5
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
IconButton,
|
|
18
|
+
PrimaryButton,
|
|
19
|
+
Spacer,
|
|
20
|
+
TertiaryButton,
|
|
21
|
+
useRoomInfo,
|
|
22
|
+
} from 'customization-api';
|
|
23
|
+
import {useIsDesktop, isMobileUA} from '../../utils/common';
|
|
24
|
+
import hexadecimalTransparency from '../../utils/hexadecimalTransparency';
|
|
6
25
|
|
|
7
26
|
const UserPrompt = () => {
|
|
27
|
+
const isDesktop = useIsDesktop()('popup');
|
|
28
|
+
const [isModalOpen, setModalOpen] = useState(false);
|
|
8
29
|
const {prompt, setPrompt, agentConnectionState, agentId} =
|
|
9
30
|
useContext(AgentContext);
|
|
10
31
|
const {
|
|
11
32
|
data: {agents},
|
|
12
33
|
} = useRoomInfo();
|
|
13
34
|
|
|
35
|
+
const [localPrompt, setLocalPrompt] = useState('');
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
setLocalPrompt(prompt);
|
|
39
|
+
}, [prompt]);
|
|
40
|
+
|
|
14
41
|
useEffect(() => {
|
|
15
42
|
if (agentId) {
|
|
16
43
|
setPrompt(agents?.find(a => a?.id === agentId)?.config?.llm?.prompt);
|
|
@@ -21,25 +48,136 @@ const UserPrompt = () => {
|
|
|
21
48
|
<Text style={styles.label}>Prompt</Text>
|
|
22
49
|
<View style={styles.container}>
|
|
23
50
|
<TextInput
|
|
24
|
-
aria-disabled={
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
style={[
|
|
28
|
-
styles.input,
|
|
29
|
-
agentConnectionState === 'AGENT_CONNECTED' ? {opacity: 0.4} : {},
|
|
30
|
-
]}
|
|
51
|
+
aria-disabled={true}
|
|
52
|
+
style={[styles.input, {opacity: 0.4}]}
|
|
31
53
|
value={prompt}
|
|
32
54
|
onChangeText={setPrompt}
|
|
33
55
|
placeholder="Customize Prompt"
|
|
34
|
-
numberOfLines={
|
|
56
|
+
numberOfLines={5}
|
|
35
57
|
multiline={true}
|
|
36
58
|
/>
|
|
37
59
|
</View>
|
|
60
|
+
<TouchableOpacity
|
|
61
|
+
style={[
|
|
62
|
+
styles.promptBtnContainer,
|
|
63
|
+
agentConnectionState === 'AGENT_CONNECTED'
|
|
64
|
+
? styles.promptBtnContainerDisabled
|
|
65
|
+
: {},
|
|
66
|
+
]}
|
|
67
|
+
onPress={() => setModalOpen(true)}>
|
|
68
|
+
<Text style={styles.promptBtnText}>Customize Prompt</Text>
|
|
69
|
+
</TouchableOpacity>
|
|
70
|
+
<PromptModal
|
|
71
|
+
modalVisible={isModalOpen}
|
|
72
|
+
setModalVisible={setModalOpen}
|
|
73
|
+
showCloseIcon={true}
|
|
74
|
+
title={'Customize Prompt'}
|
|
75
|
+
cancelable={false}
|
|
76
|
+
contentContainerStyle={modalStyles.mContainer}>
|
|
77
|
+
<View style={modalStyles.mbody}>
|
|
78
|
+
<View style={[styles.container, {flex: 3}]}>
|
|
79
|
+
<TextInput
|
|
80
|
+
style={[styles.input]}
|
|
81
|
+
value={localPrompt}
|
|
82
|
+
onChangeText={setLocalPrompt}
|
|
83
|
+
placeholder="Customize Prompt"
|
|
84
|
+
numberOfLines={45}
|
|
85
|
+
multiline={true}
|
|
86
|
+
/>
|
|
87
|
+
</View>
|
|
88
|
+
<View style={styles.infoTextContainer}>
|
|
89
|
+
<Text style={styles.infoText}>
|
|
90
|
+
Fine-tune your AI agent’s behavior by editing its prompt.
|
|
91
|
+
</Text>
|
|
92
|
+
</View>
|
|
93
|
+
<View
|
|
94
|
+
style={[
|
|
95
|
+
isDesktop ? styles.btnContainer : styles.btnContainerMobile,
|
|
96
|
+
isMobileUA() ? {flex: 1} : {flex: 0.5},
|
|
97
|
+
]}>
|
|
98
|
+
<View style={isDesktop && {flex: 1}}>
|
|
99
|
+
<TertiaryButton
|
|
100
|
+
containerStyle={{
|
|
101
|
+
width: '100%',
|
|
102
|
+
height: 48,
|
|
103
|
+
paddingVertical: 12,
|
|
104
|
+
paddingHorizontal: 12,
|
|
105
|
+
borderRadius: ThemeConfig.BorderRadius.medium,
|
|
106
|
+
}}
|
|
107
|
+
textStyle={styles.btnText}
|
|
108
|
+
text={'CANCEL'}
|
|
109
|
+
onPress={() => {
|
|
110
|
+
setLocalPrompt(prompt);
|
|
111
|
+
setModalOpen(false);
|
|
112
|
+
}}
|
|
113
|
+
/>
|
|
114
|
+
</View>
|
|
115
|
+
<Spacer
|
|
116
|
+
size={isDesktop ? 40 : 20}
|
|
117
|
+
horizontal={isDesktop ? true : false}
|
|
118
|
+
/>
|
|
119
|
+
<View style={isDesktop && {flex: 1}}>
|
|
120
|
+
<PrimaryButton
|
|
121
|
+
containerStyle={{
|
|
122
|
+
minWidth: 'auto',
|
|
123
|
+
width: '100%',
|
|
124
|
+
borderRadius: ThemeConfig.BorderRadius.medium,
|
|
125
|
+
height: 48,
|
|
126
|
+
backgroundColor: $config.PRIMARY_ACTION_BRAND_COLOR,
|
|
127
|
+
paddingVertical: 12,
|
|
128
|
+
paddingHorizontal: 12,
|
|
129
|
+
}}
|
|
130
|
+
textStyle={styles.btnText}
|
|
131
|
+
text={'UPDATE'}
|
|
132
|
+
onPress={() => {
|
|
133
|
+
setPrompt(localPrompt);
|
|
134
|
+
setModalOpen(false);
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
</View>
|
|
138
|
+
</View>
|
|
139
|
+
</View>
|
|
140
|
+
</PromptModal>
|
|
38
141
|
</>
|
|
39
142
|
);
|
|
40
143
|
};
|
|
41
144
|
|
|
42
145
|
const styles = StyleSheet.create({
|
|
146
|
+
infoTextContainer: {
|
|
147
|
+
padding: 8,
|
|
148
|
+
},
|
|
149
|
+
infoText: {
|
|
150
|
+
color: $config.FONT_COLOR,
|
|
151
|
+
fontFamily: ThemeConfig.FontFamily.sansPro,
|
|
152
|
+
fontSize: 12,
|
|
153
|
+
lineHeight: 12,
|
|
154
|
+
},
|
|
155
|
+
promptBtnContainer: {
|
|
156
|
+
padding: 8,
|
|
157
|
+
},
|
|
158
|
+
promptBtnContainerDisabled: {
|
|
159
|
+
opacity: 0.4,
|
|
160
|
+
},
|
|
161
|
+
btnContainer: {
|
|
162
|
+
flex: 1,
|
|
163
|
+
flexDirection: 'row',
|
|
164
|
+
justifyContent: 'center',
|
|
165
|
+
alignItems: 'center',
|
|
166
|
+
},
|
|
167
|
+
btnContainerMobile: {
|
|
168
|
+
flexDirection: 'column-reverse',
|
|
169
|
+
},
|
|
170
|
+
promptBtnText: {
|
|
171
|
+
color: $config.PRIMARY_ACTION_BRAND_COLOR,
|
|
172
|
+
fontFamily: ThemeConfig.FontFamily.sansPro,
|
|
173
|
+
fontSize: 14,
|
|
174
|
+
lineHeight: 14,
|
|
175
|
+
},
|
|
176
|
+
btnText: {
|
|
177
|
+
fontWeight: '600',
|
|
178
|
+
fontSize: 16,
|
|
179
|
+
lineHeight: 24,
|
|
180
|
+
},
|
|
43
181
|
container: {
|
|
44
182
|
flex: 1,
|
|
45
183
|
justifyContent: 'center',
|
|
@@ -72,4 +210,158 @@ const styles = StyleSheet.create({
|
|
|
72
210
|
},
|
|
73
211
|
});
|
|
74
212
|
|
|
213
|
+
interface PromptModalProps extends ModalProps {
|
|
214
|
+
title?: string;
|
|
215
|
+
subtitle?: string;
|
|
216
|
+
modalVisible: boolean;
|
|
217
|
+
setModalVisible: React.Dispatch<SetStateAction<boolean>>;
|
|
218
|
+
showCloseIcon?: boolean;
|
|
219
|
+
children: React.ReactNode;
|
|
220
|
+
contentContainerStyle?: ViewStyle;
|
|
221
|
+
containerStyle?: ViewStyle;
|
|
222
|
+
cancelable?: boolean;
|
|
223
|
+
}
|
|
224
|
+
const PromptModal = (props: PromptModalProps) => {
|
|
225
|
+
const {
|
|
226
|
+
title,
|
|
227
|
+
modalVisible,
|
|
228
|
+
setModalVisible,
|
|
229
|
+
children,
|
|
230
|
+
cancelable = false,
|
|
231
|
+
} = props;
|
|
232
|
+
|
|
233
|
+
const isDesktop = useIsDesktop()('popup');
|
|
234
|
+
|
|
235
|
+
return (
|
|
236
|
+
<Modal
|
|
237
|
+
animationType="none"
|
|
238
|
+
transparent={true}
|
|
239
|
+
visible={modalVisible}
|
|
240
|
+
onRequestClose={() => {
|
|
241
|
+
setModalVisible(false);
|
|
242
|
+
}}>
|
|
243
|
+
<View
|
|
244
|
+
style={[modalStyles.centeredView, isDesktop && {alignItems: 'center'}]}>
|
|
245
|
+
<TouchableWithoutFeedback
|
|
246
|
+
onPress={() => {
|
|
247
|
+
cancelable && setModalVisible(false);
|
|
248
|
+
}}>
|
|
249
|
+
<View style={modalStyles.backDrop} />
|
|
250
|
+
</TouchableWithoutFeedback>
|
|
251
|
+
<View style={[modalStyles.modalView, props?.contentContainerStyle]}>
|
|
252
|
+
<View style={modalStyles.header}>
|
|
253
|
+
<Text style={modalStyles.title}>{title}</Text>
|
|
254
|
+
<View>
|
|
255
|
+
<IconButton
|
|
256
|
+
hoverEffect={true}
|
|
257
|
+
hoverEffectStyle={{
|
|
258
|
+
backgroundColor: $config.ICON_BG_COLOR,
|
|
259
|
+
borderRadius: 20,
|
|
260
|
+
}}
|
|
261
|
+
iconProps={{
|
|
262
|
+
iconType: 'plain',
|
|
263
|
+
iconContainerStyle: {
|
|
264
|
+
padding: isMobileUA() ? 0 : 5,
|
|
265
|
+
},
|
|
266
|
+
name: 'close',
|
|
267
|
+
tintColor: $config.SECONDARY_ACTION_COLOR,
|
|
268
|
+
}}
|
|
269
|
+
onPress={() => {
|
|
270
|
+
setModalVisible(false);
|
|
271
|
+
}}
|
|
272
|
+
/>
|
|
273
|
+
</View>
|
|
274
|
+
</View>
|
|
275
|
+
{children}
|
|
276
|
+
</View>
|
|
277
|
+
</View>
|
|
278
|
+
</Modal>
|
|
279
|
+
);
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
const modalStyles = StyleSheet.create({
|
|
283
|
+
mContainer: {
|
|
284
|
+
display: 'flex',
|
|
285
|
+
flexDirection: 'column',
|
|
286
|
+
alignItems: 'flex-start',
|
|
287
|
+
flexShrink: 0,
|
|
288
|
+
// width: 620,
|
|
289
|
+
width: '100%',
|
|
290
|
+
maxWidth: 680,
|
|
291
|
+
minWidth: 340,
|
|
292
|
+
height: 620,
|
|
293
|
+
maxHeight: 620,
|
|
294
|
+
borderRadius: 4,
|
|
295
|
+
zIndex: 2,
|
|
296
|
+
},
|
|
297
|
+
mHeader: {
|
|
298
|
+
display: 'flex',
|
|
299
|
+
flexDirection: 'row',
|
|
300
|
+
width: '100%',
|
|
301
|
+
height: 60,
|
|
302
|
+
paddingHorizontal: 20,
|
|
303
|
+
paddingVertical: 12,
|
|
304
|
+
alignItems: 'center',
|
|
305
|
+
gap: 20,
|
|
306
|
+
flexShrink: 0,
|
|
307
|
+
borderWidth: 1,
|
|
308
|
+
borderColor: $config.CARD_LAYER_3_COLOR,
|
|
309
|
+
backgroundColor: $config.CARD_LAYER_1_COLOR,
|
|
310
|
+
},
|
|
311
|
+
mbody: {
|
|
312
|
+
width: '100%',
|
|
313
|
+
flex: 1,
|
|
314
|
+
padding: 10,
|
|
315
|
+
justifyContent: 'space-around',
|
|
316
|
+
},
|
|
317
|
+
centeredView: {
|
|
318
|
+
flex: 1,
|
|
319
|
+
position: 'relative',
|
|
320
|
+
justifyContent: 'center',
|
|
321
|
+
alignItems: 'center',
|
|
322
|
+
paddingHorizontal: 20,
|
|
323
|
+
},
|
|
324
|
+
modalView: {
|
|
325
|
+
backgroundColor: $config.CARD_LAYER_1_COLOR,
|
|
326
|
+
borderWidth: 1,
|
|
327
|
+
borderColor: $config.CARD_LAYER_3_COLOR,
|
|
328
|
+
borderRadius: ThemeConfig.BorderRadius.large,
|
|
329
|
+
shadowColor: $config.HARD_CODED_BLACK_COLOR,
|
|
330
|
+
shadowOffset: {
|
|
331
|
+
width: 0,
|
|
332
|
+
height: 2,
|
|
333
|
+
},
|
|
334
|
+
shadowOpacity: 0.1,
|
|
335
|
+
shadowRadius: 4,
|
|
336
|
+
elevation: 5,
|
|
337
|
+
maxWidth: 650,
|
|
338
|
+
},
|
|
339
|
+
backDrop: {
|
|
340
|
+
zIndex: 1,
|
|
341
|
+
position: 'absolute',
|
|
342
|
+
top: 0,
|
|
343
|
+
bottom: 0,
|
|
344
|
+
left: 0,
|
|
345
|
+
right: 0,
|
|
346
|
+
backgroundColor:
|
|
347
|
+
$config.HARD_CODED_BLACK_COLOR + hexadecimalTransparency['60%'],
|
|
348
|
+
},
|
|
349
|
+
header: {
|
|
350
|
+
flexDirection: 'row',
|
|
351
|
+
justifyContent: 'space-between',
|
|
352
|
+
alignItems: 'flex-start',
|
|
353
|
+
paddingVertical: 12,
|
|
354
|
+
paddingHorizontal: 20,
|
|
355
|
+
width: '100%',
|
|
356
|
+
},
|
|
357
|
+
title: {
|
|
358
|
+
color: $config.FONT_COLOR + ThemeConfig.EmphasisPlus.high,
|
|
359
|
+
fontFamily: ThemeConfig.FontFamily.sansPro,
|
|
360
|
+
fontSize: ThemeConfig.FontSize.xLarge,
|
|
361
|
+
lineHeight: 32,
|
|
362
|
+
fontWeight: '500',
|
|
363
|
+
alignSelf: 'center',
|
|
364
|
+
},
|
|
365
|
+
});
|
|
366
|
+
|
|
75
367
|
export default UserPrompt;
|