@ray-js/t-agent-ui-ray 0.0.9-beta-3 → 0.0.9
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/dist/CustomCardRender/index.js +3 -3
- package/dist/TileRender/index.js +4 -3
- package/dist/hooks/context.js +3 -3
- package/dist/tiles/BubbleTile/index.js +2 -32
- package/dist/tiles/ButtonsTile/index.js +1 -1
- package/dist/tiles/RecommendationsTile/index.js +1 -1
- package/dist/tiles/WorkflowTile/index.js +1 -1
- package/dist/types.d.ts +8 -2
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ export default function CustomCardRender(_ref) {
|
|
|
10
10
|
customCardMap
|
|
11
11
|
} = useRenderOptions();
|
|
12
12
|
const {
|
|
13
|
-
|
|
13
|
+
emitTileEvent
|
|
14
14
|
} = useTileProps();
|
|
15
15
|
const ref = useRef(card);
|
|
16
16
|
useEffect(() => {
|
|
@@ -20,12 +20,12 @@ export default function CustomCardRender(_ref) {
|
|
|
20
20
|
if (typeof state === 'function') {
|
|
21
21
|
state = state(ref.current.cardState);
|
|
22
22
|
}
|
|
23
|
-
|
|
23
|
+
emitTileEvent({
|
|
24
24
|
type: '@buildIn/setCardState',
|
|
25
25
|
state,
|
|
26
26
|
options: options || {}
|
|
27
27
|
});
|
|
28
|
-
}, [
|
|
28
|
+
}, [emitTileEvent]);
|
|
29
29
|
const Card = customCardMap[card.cardCode];
|
|
30
30
|
if (!Card) {
|
|
31
31
|
return null;
|
package/dist/TileRender/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const TileRender = _ref => {
|
|
|
10
10
|
side
|
|
11
11
|
} = _ref;
|
|
12
12
|
const agent = useChatAgent();
|
|
13
|
-
const
|
|
13
|
+
const emitTileEvent = useCallback(async payload => agent.emitTileEvent(tile.id, payload), [agent, tile.id]);
|
|
14
14
|
const {
|
|
15
15
|
renderTileAs
|
|
16
16
|
} = useRenderOptions();
|
|
@@ -21,9 +21,10 @@ const TileRender = _ref => {
|
|
|
21
21
|
message,
|
|
22
22
|
side,
|
|
23
23
|
isLatestMessage,
|
|
24
|
-
emitEvent
|
|
24
|
+
emitEvent: emitTileEvent,
|
|
25
|
+
emitTileEvent
|
|
25
26
|
};
|
|
26
|
-
}, [agent, tile, message, side, isLatestMessage,
|
|
27
|
+
}, [agent, tile, message, side, isLatestMessage, emitTileEvent]);
|
|
27
28
|
const node = renderTileAs(props);
|
|
28
29
|
return /*#__PURE__*/React.createElement(TilePropsContext.Provider, {
|
|
29
30
|
value: props
|
package/dist/hooks/context.js
CHANGED
|
@@ -30,11 +30,11 @@ export const useTileProps = () => {
|
|
|
30
30
|
};
|
|
31
31
|
export const useSendAction = () => {
|
|
32
32
|
const {
|
|
33
|
-
|
|
33
|
+
emitTileEvent
|
|
34
34
|
} = useTileProps();
|
|
35
35
|
return useCallback(tttAction => {
|
|
36
|
-
|
|
36
|
+
emitTileEvent({
|
|
37
37
|
tttAction
|
|
38
38
|
});
|
|
39
|
-
}, [
|
|
39
|
+
}, [emitTileEvent]);
|
|
40
40
|
};
|
|
@@ -9,7 +9,6 @@ import { Image } from '@ray-js/ray';
|
|
|
9
9
|
import { BubbleTileStatus, ChatMessageStatus, safeParseJSON } from '@ray-js/t-agent';
|
|
10
10
|
import { getCurrentHomeInfo, submitEvaluation } from '@ray-js/t-agent-plugin-assistant';
|
|
11
11
|
import TileRender from '../../TileRender';
|
|
12
|
-
import Feedback from './Feedback';
|
|
13
12
|
import noticeSvg from './notice.svg';
|
|
14
13
|
import noticeWarnSvg from './notice-warn.svg';
|
|
15
14
|
import { useChatAgent, useRenderOptions } from '../../hooks';
|
|
@@ -35,7 +34,7 @@ const BubbleTile = props => {
|
|
|
35
34
|
i18nTranslate: t
|
|
36
35
|
} = useRenderOptions();
|
|
37
36
|
const loading = status === ChatMessageStatus.START || status === ChatMessageStatus.UPDATING;
|
|
38
|
-
|
|
37
|
+
isLatestMessage && status === ChatMessageStatus.FINISH && role === 'assistant' && ((_message$meta$request = message.meta.requestId) === null || _message$meta$request === void 0 ? void 0 : _message$meta$request.startsWith('AIAssistant')) && bubbleStatus === BubbleTileStatus.NORMAL;
|
|
39
38
|
const [feedbackLoaded, setFeedbackLoaded] = useState(false);
|
|
40
39
|
const [feedbackValue, setFeedbackValue] = useState(null);
|
|
41
40
|
useEffect(() => {
|
|
@@ -99,36 +98,7 @@ const BubbleTile = props => {
|
|
|
99
98
|
});
|
|
100
99
|
}), status === ChatMessageStatus.START && /*#__PURE__*/React.createElement(Text, {
|
|
101
100
|
className: "t-agent-bubble-tile-bubble-loader"
|
|
102
|
-
}, "..."),
|
|
103
|
-
value: feedbackValue,
|
|
104
|
-
onChange: async value => {
|
|
105
|
-
const channel = agent.session.get('AIAssistant.channel');
|
|
106
|
-
if (!message.meta.requestId || !channel) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
setFeedbackValue(value);
|
|
110
|
-
const {
|
|
111
|
-
homeId
|
|
112
|
-
} = await getCurrentHomeInfo();
|
|
113
|
-
await submitEvaluation({
|
|
114
|
-
homeId,
|
|
115
|
-
requestId: message.meta.requestId,
|
|
116
|
-
score: value,
|
|
117
|
-
channel
|
|
118
|
-
});
|
|
119
|
-
ty.setStorage({
|
|
120
|
-
key: 'latestMessageFeedbackValue',
|
|
121
|
-
data: JSON.stringify({
|
|
122
|
-
requestId: message.meta.requestId,
|
|
123
|
-
value
|
|
124
|
-
})
|
|
125
|
-
});
|
|
126
|
-
ty.showToast({
|
|
127
|
-
title: t('t-agent.message.feedback.success'),
|
|
128
|
-
icon: 'none'
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
}), bubbleStatus === BubbleTileStatus.ABORTED && /*#__PURE__*/React.createElement(View, {
|
|
101
|
+
}, "..."), bubbleStatus === BubbleTileStatus.ABORTED && /*#__PURE__*/React.createElement(View, {
|
|
132
102
|
className: "t-agent-bubble-tile-aborted"
|
|
133
103
|
}, t('t-agent.message.bubble.aborted'))), side === 'start' && errorNode);
|
|
134
104
|
};
|
|
@@ -22,7 +22,7 @@ export default function ButtonsTile(props) {
|
|
|
22
22
|
key: "".concat(text, "-").concat(item.type || ''),
|
|
23
23
|
className: "t-agent-buttons-tile-button ".concat(item.type ? "t-agent-buttons-tile-button-".concat(item.type) : ''),
|
|
24
24
|
onClick: () => {
|
|
25
|
-
item.clickPayload && props.
|
|
25
|
+
item.clickPayload && props.emitTileEvent(item.clickPayload);
|
|
26
26
|
}
|
|
27
27
|
}, text);
|
|
28
28
|
}));
|
|
@@ -26,7 +26,7 @@ export default function RecommendationsTile(props) {
|
|
|
26
26
|
key: "".concat(item.text),
|
|
27
27
|
className: "t-agent-recommendations-tile-item",
|
|
28
28
|
onClick: () => {
|
|
29
|
-
item.clickPayload && props.
|
|
29
|
+
item.clickPayload && props.emitTileEvent(item.clickPayload);
|
|
30
30
|
}
|
|
31
31
|
}, "\u2192 ", item.text)));
|
|
32
32
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChatCardObject, ChatMessageObject, ChatTileObject } from '@ray-js/t-agent';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { UIChatAgent } from './contexts';
|
|
3
4
|
export interface TileProps<T = any, P = any> {
|
|
4
5
|
side: 'start' | 'end' | string;
|
|
5
6
|
message: ChatMessageObject;
|
|
6
7
|
tile: ChatTileObject<T>;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Use `emitTileEvent` instead
|
|
10
|
+
* @param payload
|
|
11
|
+
*/
|
|
7
12
|
emitEvent: (payload: P) => void;
|
|
13
|
+
emitTileEvent: (payload: P) => void;
|
|
8
14
|
isLatestMessage?: boolean;
|
|
9
|
-
agent:
|
|
15
|
+
agent: UIChatAgent;
|
|
10
16
|
}
|
|
11
17
|
export interface MarkdownBlock {
|
|
12
18
|
id: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ray-js/t-agent-ui-ray",
|
|
3
|
-
"version": "0.0.9
|
|
3
|
+
"version": "0.0.9",
|
|
4
4
|
"author": "Tuya.inc",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -41,5 +41,5 @@
|
|
|
41
41
|
"@types/echarts": "^4.9.22",
|
|
42
42
|
"@types/markdown-it": "^14.1.1"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "328a8616b0356cbaef02d7a4ad46ee0c077d04be"
|
|
45
45
|
}
|