@blueking/chat-helper 0.0.8 → 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.
@@ -82,6 +82,7 @@ function _object_spread(target) {
82
82
  import { ref } from 'vue';
83
83
  import { AGUIProtocol } from '../event/index.ts.js';
84
84
  import { MessageRole, MessageStatus } from '../message/index.ts.js';
85
+ import { SessionStatus } from '../session/type.ts.js';
85
86
  /**
86
87
  * Agent 模块
87
88
  * @param options - 配置选项
@@ -203,9 +204,8 @@ import { MessageRole, MessageStatus } from '../message/index.ts.js';
203
204
  * @param url - 请求 URL(可选)
204
205
  * @param config - 请求配置(可选)
205
206
  */ const resumeStreamingChat = (sessionCode, url, config)=>{
206
- var _mediator_message;
207
- const lastMessage = (_mediator_message = mediator.message) === null || _mediator_message === void 0 ? void 0 : _mediator_message.list.value.at(-1);
208
- if ((lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.status) === MessageStatus.Streaming || (lastMessage === null || lastMessage === void 0 ? void 0 : lastMessage.role) === MessageRole.User) {
207
+ var _mediator_session_current_value, _mediator_session;
208
+ if (((_mediator_session = mediator.session) === null || _mediator_session === void 0 ? void 0 : (_mediator_session_current_value = _mediator_session.current.value) === null || _mediator_session_current_value === void 0 ? void 0 : _mediator_session_current_value.status) === SessionStatus.Running) {
209
209
  streamRequest(sessionCode, url, config);
210
210
  }
211
211
  };
@@ -38,6 +38,7 @@
38
38
  rate: data.rate,
39
39
  updatedAt: data.updated_at,
40
40
  createdAt: data.created_at,
41
+ status: data.status,
41
42
  roleInfo: data.role_info ? {
42
43
  collectionId: data.role_info.collection_id,
43
44
  collectionName: data.role_info.collection_name,
@@ -67,6 +68,7 @@
67
68
  rate: data.rate,
68
69
  updated_at: data.updatedAt,
69
70
  created_at: data.createdAt,
71
+ status: data.status,
70
72
  role_info: data.roleInfo ? {
71
73
  collection_id: data.roleInfo.collectionId,
72
74
  collection_name: data.roleInfo.collectionName,
package/dist/index.d.ts CHANGED
@@ -649,6 +649,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
649
649
  sessionName: string;
650
650
  tools?: unknown[];
651
651
  updatedAt?: string;
652
+ status?: import("./session").SessionStatus;
652
653
  roleInfo?: {
653
654
  collectionId: number;
654
655
  collectionName: string;
@@ -1163,6 +1164,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
1163
1164
  sessionName: string;
1164
1165
  tools?: unknown[];
1165
1166
  updatedAt?: string;
1167
+ status?: import("./session").SessionStatus;
1166
1168
  roleInfo?: {
1167
1169
  collectionId: number;
1168
1170
  collectionName: string;
@@ -1678,6 +1680,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
1678
1680
  sessionName: string;
1679
1681
  tools?: unknown[];
1680
1682
  updatedAt?: string;
1683
+ status?: import("./session").SessionStatus;
1681
1684
  roleInfo?: {
1682
1685
  collectionId: number;
1683
1686
  collectionName: string;
@@ -2192,6 +2195,7 @@ export declare const useChatHelper: (options: IUseChatHelperOptions) => {
2192
2195
  sessionName: string;
2193
2196
  tools?: unknown[];
2194
2197
  updatedAt?: string;
2198
+ status?: import("./session").SessionStatus;
2195
2199
  roleInfo?: {
2196
2200
  collectionId: number;
2197
2201
  collectionName: string;
@@ -1,4 +1,10 @@
1
1
  import type { IMessage } from '../message';
2
+ export declare enum SessionStatus {
3
+ Running = "running",
4
+ Finished = "finished",
5
+ Failed = "failed",
6
+ Cancelled = "cancelled"
7
+ }
2
8
  export interface ISession<ITool = unknown, IAnchorPathResources = unknown> {
3
9
  anchorPathResources?: IAnchorPathResources;
4
10
  comment?: string;
@@ -12,6 +18,7 @@ export interface ISession<ITool = unknown, IAnchorPathResources = unknown> {
12
18
  sessionName: string;
13
19
  tools?: ITool[];
14
20
  updatedAt?: string;
21
+ status?: SessionStatus;
15
22
  roleInfo?: {
16
23
  collectionId: number;
17
24
  collectionName: string;
@@ -40,6 +47,7 @@ export interface ISessionApi<IToolApi = unknown, IAnchorPathResourcesApi = unkno
40
47
  session_name: string;
41
48
  tools?: IToolApi[];
42
49
  updated_at?: string;
50
+ status?: SessionStatus;
43
51
  role_info?: {
44
52
  collection_id: number;
45
53
  collection_name: string;
@@ -22,4 +22,10 @@
22
22
  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
23
  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24
24
  * IN THE SOFTWARE.
25
- */ export { };
25
+ */ export var SessionStatus;
26
+ (function(SessionStatus) {
27
+ SessionStatus["Running"] = "running";
28
+ SessionStatus["Finished"] = "finished";
29
+ SessionStatus["Failed"] = "failed";
30
+ SessionStatus["Cancelled"] = "cancelled";
31
+ })(SessionStatus || (SessionStatus = {}));
@@ -18,6 +18,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
18
18
  sessionName: string;
19
19
  tools?: unknown[];
20
20
  updatedAt?: string;
21
+ status?: import("./type").SessionStatus;
21
22
  roleInfo?: {
22
23
  collectionId: number;
23
24
  collectionName: string;
@@ -532,6 +533,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
532
533
  sessionName: string;
533
534
  tools?: unknown[];
534
535
  updatedAt?: string;
536
+ status?: import("./type").SessionStatus;
535
537
  roleInfo?: {
536
538
  collectionId: number;
537
539
  collectionName: string;
@@ -1047,6 +1049,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
1047
1049
  sessionName: string;
1048
1050
  tools?: unknown[];
1049
1051
  updatedAt?: string;
1052
+ status?: import("./type").SessionStatus;
1050
1053
  roleInfo?: {
1051
1054
  collectionId: number;
1052
1055
  collectionName: string;
@@ -1561,6 +1564,7 @@ export declare const useSession: (mediator: IMediatorModule) => {
1561
1564
  sessionName: string;
1562
1565
  tools?: unknown[];
1563
1566
  updatedAt?: string;
1567
+ status?: import("./type").SessionStatus;
1564
1568
  roleInfo?: {
1565
1569
  collectionId: number;
1566
1570
  collectionName: string;
@@ -126,9 +126,8 @@ import { ref } from 'vue';
126
126
  var // 中止当前聊天
127
127
  _mediator_agent;
128
128
  (_mediator_agent = mediator.agent) === null || _mediator_agent === void 0 ? void 0 : _mediator_agent.abortChat();
129
- var _list_value_find;
130
- // 选择会话
131
- current.value = (_list_value_find = list.value.find((item)=>item.sessionCode === sessionCode)) !== null && _list_value_find !== void 0 ? _list_value_find : null;
129
+ // 从接口更新当前会话信息
130
+ yield getSession(sessionCode);
132
131
  // 默认加载消息,但允许跳过(新会话消息必定为空,无需加载)
133
132
  if ((options === null || options === void 0 ? void 0 : options.loadMessages) !== false) {
134
133
  var _mediator_message, // 继续聊天
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/chat-helper",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "./dist/index.ts.js",
6
6
  "types": "./dist/index.d.ts",