@blueking/ai-ui-sdk 0.0.15-beta.3 → 0.0.15-beta.4

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.
@@ -25,6 +25,7 @@ export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, ha
25
25
  time?: string | undefined;
26
26
  property?: {
27
27
  extra?: {
28
+ [x: string]: any;
28
29
  tools?: {
29
30
  spaceId?: string | undefined;
30
31
  header: {
@@ -431,6 +432,7 @@ export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, ha
431
432
  time?: string | undefined;
432
433
  property?: {
433
434
  extra?: {
435
+ [x: string]: any;
434
436
  tools?: {
435
437
  spaceId?: string | undefined;
436
438
  header: {
@@ -828,7 +830,7 @@ export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, ha
828
830
  chat: ({ sessionCode, data, url, headers, }: {
829
831
  sessionCode: string;
830
832
  data?: Record<string, any>;
831
- url: string;
833
+ url?: string;
832
834
  headers?: Record<string, string>;
833
835
  }) => void;
834
836
  sendChat: (content: BasicChatContent | ShortcutChatContent, callback?: () => void) => void;
@@ -844,11 +846,8 @@ export declare const useChat: ({ handleStart, handleText, handleReferenceDoc, ha
844
846
  deleteSessionContents: (sessionCode: string, contentIds: number[]) => Promise<number>;
845
847
  handleStartChat: (sessionCode: string) => Promise<void | undefined>;
846
848
  handleErrorChat: (sessionCode: string, message: string, code?: string) => Promise<void | undefined>;
847
- reGenerateChat: (chatIndex: number) => void;
848
- reSendChat: (index: number, { message, cite }: {
849
- message: string;
850
- cite?: string;
851
- }, callback?: () => void) => void;
849
+ reGenerateChat: (sessionCode: string, sessionContent: ISessionContent, sessionIndex: number) => void;
850
+ reSendChat: (sessionCode: string, sessionContent: ISessionContent, sessionIndex: number) => void;
852
851
  deleteChat: (index: number) => void;
853
852
  clearSessionApi: (sessionCode: string) => Promise<unknown>;
854
853
  getSessionsApi: () => Promise<ISession[]>;
@@ -434,18 +434,17 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
434
434
  return _handleErrorChat.apply(this, arguments);
435
435
  }
436
436
  // 重新生成对话 仅支持重新生成 ai 的回复
437
- function reGenerateChat(chatIndex) {
438
- const chat = sessionContents.value[chatIndex];
439
- if (chat.role !== SessionContentRole.Ai) {
437
+ function reGenerateChat(sessionCode, sessionContent, sessionIndex) {
438
+ if (sessionContent.role !== SessionContentRole.Ai) {
440
439
  return;
441
440
  }
442
- const message = sessionContents.value[chatIndex - 1].content;
443
- const cite = sessionContents.value[chatIndex - 1].cite;
444
- sessionContents.value.splice(chatIndex - 1, sessionContents.value.length - chatIndex + 1); // 重新生成时,删除当前的 ai 回复和下方的所有内容
445
- sendChat({
446
- message,
447
- cite
448
- });
441
+ // 重新生成时,删除当前的 ai 回复和下方的所有内容
442
+ const sessionIds = sessionContents.value.slice(sessionIndex, sessionContents.value.length).map((item)=>item.id).filter((item)=>item !== undefined);
443
+ if (sessionIds.length > 0) {
444
+ deleteSessionContents(sessionCode, sessionIds);
445
+ }
446
+ const userSessionContent = sessionContents.value[sessionIndex - 1];
447
+ userSessionContent && chat(userSessionContent);
449
448
  }
450
449
  // 聊天
451
450
  function chat({ sessionCode, data, url, headers }) {
@@ -453,7 +452,7 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
453
452
  // 发送请求
454
453
  chatHelper.stream({
455
454
  sessionCode,
456
- url: url,
455
+ url: url || requestOptions.url,
457
456
  data: _object_spread({
458
457
  session_content_id: sessionContent.id,
459
458
  session_code: sessionCode
@@ -462,16 +461,15 @@ export const useChat = ({ handleStart, handleText, handleReferenceDoc, handleThi
462
461
  });
463
462
  }
464
463
  // 重新发送聊天, 需要将当前聊天内容以及下方的所有内容删除
465
- function reSendChat(index, { message, cite }, callback) {
466
- const chat = sessionContents.value[index];
467
- if (chat.role !== SessionContentRole.User) {
464
+ function reSendChat(sessionCode, sessionContent, sessionIndex) {
465
+ if (sessionContent.role !== SessionContentRole.User) {
468
466
  return;
469
467
  }
470
- sessionContents.value.splice(index, sessionContents.value.length - index);
471
- sendChat({
472
- message,
473
- cite
474
- }, callback);
468
+ const sessionIds = sessionContents.value.slice(sessionIndex, sessionContents.value.length).map((item)=>item.id).filter((item)=>item !== undefined);
469
+ if (sessionIds.length > 0) {
470
+ deleteSessionContents(sessionCode, sessionIds);
471
+ }
472
+ chat(sessionContent);
475
473
  }
476
474
  // 发送聊天
477
475
  function sendChat(content, callback) {
@@ -27,6 +27,7 @@ export interface ISessionContentApi {
27
27
  knowledgebases?: IKnowledgebaseApi[];
28
28
  knowledge_folders?: IKnowledgeApi[];
29
29
  };
30
+ [key: string]: any;
30
31
  };
31
32
  };
32
33
  }
@@ -49,6 +50,7 @@ export interface ISessionContent {
49
50
  extra?: {
50
51
  tools?: ITool[];
51
52
  anchorPathResources?: IAnchorPathResources;
53
+ [key: string]: any;
52
54
  };
53
55
  };
54
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blueking/ai-ui-sdk",
3
- "version": "0.0.15-beta.3",
3
+ "version": "0.0.15-beta.4",
4
4
  "description": "蓝鲸AI UI SDK",
5
5
  "main": "dist/main.js",
6
6
  "types": "dist/main.d.ts",