@ray-js/t-agent-ui-ray 0.0.8-beta-2 → 0.0.8

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/README-zh_CN.md CHANGED
@@ -1,5 +1,3 @@
1
- [English](./README.md) | 简体中文
2
-
3
1
  # @ray-js/t-agent-ui-ray
4
2
 
5
3
  > AI 智能体 SDK
package/README.md CHANGED
@@ -1,5 +1,3 @@
1
- English | [简体中文](./README-zh_CN.md)
2
-
3
1
  # @ray-js/t-agent-ui-ray
4
2
 
5
3
  > AI Agent SDK
@@ -5,6 +5,7 @@ interface Props {
5
5
  setText: (text: string) => void;
6
6
  onBack: () => void;
7
7
  sendDisabled: boolean;
8
+ responding: boolean;
8
9
  onSend: () => Promise<any>;
9
10
  onError: (error: Error) => void;
10
11
  onMoreClick: () => void;
@@ -5,6 +5,7 @@ import cx from 'clsx';
5
5
  import { useAsrInput } from '../hooks';
6
6
  export default function AsrInput(props) {
7
7
  const {
8
+ responding,
8
9
  sendDisabled,
9
10
  onMoreClick,
10
11
  moreOpen,
@@ -64,11 +65,11 @@ export default function AsrInput(props) {
64
65
  onTouchCancel: release,
65
66
  onTouchEnd: release
66
67
  }), /*#__PURE__*/React.createElement(Button, {
67
- disabled: sendDisabled,
68
+ disabled: sendDisabled || responding,
68
69
  "data-testid": "t-agent-message-input-asr-button-right",
69
70
  className: cx('t-agent-message-input-button', {
70
71
  't-agent-message-input-button-voice-send': state === 'pending',
71
- 't-agent-message-input-button-hide': state === 'recording' || !hasMore,
72
+ 't-agent-message-input-button-hide': state === 'recording' || !hasMore && state !== 'pending',
72
73
  't-agent-message-input-button-more': state === 'init' && hasMore,
73
74
  't-agent-message-input-button-more-open': state === 'init' && moreOpen
74
75
  }),
@@ -17,6 +17,9 @@ import { useAttachmentInput, useChatAgent, useEmitEvent, useIsUnmounted, useOnEv
17
17
  import AsrInput from './AsrInput';
18
18
  export default function MessageInput(props) {
19
19
  const [moreOpen, setMoreOpen] = useState(false);
20
+ const {
21
+ i18nTranslate: t
22
+ } = useRenderOptions();
20
23
  const [text, setText] = useState('');
21
24
  const [asrText, setAsrText] = useState('');
22
25
  const attachmentInput = useAttachmentInput();
@@ -142,7 +145,7 @@ export default function MessageInput(props) {
142
145
  if (!auth) {
143
146
  ty.showToast({
144
147
  icon: 'none',
145
- title: I18n.t('chat.input.voice.requirePermission')
148
+ title: t('t-agent.input.voice.require-permission')
146
149
  });
147
150
  return;
148
151
  }
@@ -180,7 +183,8 @@ export default function MessageInput(props) {
180
183
  moreOpen: moreOpen,
181
184
  closeMore: () => setMoreOpen(false),
182
185
  onMoreClick: openMoreClick,
183
- sendDisabled: responding || uploading,
186
+ responding: responding,
187
+ sendDisabled: uploading,
184
188
  onSend: async () => {
185
189
  if (asrText) {
186
190
  await send([...attachmentInput.blocks, {
@@ -261,7 +265,7 @@ export default function MessageInput(props) {
261
265
  } catch (e) {
262
266
  ty.showToast({
263
267
  icon: 'error',
264
- title: I18n.t('common.upload.failed')
268
+ title: t('t-agent.input.upload.failed')
265
269
  });
266
270
  }
267
271
  }
@@ -277,7 +281,7 @@ export default function MessageInput(props) {
277
281
  } catch (e) {
278
282
  ty.showToast({
279
283
  icon: 'error',
280
- title: I18n.t('common.upload.failed')
284
+ title: t('t-agent.input.upload.failed')
281
285
  });
282
286
  }
283
287
  }
@@ -72,5 +72,6 @@ export const defaultRenderOptions = {
72
72
  customBlockTypes: defaultCustomBlockTypes,
73
73
  renderCardAs: defaultRenderCardAs,
74
74
  customCardMap: {},
75
- getStaticResourceBizType: () => ''
75
+ getStaticResourceBizType: () => '',
76
+ i18nTranslate: key => I18n.t(key)
76
77
  };
@@ -12,7 +12,7 @@ import TileRender from '../../TileRender';
12
12
  import Feedback from './Feedback';
13
13
  import noticeSvg from './notice.svg';
14
14
  import noticeWarnSvg from './notice-warn.svg';
15
- import { useChatAgent } from '../../hooks';
15
+ import { useChatAgent, useRenderOptions } from '../../hooks';
16
16
  const BubbleTile = props => {
17
17
  var _message$meta$request;
18
18
  const agent = useChatAgent();
@@ -31,6 +31,9 @@ const BubbleTile = props => {
31
31
  data
32
32
  } = tile;
33
33
  const bubbleStatus = data.status || BubbleTileStatus.NORMAL;
34
+ const {
35
+ i18nTranslate: t
36
+ } = useRenderOptions();
34
37
  const loading = status === ChatMessageStatus.START || status === ChatMessageStatus.UPDATING;
35
38
  const showFeedback = 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;
36
39
  const [feedbackLoaded, setFeedbackLoaded] = useState(false);
@@ -77,7 +80,7 @@ const BubbleTile = props => {
77
80
  onClick: showInfo,
78
81
  src: noticeWarnSvg,
79
82
  className: "t-agent-bubble-tile-error",
80
- "data-testid": "t-agent-bubble-tile-error"
83
+ "data-testid": "t-agent-bubble-tile-warning"
81
84
  });
82
85
  }
83
86
  return /*#__PURE__*/React.createElement(View, {
@@ -120,7 +123,7 @@ const BubbleTile = props => {
120
123
  })
121
124
  });
122
125
  ty.showToast({
123
- title: I18n.t('chat.feedback.success'),
126
+ title: t('t-agent.message.feedback.success'),
124
127
  icon: 'none'
125
128
  });
126
129
  }
@@ -3,17 +3,27 @@ import "core-js/modules/esnext.iterator.map.js";
3
3
  import { Button, View } from '@ray-js/components';
4
4
  import React from 'react';
5
5
  import './index.less';
6
+ import { useRenderOptions } from '../../hooks';
6
7
  export default function ButtonsTile(props) {
8
+ const {
9
+ i18nTranslate
10
+ } = useRenderOptions();
7
11
  if (props.tile.locked) {
8
12
  return null;
9
13
  }
10
14
  return /*#__PURE__*/React.createElement(View, {
11
15
  className: "t-agent-buttons-tile"
12
- }, props.tile.data.buttons.map(item => /*#__PURE__*/React.createElement(Button, {
13
- key: "".concat(item.text, "-").concat(item.type || ''),
14
- className: "t-agent-buttons-tile-button ".concat(item.type ? "t-agent-buttons-tile-button-".concat(item.type) : ''),
15
- onClick: () => {
16
- item.clickPayload && props.emitEvent(item.clickPayload);
16
+ }, props.tile.data.buttons.map(item => {
17
+ let text = item.text;
18
+ if (item.i18nKey) {
19
+ text = i18nTranslate(item.i18nKey);
17
20
  }
18
- }, item.text)));
21
+ return /*#__PURE__*/React.createElement(Button, {
22
+ key: "".concat(text, "-").concat(item.type || ''),
23
+ className: "t-agent-buttons-tile-button ".concat(item.type ? "t-agent-buttons-tile-button-".concat(item.type) : ''),
24
+ onClick: () => {
25
+ item.clickPayload && props.emitEvent(item.clickPayload);
26
+ }
27
+ }, text);
28
+ }));
19
29
  }
package/dist/types.d.ts CHANGED
@@ -23,4 +23,5 @@ export interface RenderOptions {
23
23
  card: ChatCardObject;
24
24
  }>>;
25
25
  getStaticResourceBizType: (src: string, scene?: string, data?: any) => string;
26
+ i18nTranslate: (key: string) => string;
26
27
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-ui-ray",
3
- "version": "0.0.8-beta-2",
3
+ "version": "0.0.8",
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": "0fe6e7c1daafbeffd1394a7ee85ab4ae86d8f93e"
44
+ "gitHead": "686e9d17bd1a96074d3ac16ac2a3d73e1aa17f8f"
45
45
  }