@ray-js/t-agent-plugin-aistream 0.2.0-beta-5 → 0.2.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.
@@ -86,6 +86,7 @@ export type ImagePathInputBlock = {
86
86
  type: 'image_path';
87
87
  image_path: {
88
88
  path: string;
89
+ size: number;
89
90
  };
90
91
  };
91
92
  export type FileUrlInputBlock = {
@@ -101,12 +102,15 @@ export type FilePathInputBlock = {
101
102
  file_path: {
102
103
  mimeType: string;
103
104
  path: string;
105
+ size: number;
104
106
  };
105
107
  };
106
108
  export type VideoPathInputBlock = {
107
109
  type: 'video_path';
108
110
  video_path: {
109
111
  path: string;
112
+ thumb_path: string;
113
+ size: number;
110
114
  };
111
115
  };
112
116
  /**
@@ -8,8 +8,9 @@ import "core-js/modules/esnext.iterator.map.js";
8
8
  import "core-js/modules/web.dom-collections.iterator.js";
9
9
  import { mock } from './mock';
10
10
  import { EmitterEvent, generateId } from '@ray-js/t-agent';
11
- import { BizCode, ConnectState, EventType, ReceivedTextPacketEof, ReceivedTextPacketType, StreamFlag } from '../AIStreamTypes';
11
+ import { AIStreamErrorCode, BizCode, ConnectState, EventType, ReceivedTextPacketEof, ReceivedTextPacketType, SessionState, StreamFlag } from '../AIStreamTypes';
12
12
  import AbortController from './abort';
13
+ import { tryCatch } from './misc';
13
14
  function splitString(input) {
14
15
  return input.match(/[a-zA-Z0-9]+\s*|[\u4e00-\u9fff]+\s*|[^\w\s\u4e00-\u9fff]+\s*|[\s]+/g) || [];
15
16
  }
@@ -223,7 +224,18 @@ mock.hooks.hook('sendEventEnd', context => {
223
224
  data: event.data,
224
225
  responseText: ''
225
226
  };
226
- await mock.hooks.callHook('sendToAIStream', ctx);
227
+ const [error] = await tryCatch(() => mock.hooks.callHook('sendToAIStream', ctx));
228
+ if (error) {
229
+ dispatch('onSessionStateChanged', {
230
+ sessionId: session.sessionId,
231
+ sessionState: SessionState.CLOSED,
232
+ code: AIStreamErrorCode.InternalServerError
233
+ });
234
+ session.closed = true;
235
+ const map = mock.data.get('sessionMap');
236
+ map.delete(session.sessionId);
237
+ return;
238
+ }
227
239
  const text = ctx.responseText || '⚠️ No mock text response matched!';
228
240
  const words = splitString(text);
229
241
  if (event.controller.signal.aborted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/t-agent-plugin-aistream",
3
- "version": "0.2.0-beta-5",
3
+ "version": "0.2.0-beta-6",
4
4
  "author": "Tuya.inc",
5
5
  "license": "MIT",
6
6
  "private": false,
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@types/url-parse": "^1.4.11"
37
37
  },
38
- "gitHead": "a0beda17c8e1c3ef81c718300c02a23d88a3ee4a"
38
+ "gitHead": "a09b74682949c5860f34105b4a5f8f60fc34a582"
39
39
  }