@ray-js/t-agent 0.2.5-beta-1 → 0.2.5-beta-2
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 +562 -305
- package/README.md +570 -269
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
# AI Intelligent Agent SDK
|
|
2
2
|
|
|
3
|
+
## Version Notes
|
|
4
|
+
|
|
5
|
+
**⚠️ Important Notice**: Starting from version 0.2.x, `@ray-js/t-agent-plugin-assistant` has been deprecated. Please use `@ray-js/t-agent-plugin-aistream` instead.
|
|
6
|
+
|
|
3
7
|
## Installation (ray mini-program)
|
|
4
8
|
|
|
5
9
|
```shell
|
|
6
|
-
yarn add @ray-js/t-agent @ray-js/t-agent-plugin-
|
|
10
|
+
yarn add @ray-js/t-agent @ray-js/t-agent-plugin-aistream @ray-js/t-agent-ui-ray
|
|
7
11
|
```
|
|
8
12
|
|
|
9
|
-
> Ensure that the versions of `@ray-js/t-agent`, `@ray-js/t-agent-plugin-
|
|
13
|
+
> Ensure that the versions of `@ray-js/t-agent`, `@ray-js/t-agent-plugin-aistream`, and `@ray-js/t-agent-ui-ray` are consistent.
|
|
10
14
|
|
|
11
15
|
## Mini-Program Kit Requirements
|
|
12
16
|
|
|
@@ -17,7 +21,8 @@ yarn add @ray-js/t-agent @ray-js/t-agent-plugin-assistant @ray-js/t-agent-ui-ray
|
|
|
17
21
|
"BizKit": "4.10.0",
|
|
18
22
|
"DeviceKit": "4.6.1",
|
|
19
23
|
"HomeKit": "3.4.0",
|
|
20
|
-
"MiniKit": "3.12.1"
|
|
24
|
+
"MiniKit": "3.12.1",
|
|
25
|
+
"AIStreamKit": "1.0.0"
|
|
21
26
|
},
|
|
22
27
|
"baseversion": "2.21.10"
|
|
23
28
|
}
|
|
@@ -54,48 +59,54 @@ Implementing a chat page using ray UI
|
|
|
54
59
|
import React from 'react';
|
|
55
60
|
import { View } from '@ray-js/components';
|
|
56
61
|
import { createChatAgent, withDebug, withUI } from '@ray-js/t-agent';
|
|
57
|
-
import { ChatContainer, MessageInput, MessageList } from '@ray-js/t-agent-ui-ray';
|
|
58
|
-
import {
|
|
62
|
+
import { ChatContainer, MessageInput, MessageList, MessageActionBar } from '@ray-js/t-agent-ui-ray';
|
|
63
|
+
import { withAIStream, withBuildIn } from '@ray-js/t-agent-plugin-aistream';
|
|
59
64
|
|
|
60
65
|
const createAgent = () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
66
|
+
try {
|
|
67
|
+
// The order of applying plugins matters
|
|
68
|
+
const agent = createChatAgent(
|
|
69
|
+
withUI(), // The withUI plugin provides default UI behavior, essential
|
|
70
|
+
withAIStream({
|
|
71
|
+
// Connects to the mini-program AI agent platform, essential in mini-program
|
|
72
|
+
enableTts: false, // Whether to enable Text-to-Speech
|
|
73
|
+
earlyStart: true, // Whether to establish connection during onAgentStart phase
|
|
74
|
+
agentId: '', // Enter your agent ID
|
|
75
|
+
}),
|
|
76
|
+
withDebug(), // Enables logging to the console
|
|
77
|
+
withBuildIn() // Provides built-in features
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// Lifecycle hooks for custom behavior registration
|
|
81
|
+
const { onChatStart, createMessage, onChatResume, onError, onInputBlocksPush, session } = agent;
|
|
82
|
+
|
|
83
|
+
// Initialize chat with a message
|
|
84
|
+
onChatStart(async result => {
|
|
85
|
+
const hello = createMessage({
|
|
86
|
+
role: 'assistant',
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
hello.bubble.setText('Hello, world!');
|
|
90
|
+
result.messages.push(hello);
|
|
91
|
+
// Persist message for display upon next entry
|
|
92
|
+
await hello.persist();
|
|
80
93
|
});
|
|
81
94
|
|
|
82
|
-
|
|
83
|
-
result
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
95
|
+
// Message upon chat resume
|
|
96
|
+
onChatResume(async result => {
|
|
97
|
+
const welcomeBack = createMessage({
|
|
98
|
+
role: 'assistant',
|
|
99
|
+
});
|
|
87
100
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
role: 'assistant',
|
|
101
|
+
welcomeBack.bubble.setText('Welcome back');
|
|
102
|
+
result.messages.push(welcomeBack);
|
|
103
|
+
await welcomeBack.persist();
|
|
92
104
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
return agent;
|
|
105
|
+
return agent;
|
|
106
|
+
} catch (error) {
|
|
107
|
+
console.error('Agent creation failed:', error);
|
|
108
|
+
throw error;
|
|
109
|
+
}
|
|
99
110
|
};
|
|
100
111
|
|
|
101
112
|
export default function ChatPage() {
|
|
@@ -104,6 +115,7 @@ export default function ChatPage() {
|
|
|
104
115
|
<ChatContainer createAgent={createAgent}>
|
|
105
116
|
<MessageList />
|
|
106
117
|
<MessageInput />
|
|
118
|
+
<MessageActionBar />
|
|
107
119
|
</ChatContainer>
|
|
108
120
|
</View>
|
|
109
121
|
);
|
|
@@ -168,6 +180,14 @@ const createAgent = () => {
|
|
|
168
180
|
};
|
|
169
181
|
```
|
|
170
182
|
|
|
183
|
+
#### Hook Execution Order
|
|
184
|
+
|
|
185
|
+
Hooks are executed in the following order:
|
|
186
|
+
|
|
187
|
+
```
|
|
188
|
+
onAgentStart → onChatStart/onChatResume → onMessageListInit → onInputBlocksPush
|
|
189
|
+
```
|
|
190
|
+
|
|
171
191
|
ChatAgent's Central Hooks and Parameters:
|
|
172
192
|
|
|
173
193
|
- `agent.onAgentStart` Agent initialization
|
|
@@ -176,7 +196,7 @@ ChatAgent's Central Hooks and Parameters:
|
|
|
176
196
|
- `agent.onChatResume` Triggered on dialogue continuation
|
|
177
197
|
- `result.messages` Restored message lists
|
|
178
198
|
- `agent.onMessageListInit` On message list initialization
|
|
179
|
-
- `result.messages` Rendering message list
|
|
199
|
+
- `result.messages` Rendering message list, same list as the previous two hooks
|
|
180
200
|
- `agent.onInputBlocksPush` On message block input
|
|
181
201
|
- `blocks` Input message blocks
|
|
182
202
|
- `signal` Interrupt signal
|
|
@@ -579,6 +599,58 @@ The main events of the UI plugin are as follows, and you can freely register add
|
|
|
579
599
|
- `payload.value: any`: Session value
|
|
580
600
|
- `payload.oldValue: any`: Old session value
|
|
581
601
|
|
|
602
|
+
Enhanced Features in withUI Plugin (0.2.x):
|
|
603
|
+
|
|
604
|
+
withUI plugin in version 0.2.x introduces Hook mechanisms for customizing message feedback and history clearing behavior:
|
|
605
|
+
|
|
606
|
+
**Message Feedback Hook**:
|
|
607
|
+
|
|
608
|
+
- `agent.plugins.ui.hook('onMessageFeedback', async context => {})` Register message feedback Hook
|
|
609
|
+
- `context.payload.messageId: string` Message ID
|
|
610
|
+
- `context.payload.rate: 'like' | 'unlike'` Feedback type
|
|
611
|
+
- `context.payload.content?: string` Feedback content (optional)
|
|
612
|
+
- `context.result: { success: boolean }` Return result, need to set success status
|
|
613
|
+
|
|
614
|
+
**Clear History Hook**:
|
|
615
|
+
|
|
616
|
+
- `agent.plugins.ui.hook('onClearHistory', async context => {})` Register clear history Hook
|
|
617
|
+
- `context.payload: any` Clear history parameters
|
|
618
|
+
- `context.result: { success: boolean }` Return result, need to set success status
|
|
619
|
+
|
|
620
|
+
**Calling Hooks**:
|
|
621
|
+
|
|
622
|
+
- `agent.plugins.ui.callHook('onMessageFeedback', payload)` Call message feedback Hook
|
|
623
|
+
- `agent.plugins.ui.callHook('onClearHistory', payload)` Call clear history Hook
|
|
624
|
+
|
|
625
|
+
Usage example:
|
|
626
|
+
|
|
627
|
+
```tsx
|
|
628
|
+
const agent = createChatAgent(withUI(), withAIStream({ agentId: 'your-agent-id' }));
|
|
629
|
+
|
|
630
|
+
// Register message feedback handler
|
|
631
|
+
agent.plugins.ui.hook('onMessageFeedback', async context => {
|
|
632
|
+
const { messageId, rate, content } = context.payload;
|
|
633
|
+
try {
|
|
634
|
+
// Call your API to submit feedback
|
|
635
|
+
await submitFeedback({ messageId, rate, content });
|
|
636
|
+
context.result = { success: true };
|
|
637
|
+
} catch (error) {
|
|
638
|
+
context.result = { success: false };
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
// Register clear history handler
|
|
643
|
+
agent.plugins.ui.hook('onClearHistory', async context => {
|
|
644
|
+
try {
|
|
645
|
+
// Call your API to clear history
|
|
646
|
+
await clearChatHistory();
|
|
647
|
+
context.result = { success: true };
|
|
648
|
+
} catch (error) {
|
|
649
|
+
context.result = { success: false };
|
|
650
|
+
}
|
|
651
|
+
});
|
|
652
|
+
```
|
|
653
|
+
|
|
582
654
|
> Note: `ChatMessageObject` here is a message object, not a `ChatMessage` type.
|
|
583
655
|
> It contains various attributes and methods to ensure changes are made in the ChatAgent, avoiding conflicts with the UI layer.
|
|
584
656
|
|
|
@@ -649,28 +721,29 @@ const obj = safeParseJSON<{ a: number }>('{"a": 1}');
|
|
|
649
721
|
console.log(obj.a); // 1
|
|
650
722
|
```
|
|
651
723
|
|
|
652
|
-
# t-agent-plugin-
|
|
724
|
+
# t-agent-plugin-aistream
|
|
653
725
|
|
|
654
|
-
t-agent-plugin-
|
|
726
|
+
t-agent-plugin-aistream is a plugin designed for integration with applet AI agent platforms, offering capabilities to connect to these platforms.
|
|
655
727
|
|
|
656
728
|
## Installation
|
|
657
729
|
|
|
658
730
|
```shell
|
|
659
|
-
yarn add @ray-js/t-agent-plugin-
|
|
731
|
+
yarn add @ray-js/t-agent-plugin-aistream
|
|
660
732
|
```
|
|
661
733
|
|
|
662
734
|
## Usage
|
|
663
735
|
|
|
664
736
|
```tsx
|
|
665
737
|
import { createChatAgent, withUI } from '@ray-js/t-agent';
|
|
666
|
-
import {
|
|
738
|
+
import { withAIStream, withBuildIn } from '@ray-js/t-agent-plugin-aistream';
|
|
667
739
|
|
|
668
740
|
const createAgent = () => {
|
|
669
741
|
const agent = createChatAgent(
|
|
670
742
|
withUI(), // Typically, the withUI plugin is necessary
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
743
|
+
withAIStream({
|
|
744
|
+
enableTts: false, // Enable Text-to-Speech
|
|
745
|
+
earlyStart: true, // Establish connection during onAgentStart phase
|
|
746
|
+
agentId: 'your-agent-id', // Provide your agent ID
|
|
674
747
|
}),
|
|
675
748
|
withBuildIn()
|
|
676
749
|
);
|
|
@@ -681,110 +754,96 @@ const createAgent = () => {
|
|
|
681
754
|
|
|
682
755
|
## Included Plugins
|
|
683
756
|
|
|
684
|
-
###
|
|
757
|
+
### withAIStream Plugin
|
|
685
758
|
|
|
686
759
|
This plugin facilitates communication with applet AI agent platforms.
|
|
687
760
|
|
|
688
761
|
Parameters:
|
|
689
762
|
|
|
690
|
-
- `
|
|
691
|
-
- `
|
|
692
|
-
- `
|
|
693
|
-
- `
|
|
763
|
+
- `agentId` Agent ID (required)
|
|
764
|
+
- `clientType` Client type, defaults to APP (2)
|
|
765
|
+
- `deviceId` Device ID, required when clientType is DEVICE (1)
|
|
766
|
+
- `enableTts` Whether to enable Text-to-Speech, defaults to false
|
|
767
|
+
- `wireInput` Whether to pass input blocks to the agent, defaults to true. Set to false if you plan to handle input blocks manually with the onInputBlocksPush Hook
|
|
768
|
+
- `historySize` History message size, defaults to 1000
|
|
769
|
+
- `indexId` Index ID, defaults to 'default'
|
|
770
|
+
- `homeId` Home ID, defaults to current home if not provided
|
|
771
|
+
- `earlyStart` Whether to establish connection during onAgentStart phase
|
|
772
|
+
- `tokenOptions` Parameters for getting agent token
|
|
773
|
+
- `api` API interface name
|
|
774
|
+
- `version` Interface version
|
|
775
|
+
- `extParams` Additional parameters
|
|
776
|
+
- `createChatHistoryStore` Custom message storage function
|
|
694
777
|
|
|
695
778
|
Methods:
|
|
696
779
|
|
|
697
|
-
- `agent.plugins.
|
|
698
|
-
- `agent.plugins.
|
|
780
|
+
- `agent.plugins.aiStream.send`: Send a message to the agent
|
|
781
|
+
- `agent.plugins.aiStream.chat`: Send a message to the agent while generating a ChatMessage object for the question and the AI's answer, updating in a streaming manner
|
|
699
782
|
|
|
700
783
|
Hooks:
|
|
701
784
|
|
|
702
|
-
- `
|
|
703
|
-
- `
|
|
704
|
-
- `
|
|
705
|
-
|
|
706
|
-
- `
|
|
707
|
-
- `
|
|
708
|
-
- `
|
|
709
|
-
|
|
710
|
-
- `
|
|
711
|
-
- `
|
|
712
|
-
- `
|
|
713
|
-
- `
|
|
714
|
-
- `
|
|
785
|
+
- `onMessageParse` Triggered when reading history messages and parsing them, allowing for message modification in this Hook
|
|
786
|
+
- `msgItem` Stored message object
|
|
787
|
+
- `result.messages` Parsed message list
|
|
788
|
+
- `onSkillCompose` Triggered when receiving skill data, used for handling skill rendering
|
|
789
|
+
- `skill` Skill data array (ReceivedTextSkillPacketBody[])
|
|
790
|
+
- `respMsg` Response message
|
|
791
|
+
- `result.messages` Message list
|
|
792
|
+
- `onSkillsEnd` Triggered when all skills processing is complete
|
|
793
|
+
- `skills` Skill data list (ReceivedTextSkillPacketBody[])
|
|
794
|
+
- `respMsg` Response message
|
|
795
|
+
- `result.messages` Message list
|
|
796
|
+
- `onTTTAction` Triggered when tile uses `sendAction`
|
|
797
|
+
- `tile` Triggering tile
|
|
798
|
+
- `result.action` TTTAction, can modify the action to be executed
|
|
799
|
+
- `onCardsReceived` Triggered when receiving card data
|
|
800
|
+
- `skills` Skill data list (ReceivedTextSkillPacketBody[])
|
|
715
801
|
- `result.cards` Card list
|
|
716
802
|
|
|
717
803
|
### withBuildIn Plugin
|
|
718
804
|
|
|
719
|
-
Offers built-in features
|
|
805
|
+
Offers built-in features including smart home device control and knowledge base search.
|
|
720
806
|
|
|
721
|
-
|
|
807
|
+
**Supported Skills**:
|
|
722
808
|
|
|
723
|
-
|
|
809
|
+
- **Smart Home**: Device control and scene management
|
|
810
|
+
- **Knowledge Base Search**: Related document display
|
|
724
811
|
|
|
725
812
|
## Mock Mechanism
|
|
726
813
|
|
|
727
814
|
To facilitate development, we offer a mock mechanism allowing mock data to be used without connecting to applet AI platforms.
|
|
728
815
|
|
|
729
|
-
### Mock
|
|
730
|
-
|
|
731
|
-
```tsx
|
|
732
|
-
import { mock } from '@ray-js/t-agent-plugin-assistant';
|
|
733
|
-
|
|
734
|
-
// Mock the interface for retrieving historical data
|
|
735
|
-
mock.hooks.hook('getAIAssistantGroupHistory', context => {
|
|
736
|
-
context.result = yourMockData;
|
|
737
|
-
});
|
|
738
|
-
```
|
|
739
|
-
|
|
740
|
-
### Mock AI Assistant Response
|
|
816
|
+
### Mock AI Stream Response
|
|
741
817
|
|
|
742
818
|
```tsx
|
|
743
|
-
import { mock } from '@ray-js/t-agent-plugin-
|
|
819
|
+
import { mock } from '@ray-js/t-agent-plugin-aistream';
|
|
744
820
|
|
|
745
|
-
mock.hooks.hook('
|
|
746
|
-
if (context.options.block?.includes('hello')) {
|
|
747
|
-
context.responseText = '
|
|
821
|
+
mock.hooks.hook('sendToAIStream', context => {
|
|
822
|
+
if (context.options.blocks?.some(block => block.text?.includes('hello'))) {
|
|
823
|
+
context.responseText = 'hello, who are you?';
|
|
748
824
|
}
|
|
749
825
|
|
|
750
|
-
if (context.options.block?.includes('
|
|
751
|
-
context.responseText = '
|
|
752
|
-
context.
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
if (context.options.block?.includes('workflow')) {
|
|
769
|
-
context.responseText = 'This is a workflow';
|
|
770
|
-
context.responseExtensions = {
|
|
771
|
-
workflowAskOptions: {
|
|
772
|
-
options: [
|
|
773
|
-
{
|
|
774
|
-
name: 'Option 1',
|
|
775
|
-
value: 'Option 1',
|
|
776
|
-
},
|
|
777
|
-
{
|
|
778
|
-
name: 'Option 2',
|
|
779
|
-
value: 'Option 2',
|
|
826
|
+
if (context.options.blocks?.some(block => block.text?.includes('smart home'))) {
|
|
827
|
+
context.responseText = 'Controlling smart devices for you...';
|
|
828
|
+
context.responseSkills = [
|
|
829
|
+
{
|
|
830
|
+
code: 'smart_home',
|
|
831
|
+
general: {
|
|
832
|
+
action: 'control_device',
|
|
833
|
+
data: {
|
|
834
|
+
devices: [
|
|
835
|
+
{
|
|
836
|
+
deviceId: 'vdevo174796589841019',
|
|
837
|
+
icon: '',
|
|
838
|
+
dps: { range: '0', toggle: 'ON' },
|
|
839
|
+
name: 'Towel Rack',
|
|
840
|
+
},
|
|
841
|
+
],
|
|
780
842
|
},
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
value: 'Option 3',
|
|
784
|
-
},
|
|
785
|
-
],
|
|
843
|
+
},
|
|
844
|
+
custom: {},
|
|
786
845
|
},
|
|
787
|
-
|
|
846
|
+
];
|
|
788
847
|
}
|
|
789
848
|
});
|
|
790
849
|
```
|
|
@@ -792,14 +851,14 @@ mock.hooks.hook('sendToAssistant', context => {
|
|
|
792
851
|
### mock ASR Speech Recognition
|
|
793
852
|
|
|
794
853
|
```tsx
|
|
795
|
-
import { mock } from '@ray-js/t-agent-plugin-
|
|
854
|
+
import { mock } from '@ray-js/t-agent-plugin-aistream';
|
|
796
855
|
|
|
797
856
|
mock.hooks.hook('asrDetection', context => {
|
|
798
857
|
context.responseText = 'Hello world!, I am a virtual assistant.';
|
|
799
858
|
});
|
|
800
859
|
```
|
|
801
860
|
|
|
802
|
-
## Additional Utils Tools (
|
|
861
|
+
## Additional Utils Tools (Currently under development)
|
|
803
862
|
|
|
804
863
|
### AbortController
|
|
805
864
|
|
|
@@ -815,45 +874,43 @@ Run a TTTAction to handle user actions, currently supporting the following actio
|
|
|
815
874
|
- `sendMessage` Send a message
|
|
816
875
|
- `buildIn` Built-in action
|
|
817
876
|
|
|
818
|
-
###
|
|
877
|
+
### AsrAgent
|
|
819
878
|
|
|
820
|
-
ASR Speech Recognition
|
|
879
|
+
ASR Speech Recognition agent, used for recognizing user's voice input
|
|
821
880
|
|
|
822
881
|
Usage:
|
|
823
882
|
|
|
824
883
|
```tsx
|
|
825
|
-
import {
|
|
884
|
+
import { createAsrAgent } from '@ray-js/t-agent-plugin-aistream';
|
|
826
885
|
|
|
827
886
|
async function startAsr() {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
//
|
|
847
|
-
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
if (res.state === AsrDetectResultState.ERROR) {
|
|
851
|
-
onError(new AsrError(res.errorCode));
|
|
852
|
-
}
|
|
887
|
+
const asrAgent = createAsrAgent({
|
|
888
|
+
agentId: 'your-agent-id',
|
|
889
|
+
onMessage: message => {
|
|
890
|
+
if (message.type === 'text') {
|
|
891
|
+
console.log('Recognition result:', message.text);
|
|
892
|
+
} else if (message.type === 'file') {
|
|
893
|
+
console.log('Audio file:', message.file);
|
|
894
|
+
}
|
|
895
|
+
},
|
|
896
|
+
onFinish: () => {
|
|
897
|
+
console.log('Recognition completed');
|
|
898
|
+
},
|
|
899
|
+
onError: error => {
|
|
900
|
+
console.error('Recognition error:', error);
|
|
901
|
+
},
|
|
902
|
+
recordingOptions: {
|
|
903
|
+
saveFile: false,
|
|
904
|
+
sampleRate: 16000,
|
|
905
|
+
maxDuration: 60000, // Maximum 60 seconds
|
|
906
|
+
},
|
|
853
907
|
});
|
|
854
908
|
|
|
855
909
|
// Start recognition
|
|
856
|
-
await
|
|
910
|
+
await asrAgent.start();
|
|
911
|
+
|
|
912
|
+
// Stop recognition
|
|
913
|
+
await asrAgent.stop();
|
|
857
914
|
}
|
|
858
915
|
```
|
|
859
916
|
|
|
@@ -864,7 +921,7 @@ A promisify method for the built-in TTT API, used to convert the TTT API into a
|
|
|
864
921
|
Usage:
|
|
865
922
|
|
|
866
923
|
```tsx
|
|
867
|
-
import { promisify } from '@ray-js/t-agent-plugin-
|
|
924
|
+
import { promisify } from '@ray-js/t-agent-plugin-aistream';
|
|
868
925
|
|
|
869
926
|
interface RouterParams {
|
|
870
927
|
/** Route link */
|
|
@@ -891,76 +948,80 @@ mock.hooks.hook('router', context => {
|
|
|
891
948
|
await router({ url: '/pages/index/index' });
|
|
892
949
|
```
|
|
893
950
|
|
|
894
|
-
###
|
|
951
|
+
### sendBlocksToAIStream
|
|
895
952
|
|
|
896
|
-
|
|
953
|
+
**Note: This function is for internal use only. General developers should not call it directly**
|
|
897
954
|
|
|
898
|
-
|
|
899
|
-
import { sendBlockToAssistant, getAIAssistantRequestId } from '@ray-js/t-agent-ui-ray';
|
|
955
|
+
Send message blocks to AIStream. This is a low-level function. You should typically use `agent.plugins.aiStream.send` or `agent.plugins.aiStream.chat` methods instead.
|
|
900
956
|
|
|
901
|
-
|
|
902
|
-
const requestId = await getAIAssistantRequestId();
|
|
903
|
-
const result = sendBlockToAssistant({
|
|
904
|
-
channel: 'your-channel-id',
|
|
905
|
-
sessionId: 'your-session-id',
|
|
906
|
-
requestId,
|
|
907
|
-
blocks: [{ type: 'text', text: 'hello' }],
|
|
908
|
-
});
|
|
957
|
+
#### Use Cases
|
|
909
958
|
|
|
910
|
-
|
|
911
|
-
|
|
959
|
+
- ✅ **Suitable**: When you need direct control over streaming response handling
|
|
960
|
+
- ✅ **Suitable**: Implementing custom message sending logic
|
|
961
|
+
- ❌ **Not suitable**: General conversation scenarios, should use `agent.plugins.aiStream.chat`
|
|
962
|
+
- ❌ **Not suitable**: Simple message sending, should use `agent.plugins.aiStream.send`
|
|
912
963
|
|
|
913
|
-
|
|
914
|
-
const parts = result.parts();
|
|
964
|
+
#### Function Signature
|
|
915
965
|
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
966
|
+
```tsx
|
|
967
|
+
import { sendBlocksToAIStream } from '@ray-js/t-agent-plugin-aistream';
|
|
968
|
+
|
|
969
|
+
export interface SendBlocksToAIStreamParams {
|
|
970
|
+
blocks: InputBlock[];
|
|
971
|
+
session: AIStreamSession;
|
|
972
|
+
attribute?: AIStreamChatAttribute;
|
|
973
|
+
signal?: AbortSignal;
|
|
974
|
+
enableTts?: boolean;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
export function sendBlocksToAIStream(params: SendBlocksToAIStreamParams): {
|
|
978
|
+
response: StreamResponse;
|
|
979
|
+
metaPromise: Promise<Record<string, any>>;
|
|
919
980
|
};
|
|
920
981
|
```
|
|
921
982
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
Send skills to the Assistant
|
|
983
|
+
#### Usage Example
|
|
925
984
|
|
|
926
985
|
```tsx
|
|
927
|
-
import { sendSkillToAssistant } from '@ray-js/t-agent-ui-ray';
|
|
928
|
-
|
|
929
986
|
const send = async () => {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
options: {
|
|
934
|
-
domain: 'string',
|
|
935
|
-
intent: 'string',
|
|
936
|
-
},
|
|
937
|
-
});
|
|
987
|
+
try {
|
|
988
|
+
// First need to get AIStreamSession object
|
|
989
|
+
const streamSession = agent.session.get('AIStream.streamSession');
|
|
938
990
|
|
|
939
|
-
|
|
940
|
-
|
|
991
|
+
const result = sendBlocksToAIStream({
|
|
992
|
+
blocks: [{ type: 'text', text: 'hello' }],
|
|
993
|
+
session: streamSession,
|
|
994
|
+
signal: new AbortController().signal,
|
|
995
|
+
});
|
|
941
996
|
|
|
942
|
-
|
|
943
|
-
|
|
997
|
+
// Get metadata after sending
|
|
998
|
+
const meta = await result.metaPromise;
|
|
944
999
|
|
|
945
|
-
|
|
946
|
-
|
|
1000
|
+
// Get streamed message
|
|
1001
|
+
const parts = result.response.parts();
|
|
1002
|
+
for await (const part of parts) {
|
|
1003
|
+
console.log('part', part);
|
|
1004
|
+
}
|
|
1005
|
+
} catch (error) {
|
|
1006
|
+
console.error('Send message failed:', error);
|
|
1007
|
+
// Error handling logic
|
|
947
1008
|
}
|
|
948
1009
|
};
|
|
949
1010
|
```
|
|
950
1011
|
|
|
951
|
-
###
|
|
1012
|
+
### authorizeAIStreamPolicy
|
|
952
1013
|
|
|
953
1014
|
Popup to remind users to accept the AI privacy policy, a security requirement that users must agree to access AI features in the app
|
|
954
1015
|
|
|
955
1016
|
> Note that this function requires `BaseKit >= 3.20.4`. If your BaseKit version is lower than this version, it will be directly passed.
|
|
956
1017
|
|
|
957
1018
|
```tsx
|
|
958
|
-
import {
|
|
1019
|
+
import { authorizeAIStreamPolicy } from '@ray-js/t-agent-plugin-aistream';
|
|
959
1020
|
|
|
960
1021
|
// Call this function after the page load completes to pop up the agreement prompt
|
|
961
1022
|
const authorize = async () => {
|
|
962
1023
|
try {
|
|
963
|
-
const result = await
|
|
1024
|
+
const result = await authorizeAIStreamPolicy();
|
|
964
1025
|
|
|
965
1026
|
if (result) {
|
|
966
1027
|
// Already agreed or clicked the agree button
|
|
@@ -1032,7 +1093,7 @@ import { ChatContainer, MessageList, MessageInput } from '@ray-js/t-agent-ui-ray
|
|
|
1032
1093
|
import { createAgent } from './createAgent';
|
|
1033
1094
|
|
|
1034
1095
|
export default function ChatPage() {
|
|
1035
|
-
// createAgent must return a ChatAgent instance applied with withUI,
|
|
1096
|
+
// createAgent must return a ChatAgent instance applied with withUI, withAIStream plugins
|
|
1036
1097
|
return (
|
|
1037
1098
|
<View style={{ height: '100vh' }}>
|
|
1038
1099
|
<ChatContainer createAgent={createAgent}>
|
|
@@ -1060,18 +1121,34 @@ props:
|
|
|
1060
1121
|
- `customBlockTypes` Custom block types, only block types registered here will be rendered by `renderCustomBlockAs`
|
|
1061
1122
|
- `renderCustomBlockAs` This function decides how to render custom blocks in markdown bubble messages, by default supports `echarts`
|
|
1062
1123
|
- `renderCardAs` This function decides how to render cards in messages, generally no need to customize this item
|
|
1124
|
+
- `renderLongPressAs` **(0.2.x New)** This function decides how to render long press menu, allows customizing long press menu style and behavior
|
|
1125
|
+
- `formatErrorMessageAs` **(0.2.x New)** This function decides how to format error messages, can return user-friendly error messages based on error codes
|
|
1063
1126
|
- `customCardMap` Custom card mapping, no need to modify the `renderCardAs` function, just register the card type and corresponding component here
|
|
1064
1127
|
- `getStaticResourceBizType` Get static resource `bizType` used to fetch static resources
|
|
1065
1128
|
|
|
1066
1129
|
### MessageList
|
|
1067
1130
|
|
|
1068
|
-
Message list, used to display messages
|
|
1131
|
+
Message list, used to display messages. In version 0.2.x, it integrates LazyScrollView component for better performance optimization.
|
|
1069
1132
|
|
|
1070
|
-
|
|
1133
|
+
**Props**:
|
|
1071
1134
|
|
|
1072
1135
|
- `className` Class name of the list
|
|
1073
1136
|
- `roleSide` Alignment of message roles, default `{ user: 'end', assistant: 'start' }`
|
|
1074
1137
|
|
|
1138
|
+
**LazyScrollView Integration (0.2.x New)**:
|
|
1139
|
+
|
|
1140
|
+
MessageList internally uses LazyScrollView component to optimize performance when rendering large numbers of messages:
|
|
1141
|
+
|
|
1142
|
+
- **Lazy Rendering**: Only renders messages in the visible area, greatly improving performance
|
|
1143
|
+
- **Height Adaptation**: Automatically calculates message heights, supports dynamic content
|
|
1144
|
+
- **notifyHeightChanged()**: Automatically notifies height updates when message content changes
|
|
1145
|
+
|
|
1146
|
+
The component automatically handles the following scenarios:
|
|
1147
|
+
|
|
1148
|
+
- Ensures the bottom 10 messages are always rendered to avoid blank screens when scrolling to bottom
|
|
1149
|
+
- Automatically updates scroll position when message heights change
|
|
1150
|
+
- Supports animated scrolling to bottom effects
|
|
1151
|
+
|
|
1075
1152
|
### MessageInput
|
|
1076
1153
|
|
|
1077
1154
|
Message input box, used to input messages, upload attachments, ASR speech recognition
|
|
@@ -1082,10 +1159,79 @@ props:
|
|
|
1082
1159
|
- `placeholder` Placeholder of the input box
|
|
1083
1160
|
- `renderTop` Used to render content above the input box
|
|
1084
1161
|
|
|
1162
|
+
### MessageActionBar (0.2.x New)
|
|
1163
|
+
|
|
1164
|
+
Message action bar component, used to display action buttons when in multi-select mode, supports deleting selected messages and clearing history.
|
|
1165
|
+
|
|
1166
|
+
**Props**:
|
|
1167
|
+
|
|
1168
|
+
No props need to be passed, the component automatically shows and hides based on multi-select state
|
|
1169
|
+
|
|
1170
|
+
**Features**:
|
|
1171
|
+
|
|
1172
|
+
- **Back Button**: Exit multi-select mode
|
|
1173
|
+
- **Clear History Button**: Clear all history messages, will call `onClearHistory` Hook
|
|
1174
|
+
- **Delete Selected Button**: Delete currently selected messages, button is disabled when no messages are selected
|
|
1175
|
+
|
|
1176
|
+
**How it Works**:
|
|
1177
|
+
|
|
1178
|
+
MessageActionBar component monitors the `UIRay.multiSelect.show` state in session data to determine whether to display. When user long-presses a message and selects "Multi-select", this component will automatically show.
|
|
1179
|
+
|
|
1180
|
+
**Usage Example**:
|
|
1181
|
+
|
|
1182
|
+
```tsx
|
|
1183
|
+
export default function ChatPage() {
|
|
1184
|
+
return (
|
|
1185
|
+
<View style={{ height: '100vh' }}>
|
|
1186
|
+
<ChatContainer createAgent={createAgent}>
|
|
1187
|
+
<MessageList />
|
|
1188
|
+
<MessageInput />
|
|
1189
|
+
<MessageActionBar />
|
|
1190
|
+
</ChatContainer>
|
|
1191
|
+
</View>
|
|
1192
|
+
);
|
|
1193
|
+
}
|
|
1194
|
+
```
|
|
1195
|
+
|
|
1085
1196
|
### PrivateImage
|
|
1086
1197
|
|
|
1087
1198
|
Private image component, used to display private images, props are the same as Image, adding bizType parameter
|
|
1088
1199
|
|
|
1200
|
+
### LazyScrollView
|
|
1201
|
+
|
|
1202
|
+
Lazy-loading scroll view component for optimizing long list performance, automatically manages rendering in the visible area
|
|
1203
|
+
|
|
1204
|
+
Main Features:
|
|
1205
|
+
|
|
1206
|
+
- Virtual Scrolling: Only renders elements in the visible area
|
|
1207
|
+
- Height Caching: Automatically caches element heights to improve scrolling performance
|
|
1208
|
+
- Dynamic Loading: Dynamically shows/hides elements based on scroll position
|
|
1209
|
+
- `notifyHeightChanged()` Function: When element heights change, this method can be called to notify the scroll view to update
|
|
1210
|
+
|
|
1211
|
+
Usage Notes:
|
|
1212
|
+
|
|
1213
|
+
LazyScrollView is mainly used internally by MessageList, developers generally don't need to use it directly. If you need to dynamically change heights in messages, you can use the `notifyHeightChanged` parameter to notify height changes:
|
|
1214
|
+
|
|
1215
|
+
```tsx
|
|
1216
|
+
// Use in tile component
|
|
1217
|
+
const MyTile = ({ notifyHeightChanged }) => {
|
|
1218
|
+
const [expanded, setExpanded] = useState(false);
|
|
1219
|
+
|
|
1220
|
+
const handleToggle = () => {
|
|
1221
|
+
setExpanded(!expanded);
|
|
1222
|
+
// Notify height change
|
|
1223
|
+
notifyHeightChanged();
|
|
1224
|
+
};
|
|
1225
|
+
|
|
1226
|
+
return (
|
|
1227
|
+
<View>
|
|
1228
|
+
<Button onClick={handleToggle}>Expand/Collapse</Button>
|
|
1229
|
+
{expanded && <View>Detailed content...</View>}
|
|
1230
|
+
</View>
|
|
1231
|
+
);
|
|
1232
|
+
};
|
|
1233
|
+
```
|
|
1234
|
+
|
|
1089
1235
|
### Built-in tile components
|
|
1090
1236
|
|
|
1091
1237
|
- bubble Bubble
|
|
@@ -1183,6 +1329,41 @@ const MyTilePart = () => {
|
|
|
1183
1329
|
};
|
|
1184
1330
|
```
|
|
1185
1331
|
|
|
1332
|
+
### useTranslate
|
|
1333
|
+
|
|
1334
|
+
Get internationalization translation function for translating interface text, provides complete multilingual support.
|
|
1335
|
+
|
|
1336
|
+
```tsx
|
|
1337
|
+
import { useTranslate } from '@ray-js/t-agent-ui-ray';
|
|
1338
|
+
|
|
1339
|
+
const MyComponent = () => {
|
|
1340
|
+
const t = useTranslate();
|
|
1341
|
+
|
|
1342
|
+
return (
|
|
1343
|
+
<div>
|
|
1344
|
+
{t('t-agent.message.action.copy')} {/* Output: "Copy message" */}
|
|
1345
|
+
{t('t-agent.message.delete.title')} {/* Output: "Delete message" */}
|
|
1346
|
+
{t('t-agent.message.clear-history.title')} {/* Output: "Clear history" */}
|
|
1347
|
+
</div>
|
|
1348
|
+
);
|
|
1349
|
+
};
|
|
1350
|
+
```
|
|
1351
|
+
|
|
1352
|
+
**Supported Languages**:
|
|
1353
|
+
|
|
1354
|
+
Built-in multilingual support includes:
|
|
1355
|
+
|
|
1356
|
+
- **Simplified Chinese** (`zh-Hans`): Simplified Chinese
|
|
1357
|
+
- **Traditional Chinese** (`zh-Hant`): Traditional Chinese
|
|
1358
|
+
- **English** (`en`): English
|
|
1359
|
+
- **Japanese** (`ja`): Japanese
|
|
1360
|
+
- **German** (`de`): German
|
|
1361
|
+
- **French** (`fr`): French
|
|
1362
|
+
- **Spanish** (`es`): Spanish
|
|
1363
|
+
- **Italian** (`it`): Italian
|
|
1364
|
+
|
|
1365
|
+
The system automatically selects the corresponding translation based on the user's system language, falling back to English if the current language is not supported.
|
|
1366
|
+
|
|
1186
1367
|
## renderOptions Custom Rendering
|
|
1187
1368
|
|
|
1188
1369
|
### Replace or Add Tile
|
|
@@ -1211,6 +1392,73 @@ const renderOptions = {
|
|
|
1211
1392
|
};
|
|
1212
1393
|
```
|
|
1213
1394
|
|
|
1395
|
+
### Customize Long Press Menu (0.2.x New)
|
|
1396
|
+
|
|
1397
|
+
If you need to customize the style or behavior of the long press menu, you can override the `renderLongPressAs` function, for example:
|
|
1398
|
+
|
|
1399
|
+
```tsx
|
|
1400
|
+
import { defaultRenderOptions, LongPressResult } from '@ray-js/t-agent-ui-ray';
|
|
1401
|
+
import { View, Button } from '@ray-js/ray';
|
|
1402
|
+
|
|
1403
|
+
const renderOptions = {
|
|
1404
|
+
...defaultRenderOptions,
|
|
1405
|
+
renderLongPressAs: (res: LongPressResult) => {
|
|
1406
|
+
if (!res.menuProps.showActionMenu) {
|
|
1407
|
+
return null;
|
|
1408
|
+
}
|
|
1409
|
+
|
|
1410
|
+
return (
|
|
1411
|
+
<View className="my-custom-menu">
|
|
1412
|
+
{res.menuProps.menuItems.map(item => (
|
|
1413
|
+
<Button key={item.key} onClick={() => res.menuProps.handleMenuItemClick(item)}>
|
|
1414
|
+
{item.displayLabel}
|
|
1415
|
+
</Button>
|
|
1416
|
+
))}
|
|
1417
|
+
</View>
|
|
1418
|
+
);
|
|
1419
|
+
},
|
|
1420
|
+
};
|
|
1421
|
+
```
|
|
1422
|
+
|
|
1423
|
+
Long press menu features include:
|
|
1424
|
+
|
|
1425
|
+
- **Copy Message**: Copy text content to clipboard
|
|
1426
|
+
- **Delete Message**: Delete single message
|
|
1427
|
+
- **Multi-select**: Enter multi-select mode, used with MessageActionBar
|
|
1428
|
+
- **Like/Unlike**: Provide feedback for assistant messages (only available for assistant role messages)
|
|
1429
|
+
|
|
1430
|
+
### Customize Error Message Formatting (0.2.x New)
|
|
1431
|
+
|
|
1432
|
+
If you need to customize the display format of error messages, you can override the `formatErrorMessageAs` function, for example:
|
|
1433
|
+
|
|
1434
|
+
```tsx
|
|
1435
|
+
import { defaultRenderOptions } from '@ray-js/t-agent-ui-ray';
|
|
1436
|
+
|
|
1437
|
+
const renderOptions = {
|
|
1438
|
+
...defaultRenderOptions,
|
|
1439
|
+
formatErrorMessageAs: (message: string, code: string | undefined) => {
|
|
1440
|
+
// Return custom error messages based on error codes
|
|
1441
|
+
if (code === 'network-offline') {
|
|
1442
|
+
return 'Network connection is abnormal, please check your network settings';
|
|
1443
|
+
}
|
|
1444
|
+
if (code === 'timeout') {
|
|
1445
|
+
return 'Request timeout, please try again later';
|
|
1446
|
+
}
|
|
1447
|
+
// Use default error message
|
|
1448
|
+
return message;
|
|
1449
|
+
},
|
|
1450
|
+
};
|
|
1451
|
+
```
|
|
1452
|
+
|
|
1453
|
+
Built-in supported error codes include:
|
|
1454
|
+
|
|
1455
|
+
- `network-offline`: Network disconnected
|
|
1456
|
+
- `timeout`: Send timeout
|
|
1457
|
+
- `invalid-params`: Invalid parameters
|
|
1458
|
+
- `session-create-failed`: Connection failed
|
|
1459
|
+
- `connection-closed`: Connection closed
|
|
1460
|
+
- And more
|
|
1461
|
+
|
|
1214
1462
|
### Customize Cards
|
|
1215
1463
|
|
|
1216
1464
|
Cards can be categorized into three types: built-in cards (buildIn), custom cards (custom), and low-code cards (lowCode). Currently, low-code cards are still under development. Custom cards can be registered using `customCardMap`.
|
|
@@ -1392,78 +1640,131 @@ const renderOptions = {
|
|
|
1392
1640
|
|
|
1393
1641
|
Below are the built-in multilingual keys:
|
|
1394
1642
|
|
|
1395
|
-
| key
|
|
1396
|
-
|
|
|
1397
|
-
| t-agent.build-in.button.create_scene_manually
|
|
1398
|
-
| t-agent.build-in.button.enter_home_manage
|
|
1399
|
-
| t-agent.build-in.button.enter_room_manage
|
|
1400
|
-
| t-agent.build-in.button.enter_alarm_message
|
|
1401
|
-
| t-agent.build-in.button.enter_home_message
|
|
1402
|
-
| t-agent.build-in.button.enter_bulletin
|
|
1403
|
-
| t-agent.build-in.button.enter_notification_setting
|
|
1404
|
-
| t-agent.build-in.button.enter_personal_information
|
|
1405
|
-
| t-agent.build-in.button.enter_account_security
|
|
1406
|
-
| t-agent.build-in.button.enter_setting
|
|
1407
|
-
| t-agent.build-in.button.enter_paring
|
|
1408
|
-
| t-agent.build-in.button.enter_share_device
|
|
1409
|
-
| t-agent.build-in.button.enter_faq_feedback
|
|
1410
|
-
| t-agent.build-in.button.questionnaire_take
|
|
1411
|
-
| t-agent.build-in.button.set_home_location
|
|
1412
|
-
| t-agent.input.voice.require-permission
|
|
1413
|
-
| t-agent.input.upload.failed
|
|
1414
|
-
| t-agent.
|
|
1415
|
-
| t-agent.
|
|
1416
|
-
| t-agent.
|
|
1417
|
-
| t-agent.
|
|
1418
|
-
| t-agent.
|
|
1419
|
-
| t-agent.
|
|
1420
|
-
| t-agent.
|
|
1421
|
-
| t-agent.
|
|
1422
|
-
| t-agent.
|
|
1423
|
-
| t-agent.
|
|
1424
|
-
| t-agent.
|
|
1425
|
-
| t-agent.
|
|
1426
|
-
| t-agent.
|
|
1427
|
-
| t-agent.
|
|
1428
|
-
| t-agent.
|
|
1429
|
-
| t-agent.
|
|
1430
|
-
| t-agent.
|
|
1431
|
-
| t-agent.
|
|
1432
|
-
| t-agent.
|
|
1433
|
-
| t-agent.
|
|
1434
|
-
| t-agent.
|
|
1435
|
-
| t-agent.
|
|
1436
|
-
| t-agent.
|
|
1437
|
-
| t-agent.
|
|
1438
|
-
| t-agent.
|
|
1439
|
-
| t-agent.
|
|
1440
|
-
| t-agent.
|
|
1441
|
-
| t-agent.
|
|
1442
|
-
| t-agent.
|
|
1443
|
-
| t-agent.
|
|
1444
|
-
| t-agent.
|
|
1445
|
-
| t-agent.
|
|
1446
|
-
| t-agent.
|
|
1447
|
-
| t-agent.
|
|
1448
|
-
| t-agent.
|
|
1449
|
-
| t-agent.
|
|
1450
|
-
| t-agent.
|
|
1451
|
-
| t-agent.
|
|
1452
|
-
| t-agent.
|
|
1453
|
-
| t-agent.
|
|
1454
|
-
| t-agent.
|
|
1455
|
-
| t-agent.
|
|
1456
|
-
| t-agent.
|
|
1457
|
-
| t-agent.
|
|
1643
|
+
| key | Usage Context | Meaning |
|
|
1644
|
+
| ---------------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------- |
|
|
1645
|
+
| t-agent.build-in.button.create_scene_manually | Built-in ButtonTile button | Manually create scene |
|
|
1646
|
+
| t-agent.build-in.button.enter_home_manage | Built-in ButtonTile button | Enter _"Home Management"_ |
|
|
1647
|
+
| t-agent.build-in.button.enter_room_manage | Built-in ButtonTile button | Enter _"Room Management"_ |
|
|
1648
|
+
| t-agent.build-in.button.enter_alarm_message | Built-in ButtonTile button | Enter _"Alarm Message List"_ |
|
|
1649
|
+
| t-agent.build-in.button.enter_home_message | Built-in ButtonTile button | Enter _"Home Message List"_ |
|
|
1650
|
+
| t-agent.build-in.button.enter_bulletin | Built-in ButtonTile button | Enter _"Bulletin Message List"_ |
|
|
1651
|
+
| t-agent.build-in.button.enter_notification_setting | Built-in ButtonTile button | Enter _"Notification Settings"_ |
|
|
1652
|
+
| t-agent.build-in.button.enter_personal_information | Built-in ButtonTile button | Enter _"Personal Information"_ |
|
|
1653
|
+
| t-agent.build-in.button.enter_account_security | Built-in ButtonTile button | Enter _"Account and Security"_ |
|
|
1654
|
+
| t-agent.build-in.button.enter_setting | Built-in ButtonTile button | Enter _"General Settings"_ |
|
|
1655
|
+
| t-agent.build-in.button.enter_paring | Built-in ButtonTile button | Enter _"Device Pairing"_ |
|
|
1656
|
+
| t-agent.build-in.button.enter_share_device | Built-in ButtonTile button | Enter _"Share Device"_ |
|
|
1657
|
+
| t-agent.build-in.button.enter_faq_feedback | Built-in ButtonTile button | Enter _"FAQs and Feedback"_ |
|
|
1658
|
+
| t-agent.build-in.button.questionnaire_take | Built-in ButtonTile button | Take the questionnaire |
|
|
1659
|
+
| t-agent.build-in.button.set_home_location | Built-in ButtonTile button | Set home location |
|
|
1660
|
+
| t-agent.input.voice.require-permission | MessageInput switch to voice input | Need to grant recording permission |
|
|
1661
|
+
| t-agent.input.upload.failed | MessageInput file upload | File upload failed |
|
|
1662
|
+
| t-agent.input.asr.oninput.text.top | MessageInput ASR voice input | I'm listening, please speak |
|
|
1663
|
+
| t-agent.input.asr.oninput.text.center | MessageInput ASR voice input | Release to send, swipe up to cancel |
|
|
1664
|
+
| t-agent.input.asr.ptt | MessageInput ASR voice input | Hold to speak |
|
|
1665
|
+
| t-agent.input.asr.error.too-short | MessageInput ASR error | Speech too short |
|
|
1666
|
+
| t-agent.input.asr.error.empty | MessageInput ASR error | Unable to recognize text from speech |
|
|
1667
|
+
| t-agent.input.asr.error.unknown | MessageInput ASR error | Speech recognition failed |
|
|
1668
|
+
| t-agent.input.asr.error.timeout | MessageInput ASR error | Speech recognition reached time limit, will send directly |
|
|
1669
|
+
| t-agent.input.upload.source-type.camera | MessageInput file upload | Take photo |
|
|
1670
|
+
| t-agent.input.upload.source-type.camera.require-permission | MessageInput file upload | Camera permission required for taking photos, please enable in settings |
|
|
1671
|
+
| t-agent.input.upload.source-type.album | MessageInput file upload | Choose from album |
|
|
1672
|
+
| t-agent.input.upload.source-type.album.require-permission | MessageInput file upload | Album permission required for choosing from album, please enable in settings |
|
|
1673
|
+
| t-agent.input.upload.image.max-reached | MessageInput file upload | Image upload limit reached |
|
|
1674
|
+
| t-agent.input.upload.video.max-reached | MessageInput file upload | Video upload limit reached |
|
|
1675
|
+
| t-agent.file-tile.unknown-filename | FileTile file display | File |
|
|
1676
|
+
| t-agent.message.feedback.success | BubbleTile message feedback | Feedback successful |
|
|
1677
|
+
| t-agent.message.bubble.aborted | BubbleTile message | User aborted |
|
|
1678
|
+
| t-agent.message.action.copy | BubbleTile long press menu | Copy message |
|
|
1679
|
+
| t-agent.message.action.delete | BubbleTile long press menu | Delete message |
|
|
1680
|
+
| t-agent.message.action.multi-select | BubbleTile long press menu | Multi-select |
|
|
1681
|
+
| t-agent.message.action.like | BubbleTile long press menu | Like message |
|
|
1682
|
+
| t-agent.message.action.unlike | BubbleTile long press menu | Dislike message |
|
|
1683
|
+
| t-agent.message.copy.success | BubbleTile copy success | Copy successful |
|
|
1684
|
+
| t-agent.message.delete.success | BubbleTile delete success | Delete successful |
|
|
1685
|
+
| t-agent.message.like.success | BubbleTile feedback | Like successful |
|
|
1686
|
+
| t-agent.message.unlike.success | BubbleTile feedback | Dislike successful |
|
|
1687
|
+
| t-agent.message.delete.title | BubbleTile delete message dialog title | Delete message |
|
|
1688
|
+
| t-agent.message.delete.content | BubbleTile delete message dialog content | Are you sure to delete this message? |
|
|
1689
|
+
| t-agent.message.delete.confirm | BubbleTile delete message dialog confirm | Confirm |
|
|
1690
|
+
| t-agent.message.delete.cancel | BubbleTile delete message dialog cancel | Cancel |
|
|
1691
|
+
| t-agent.message.clear-history.title | MessageActionBar clear history | Clear history |
|
|
1692
|
+
| t-agent.message.clear-history.content | MessageActionBar clear history | Are you sure to clear history? |
|
|
1693
|
+
| t-agent.message.clear-history.button | MessageActionBar clear history | Clear history |
|
|
1694
|
+
| t-agent.message.multi-select-delete.title | MessageActionBar multi-select delete | Delete selected messages |
|
|
1695
|
+
| t-agent.message.multi-select-delete.content | MessageActionBar multi-select delete | Are you sure to delete these selected messages? |
|
|
1696
|
+
| t-agent.execute-card-tile.execution.success | ExecuteCardTile execution result | Execution successful |
|
|
1697
|
+
| t-agent.execute-card-tile.execution.failed | ExecuteCardTile execution result | Execution failed |
|
|
1698
|
+
| t-agent.execute-card-tile.scene.invalid | ExecuteCardTile scene status | Scene invalid |
|
|
1699
|
+
| t-agent.execute-card-tile.delete | ExecuteCardTile button | Delete |
|
|
1700
|
+
| t-agent.execute-card-tile.execute | ExecuteCardTile button | Execute |
|
|
1701
|
+
| t-agent.execute-card-tile.switch.scene.state | ExecuteCardTile operation | Switch scene state |
|
|
1702
|
+
| t-agent.operate-card-tile.open.device.failed | OperateCardTile operation result | Failed to open device |
|
|
1703
|
+
| t-agent.operate-card-tile.open.scene.failed | OperateCardTile operation result | Failed to open scene |
|
|
1704
|
+
| t-agent.operate-card-tile.operation.impact | OperateCardTile title | Operation impact: |
|
|
1705
|
+
| t-agent.operate-card-tile.hide.details | OperateCardTile button | Hide details |
|
|
1706
|
+
| t-agent.operate-card-tile.view.details | OperateCardTile button | View details |
|
|
1707
|
+
| t-agent.operate-card-tile.device.move.desc | OperateCardTile device move | Device "{device}" moved to "{room}" |
|
|
1708
|
+
| t-agent.operate-card-tile.device.rename.desc | OperateCardTile device rename | Device "{oldName}" renamed to "{newName}" |
|
|
1709
|
+
| t-agent.operate-card-tile.device.count | OperateCardTile device count | {count} devices |
|
|
1710
|
+
| t-agent.operate-card-tile.scene.count | OperateCardTile scene count | {count} scenes |
|
|
1711
|
+
| t-agent.operate-card-tile.home.count | OperateCardTile home count | {count} homes |
|
|
1712
|
+
| t-agent.operate-card-tile.room.count | OperateCardTile room count | {count} rooms |
|
|
1713
|
+
| t-agent.operate-card-tile.group.count | OperateCardTile group count | {count} groups |
|
|
1714
|
+
| t-agent.operate-card-tile.description.format | OperateCardTile description format | {items}. |
|
|
1715
|
+
| t-agent.operate-card-tile.description.separator | OperateCardTile description separator | , |
|
|
1716
|
+
| t-agent.expand.tab.device | ExpandTile tab | Devices |
|
|
1717
|
+
| t-agent.expand.tab.scene | ExpandTile tab | Scenes |
|
|
1718
|
+
| t-agent.expand.tab.more | ExpandTile tab | Others |
|
|
1719
|
+
| t-agent.expand.execution.success | ExpandTile execution result | Execution successful |
|
|
1720
|
+
| t-agent.expand.execution.failed | ExpandTile execution result | Execution failed |
|
|
1721
|
+
| t-agent.expand.device.rename | ExpandTile device rename | {oldName} renamed to {newName} |
|
|
1722
|
+
| t-agent.expand.scene.rename | ExpandTile scene rename | {oldName} renamed to {newName} |
|
|
1723
|
+
| t-agent.expand.scene.one-click | ExpandTile scene type | One-click execution |
|
|
1724
|
+
| t-agent.expand.scene.auto | ExpandTile scene type | Automatic execution |
|
|
1725
|
+
| t-agent.expand.no.details | ExpandTile no content prompt | No details available |
|
|
1726
|
+
| t-agent.error.unknown-error | Error message | Unknown error |
|
|
1727
|
+
| t-agent.error.network-offline | Error message | Network disconnected, please check network connection |
|
|
1728
|
+
| t-agent.error.invalid-params | Error message | Invalid parameters, please retry |
|
|
1729
|
+
| t-agent.error.session-create-failed | Error message | Connection failed, please retry |
|
|
1730
|
+
| t-agent.error.connection-closed | Error message | Connection closed, please retry |
|
|
1731
|
+
| t-agent.error.event-exists | Error message | Message sending error, please try again later |
|
|
1732
|
+
| t-agent.error.event-disposed | Error message | Message sending error, please try again later |
|
|
1733
|
+
| t-agent.error.event-closed | Error message | Message sending error, please try again later |
|
|
1734
|
+
| t-agent.error.event-aborted | Error message | Message aborted |
|
|
1735
|
+
| t-agent.error.event-write-failed | Error message | Message sending error, please try again later |
|
|
1736
|
+
| t-agent.error.event-no-data-code | Error message | Message sending error, please try again later |
|
|
1737
|
+
| t-agent.error.stream-exists | Error message | Message sending error, please try again later |
|
|
1738
|
+
| t-agent.error.timeout | Error message | Send timeout |
|
|
1739
|
+
| t-agent.error.asr-empty | Error message | Speech recognition result is empty |
|
|
1458
1740
|
|
|
1459
1741
|
# Change Log
|
|
1460
1742
|
|
|
1461
|
-
##
|
|
1743
|
+
## Version 0.2.x
|
|
1744
|
+
|
|
1745
|
+
### @ray-js/t-agent
|
|
1746
|
+
|
|
1747
|
+
- **Hook Mechanism Enhancement**: Added new lifecycle hooks such as `onMessageFeedback` and `onClearHistory`
|
|
1748
|
+
- **Message State Management**: Optimized message state management, providing more precise message state control
|
|
1749
|
+
- **Error Handling**: Enhanced error handling mechanism, supporting more detailed error information and error classification
|
|
1750
|
+
- **Performance Optimization**: Optimized memory management and garbage collection mechanisms
|
|
1751
|
+
|
|
1752
|
+
### @ray-js/t-agent-plugin-aistream
|
|
1753
|
+
|
|
1754
|
+
- **New Plugin**: Replaces the deprecated assistant plugin, providing more powerful functionality
|
|
1755
|
+
- **Text-to-Speech**: Supports TTS functionality, controlled via `enableTts` parameter
|
|
1756
|
+
- **Connection Optimization**: Added `earlyStart` parameter, supporting early connection establishment to reduce first response time
|
|
1757
|
+
- **Token Management**: Optimized Token acquisition mechanism, supporting custom `tokenOptions`
|
|
1758
|
+
- **Speech Recognition**: Added AsrAgent speech recognition functionality, supporting real-time speech-to-text
|
|
1759
|
+
- **Mock Mechanism**: Improved mock mechanism, supporting more flexible testing scenarios
|
|
1760
|
+
- **Multi-modal Support**: Default support for various input types including text, images, and voice
|
|
1761
|
+
|
|
1762
|
+
### @ray-js/t-agent-ui-ray
|
|
1462
1763
|
|
|
1463
|
-
- **
|
|
1464
|
-
- **
|
|
1465
|
-
- **
|
|
1466
|
-
- **
|
|
1467
|
-
- **
|
|
1468
|
-
- **
|
|
1469
|
-
- **
|
|
1764
|
+
- **Message Action Bar**: Added MessageActionBar component, supporting multi-select operations and batch deletion
|
|
1765
|
+
- **Virtual Scrolling**: Integrated LazyScrollView, providing virtual scrolling and performance optimization
|
|
1766
|
+
- **Internationalization System**: Complete internationalization system, supporting 8 languages including Simplified Chinese, Traditional Chinese, English, Japanese, etc.
|
|
1767
|
+
- **Translation Hook**: Added useTranslate Hook, simplifying multilingual usage
|
|
1768
|
+
- **Custom Rendering**: Extended renderOptions, supporting more custom rendering options
|
|
1769
|
+
- **Interaction Optimization**: Optimized long press menu functionality, supporting copy, delete, multi-select, like and other operations
|
|
1770
|
+
- **UI Enhancement**: Added multilingual key-value pairs, covering all UI interaction scenarios
|