@ray-js/t-agent 0.0.5-beta-1 → 0.0.6-beta-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/README-zh_CN.md CHANGED
@@ -667,7 +667,7 @@ const createAgent = () => {
667
667
  withUI(), // 一般都需要应用 withUI 插件
668
668
  withAssistant({
669
669
  channel: 'your-channel-id', // 输入你的智能体ID
670
- multiModal: false, // 是否开启多模态,默认为 true
670
+ multiModal: false, // 是否开启多模态,默认为 false
671
671
  }),
672
672
  withBuildIn()
673
673
  );
@@ -685,7 +685,7 @@ const createAgent = () => {
685
685
  参数:
686
686
 
687
687
  - `channel` 智能体 ID
688
- - `multiModal` 是否开启多模态,默认为 true
688
+ - `multiModal` 是否开启多模态,默认为 false
689
689
  - `wireInputToAssistant` 是否将输入块传递给智能体,默认为 true,设置为 false 时,需要你自己编写 onInputBlocksPush Hook 来处理输入块
690
690
  - `historySize` 历史消息大小,默认为 100
691
691
 
package/README.md CHANGED
@@ -374,11 +374,11 @@ sequenceDiagram
374
374
  UI ->> A: agent.pushInputBlocks()
375
375
  rect rgba(255,255,0,0.1)
376
376
  note over A: Hook: onInputBlocksPush
377
- A ->> A: Create Message object msg\nSet msg as user's input text\nmsg.show()
377
+ A ->> A: Create Message object msg<br/>Set msg as user's input text<br/>msg.show()
378
378
  note over A: Hook: onMessageChange show
379
379
  A -->> UI: Update interface
380
380
  UI -->> User: Display new message
381
- A ->> A: Create Message object respMsg\nSet respMsg as "loading"\nrespMsg.show()
381
+ A ->> A: Create Message object respMsg<br/>Set respMsg as "loading"<br/>respMsg.show()
382
382
  note over A: Hook: onMessageChange show
383
383
  A -->> UI: Update interface
384
384
  UI -->> User: Display loading message
@@ -386,7 +386,7 @@ sequenceDiagram
386
386
  AI ->> A: Return message stream
387
387
  loop Streaming messages
388
388
  AI ->> A: Message packet
389
- A ->> A: Update respMsg data\nrespMsg.update()
389
+ A ->> A: Update respMsg data<br/>respMsg.update()
390
390
  note over A: Hook: onMessageChange update
391
391
  A -->> UI: Update interface
392
392
  UI -->> User: Display typing effect/card
@@ -399,7 +399,7 @@ sequenceDiagram
399
399
  UI ->> A: agent.emitTileEvent()
400
400
  rect rgba(255,255,0,0.1)
401
401
  note over A: Hook: onTileEvent
402
- A ->> A: Set msg status\nmsg.persist()
402
+ A ->> A: Set msg status<br/>msg.persist()
403
403
  note over A: Hook: onMessagePersist
404
404
  A ->> AI: Persist message
405
405
  AI ->> A: Return result
@@ -679,7 +679,7 @@ This plugin facilitates communication with applet AI agent platforms.
679
679
  Parameters:
680
680
 
681
681
  - `channel`: Agent ID
682
- - `multiModal`: Enable multi-modal? Defaults to true
682
+ - `multiModal`: Enable multi-modal? Defaults to false
683
683
  - `wireInputToAssistant`: Should input blocks be passed to the agent? Defaults to true. Set to false if you plan to handle input blocks manually with the onInputBlocksPush Hook.
684
684
  - `historySize`: Size of message history, default is 100.
685
685
 
@@ -192,6 +192,7 @@ export default class ChatAgent {
192
192
  await this.runWithCatchError(async () => {
193
193
  try {
194
194
  const parts = response.parts();
195
+ let partText = '';
195
196
  var _iteratorAbruptCompletion = false;
196
197
  var _didIteratorError = false;
197
198
  var _iteratorError;
@@ -201,6 +202,7 @@ export default class ChatAgent {
201
202
  {
202
203
  message.setMeta(part.meta);
203
204
  if (part.type === 'text') {
205
+ partText = part.text;
204
206
  text = await textCompose(message, part.text, ChatMessageStatus.UPDATING);
205
207
  await message.set({
206
208
  status: ChatMessageStatus.UPDATING
@@ -239,7 +241,7 @@ export default class ChatAgent {
239
241
  }
240
242
  }
241
243
  }
242
- text = await textCompose(message, text, ChatMessageStatus.FINISH);
244
+ text = await textCompose(message, partText, ChatMessageStatus.FINISH);
243
245
  await message.set({
244
246
  status: ChatMessageStatus.FINISH
245
247
  }).bubble.setText(text).update();
@@ -19,7 +19,7 @@ export default class ChatMessage implements ChatMessageObject {
19
19
  update(): Promise<void>;
20
20
  remove(): Promise<void>;
21
21
  _setIsShow(): void;
22
- persist(payload: any): Promise<void>;
22
+ persist(payload?: any): Promise<void>;
23
23
  setTilesLocked(locked: boolean): this;
24
24
  removeTile(tile: ChatTile): void;
25
25
  addTile(type: string, data: any, id?: string): ChatTile<any>;
@@ -11,6 +11,7 @@ export default class ChatTile<T = any> implements ChatTileObject<T> {
11
11
  constructor(message: ChatMessage, type: string, data?: T, children?: ChatTile[], id?: string);
12
12
  setLocked(value: boolean): this;
13
13
  addTile(type: string, data: any, id?: string): ChatTile<any>;
14
+ removeTile(tile: ChatTile): this;
14
15
  /**
15
16
  * 同 message 的 show
16
17
  */
@@ -1,5 +1,6 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
3
+ import "core-js/modules/esnext.iterator.constructor.js";
3
4
  import "core-js/modules/esnext.iterator.map.js";
4
5
  import "core-js/modules/web.dom-collections.iterator.js";
5
6
  import { generateId } from './utils';
@@ -29,6 +30,13 @@ export default class ChatTile {
29
30
  this.children.push(tile);
30
31
  return tile;
31
32
  }
33
+ removeTile(tile) {
34
+ const index = this.children.indexOf(tile);
35
+ if (index !== -1) {
36
+ this.children.splice(index, 1);
37
+ }
38
+ return this;
39
+ }
32
40
 
33
41
  /**
34
42
  * 同 message 的 show
@@ -1,6 +1,6 @@
1
1
  import { ChatAgentPlugin } from './types';
2
2
  import ChatAgent from './ChatAgent';
3
- type ExtractPluginReturnType<T extends ChatAgentPlugin<any>[]> = T extends [infer F, ...infer R] ? F extends ChatAgentPlugin<infer U> ? R extends ChatAgentPlugin<any>[] ? U & ExtractPluginReturnType<R> : U : never : Record<string, unknown>;
4
- export declare function createChatAgent<T extends ChatAgentPlugin<any>[]>(...plugins: T): ChatAgent<Omit<ExtractPluginReturnType<T>, 'hooks'>>;
3
+ type ExtractPluginReturnType<T extends ChatAgentPlugin<any>[]> = T extends [infer F, ...infer R] ? F extends ChatAgentPlugin<infer U> ? R extends ChatAgentPlugin<any>[] ? U & ExtractPluginReturnType<R> : U : any : Record<string, unknown>;
4
+ export declare function createChatAgent<T extends ChatAgentPlugin<any>[]>(...plugins: T): ChatAgent<ExtractPluginReturnType<T>>;
5
5
  export declare function applyChatAgentPlugins<T extends Record<string, unknown>, P extends ChatAgentPlugin<any>[]>(agent: ChatAgent<T>, ...plugins: P): ChatAgent<T & ExtractPluginReturnType<P>>;
6
6
  export {};
@@ -1,3 +1,4 @@
1
+ import "core-js/modules/esnext.iterator.constructor.js";
1
2
  import "core-js/modules/esnext.iterator.map.js";
2
3
  import { Emitter, EmitterEvent } from '../chat';
3
4
  export function withUI() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent",
3
- "version": "0.0.5-beta-1",
3
+ "version": "0.0.6-beta-1",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -26,5 +26,5 @@
26
26
  "build": "ray build --type=component --output dist",
27
27
  "clean": "rimraf ./dist"
28
28
  },
29
- "gitHead": "c2f10c94fb4031e1c375864e70a69adb3bbadd2d"
29
+ "gitHead": "942a1aeceb65c55ba935409d386bc09f9874e283"
30
30
  }