@blueking/ai-blueking 0.2.15 → 0.3.0

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.md CHANGED
@@ -63,6 +63,12 @@ npm i @blueking/ai-blueking
63
63
  import AIBlueking, { ChatHelper, RoleType, MessageStatus } from '@blueking/ai-blueking';
64
64
  import '@blueking/ai-blueking/dist/vue3/style.css';
65
65
 
66
+ interface ISendData {
67
+ content: string; // 用户输入的内容
68
+ cite?: string; // 引用的内容
69
+ prompt?: string; // 使用的 prompt 模板
70
+ }
71
+
66
72
  const loading = ref(false);
67
73
  const messages = ref([]);
68
74
 
@@ -131,19 +137,28 @@ npm i @blueking/ai-blueking
131
137
  };
132
138
 
133
139
  // 发送消息
134
- const handleSend = (message: string) => {
140
+ const handleSend = (args: ISendData) => {
135
141
  // 记录当前消息记录
136
142
  const chatHistory = [...messages.value];
137
143
  // 添加一条消息
138
144
  messages.value.push({
139
145
  role: 'user',
140
- content: message,
146
+ content: args.content,
147
+ cite: args.cite,
141
148
  });
149
+
150
+ // 根据参数构造输入内容
151
+ const input = args.prompt
152
+ ? args.prompt // 如果有 prompt,直接使用
153
+ : args.cite
154
+ ? `${args.content}: ${args.cite}` // 如果有 cite,拼接 content 和 cite
155
+ : args.content; // 否则只使用 content
156
+
142
157
  // ai 消息,id是唯一标识当前流,调用 chatHelper.stop 的时候需要传入
143
158
  chatHelper.stream(
144
159
  {
145
160
  inputs: {
146
- input: message,
161
+ input,
147
162
  chat_history: chatHistory,
148
163
  },
149
164
  },
@@ -273,6 +288,10 @@ npm i @blueking/ai-blueking
273
288
 
274
289
  const handleSend = (val: string) => {
275
290
  console.log('trigger send', val);
291
+ // args 包含:
292
+ // - content: 用户输入的内容
293
+ // - cite: 引用的内容(可选)
294
+ // - prompt: 使用的 prompt 模板(可选)
276
295
  };
277
296
 
278
297
  const handleStop = () => {
@@ -17,27 +17,36 @@ interface IProps {
17
17
  alert?: string;
18
18
  models?: IModel[];
19
19
  model?: string;
20
+ isShow?: boolean;
20
21
  }
21
22
  declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<IProps>, {
22
23
  setInputMessage: (val: string) => void;
23
24
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
24
- close: () => void;
25
25
  stop: () => void;
26
+ close: () => void;
26
27
  clear: () => void;
27
28
  "scroll-load": () => void;
28
29
  "ai-click": (val: string) => void;
29
- send: (val: string) => void;
30
30
  "update:model": (val: string) => void;
31
31
  "choose-prompt": (prompt: IPrompt) => void;
32
+ send: (data: {
33
+ content: string;
34
+ cite?: string | undefined;
35
+ }) => void;
36
+ "update:isShow": (val: boolean) => void;
32
37
  }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<IProps>>> & {
38
+ onClose?: (() => any) | undefined;
33
39
  "onChoose-prompt"?: ((prompt: IPrompt) => any) | undefined;
34
40
  onClear?: (() => any) | undefined;
35
41
  onStop?: (() => any) | undefined;
36
- onSend?: ((val: string) => any) | undefined;
42
+ onSend?: ((data: {
43
+ content: string;
44
+ cite?: string | undefined;
45
+ }) => any) | undefined;
37
46
  "onAi-click"?: ((val: string) => any) | undefined;
38
47
  "onScroll-load"?: (() => any) | undefined;
39
- onClose?: (() => any) | undefined;
40
48
  "onUpdate:model"?: ((val: string) => any) | undefined;
49
+ "onUpdate:isShow"?: ((val: boolean) => any) | undefined;
41
50
  }, {}, {}>;
42
51
  export default _default;
43
52
 
@@ -0,0 +1,28 @@
1
+ interface Props {
2
+ size?: number;
3
+ }
4
+ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
5
+ size: number;
6
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<Props>, {
7
+ size: number;
8
+ }>>>, {
9
+ size: number;
10
+ }, {}>;
11
+ export default _default;
12
+ type __VLS_WithDefaults<P, D> = {
13
+ [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
14
+ default: D[K];
15
+ }> : P[K];
16
+ };
17
+ type __VLS_Prettify<T> = {
18
+ [K in keyof T]: T[K];
19
+ } & {};
20
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
21
+ type __VLS_TypePropsToOption<T> = {
22
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
23
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
24
+ } : {
25
+ type: import('vue').PropType<T[K]>;
26
+ required: true;
27
+ };
28
+ };
@@ -0,0 +1,21 @@
1
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<{
2
+ text: string;
3
+ showCloseIcon?: boolean | undefined;
4
+ }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ close: () => void;
6
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<{
7
+ text: string;
8
+ showCloseIcon?: boolean | undefined;
9
+ }>>> & {
10
+ onClose?: (() => any) | undefined;
11
+ }, {}, {}>;
12
+ export default _default;
13
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
14
+ type __VLS_TypePropsToOption<T> = {
15
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
16
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
17
+ } : {
18
+ type: import('vue').PropType<T[K]>;
19
+ required: true;
20
+ };
21
+ };
@@ -1,4 +1,4 @@
1
- import type { IMessage, IPrompt } from '../types/index';
1
+ import type { IMessage, IPrompt, ISendData } from '../types/index';
2
2
  interface IProps {
3
3
  messages: IMessage[];
4
4
  prompts?: IPrompt[];
@@ -17,7 +17,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
17
17
  setInputMessage: (val: string) => void;
18
18
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
19
  "ai-click": (userInput: string) => void;
20
- send: (userInput: string) => void;
20
+ send: (data: ISendData) => void;
21
21
  "choose-prompt": (prompt: IPrompt) => void;
22
22
  stop: () => void;
23
23
  "scroll-load": () => void;
@@ -27,7 +27,7 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
27
27
  }>>> & {
28
28
  "onChoose-prompt"?: ((prompt: IPrompt) => any) | undefined;
29
29
  onStop?: (() => any) | undefined;
30
- onSend?: ((userInput: string) => any) | undefined;
30
+ onSend?: ((data: ISendData) => any) | undefined;
31
31
  "onAi-click"?: ((userInput: string) => any) | undefined;
32
32
  "onScroll-load"?: (() => any) | undefined;
33
33
  }, {
@@ -60,8 +60,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
60
60
  };
61
61
  logo: string;
62
62
  }>>> & {
63
- onClear?: (() => any) | undefined;
64
63
  onClose?: (() => any) | undefined;
64
+ onClear?: (() => any) | undefined;
65
65
  "onChoose-model"?: ((val: string) => any) | undefined;
66
66
  }, {
67
67
  headBackground: string;
@@ -0,0 +1,6 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
2
+ click: (...args: any[]) => void;
3
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>> & {
4
+ onClick?: ((...args: any[]) => any) | undefined;
5
+ }, {}, {}>;
6
+ export default _default;
@@ -0,0 +1,19 @@
1
+ import type { IShortCut } from '../types/index';
2
+ interface IProps {
3
+ shortcuts: IShortCut[];
4
+ }
5
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<IProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ select: (shortcut: IShortCut) => void;
7
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<IProps>>> & {
8
+ onSelect?: ((shortcut: IShortCut) => any) | undefined;
9
+ }, {}, {}>;
10
+ export default _default;
11
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
12
+ type __VLS_TypePropsToOption<T> = {
13
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
14
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
15
+ } : {
16
+ type: import('vue').PropType<T[K]>;
17
+ required: true;
18
+ };
19
+ };
@@ -0,0 +1,22 @@
1
+ import { RoleType, MessageStatus } from '../types/enum';
2
+ interface UseBkAiOptions {
3
+ useStream?: boolean;
4
+ apiUrl?: string;
5
+ }
6
+ export declare function useBkAi(options?: UseBkAiOptions): {
7
+ loading: import("vue").Ref<boolean>;
8
+ messages: import("vue").Ref<{
9
+ status?: MessageStatus | undefined;
10
+ time?: string | number | undefined;
11
+ cite?: string | undefined;
12
+ role: RoleType;
13
+ content: string;
14
+ }[]>;
15
+ isShow: import("vue").Ref<boolean>;
16
+ handleShowAi: () => void;
17
+ handleClose: () => void;
18
+ handleClear: () => void;
19
+ handleSend: (args: any) => void;
20
+ handleStop: () => void;
21
+ };
22
+ export {};
@@ -0,0 +1,4 @@
1
+ export declare function useScrollShow(): {
2
+ isShow: import("vue").Ref<boolean>;
3
+ scrollToBottom: () => void;
4
+ };
@@ -0,0 +1,12 @@
1
+ export declare function useSelect(): {
2
+ isIconVisible: import("vue").Ref<boolean>;
3
+ iconPosition: import("vue").Ref<{
4
+ top: string;
5
+ left: string;
6
+ }>;
7
+ selectedText: import("vue").Ref<string>;
8
+ hideIcon: () => void;
9
+ clearSelection: () => void;
10
+ setSelection: (text: string) => void;
11
+ lockSelectedText: import("vue").Ref<boolean>;
12
+ };
@@ -0,0 +1 @@
1
+ export * from './shortcuts';
@@ -0,0 +1,2 @@
1
+ import { IShortCut } from '../types';
2
+ export declare const DEFAULT_SHORTCUTS: IShortCut[];
@@ -23,5 +23,8 @@ export declare const langData: {
23
23
  readonly 本周: "this week";
24
24
  readonly 上周: "last week";
25
25
  readonly 复制成功: "Copy success";
26
+ readonly 您选择的文本内容: "The text content you selected";
27
+ readonly 问小鲸: "Ask BK GPT";
28
+ readonly 想对选中的文本做什么: "What do you want to do with the selected text?";
26
29
  };
27
- export declare const t: (key: keyof typeof langData) => "BK GPT" | "shrink down" | "expand upward" | "Empty chat records" | "close" | "The content is being executed, please send it after the execution is completed." | "Send" | "You can type \"/\" to see more Prompts" | "Please input" | "Latest" | "Stop" | "Scroll up to load more records" | " sunday" | " monday" | " tuesday" | " wednesday" | " thursday" | " friday" | " saturday" | "yesterday" | "this week" | "last week" | "Copy success" | "小鲸" | "向下收缩" | "向上扩展" | "清空聊天记录" | "关闭" | "内容正在执行中,请执行完成后再发送" | "发送" | "您可以键入 “/” 查看更多Prompt" | "请输入" | "返回最新" | "终止生成" | "向上滚动加载更多记录" | "日" | "一" | "二" | "三" | "四" | "五" | "六" | "昨天" | "本周" | "上周" | "复制成功";
30
+ export declare const t: (key: keyof typeof langData) => "close" | "BK GPT" | "shrink down" | "expand upward" | "Empty chat records" | "The content is being executed, please send it after the execution is completed." | "Send" | "You can type \"/\" to see more Prompts" | "Please input" | "Latest" | "Stop" | "Scroll up to load more records" | " sunday" | " monday" | " tuesday" | " wednesday" | " thursday" | " friday" | " saturday" | "yesterday" | "this week" | "last week" | "Copy success" | "The text content you selected" | "Ask BK GPT" | "What do you want to do with the selected text?" | "小鲸" | "向下收缩" | "向上扩展" | "清空聊天记录" | "关闭" | "内容正在执行中,请执行完成后再发送" | "发送" | "您可以键入 “/” 查看更多Prompt" | "请输入" | "返回最新" | "终止生成" | "向上滚动加载更多记录" | "日" | "一" | "二" | "三" | "四" | "五" | "六" | "昨天" | "本周" | "上周" | "复制成功" | "您选择的文本内容" | "问小鲸" | "想对选中的文本做什么";
@@ -4,6 +4,7 @@ export declare enum AgentMessageType {
4
4
  }
5
5
  export declare enum RoleType {
6
6
  Assistant = "assistant",
7
+ Cite = "cite",
7
8
  System = "system",
8
9
  User = "user"
9
10
  }
@@ -2,6 +2,7 @@ import { RoleType, MessageStatus } from './enum';
2
2
  export interface IMessage extends IChatHistory {
3
3
  status?: MessageStatus;
4
4
  time?: number | string;
5
+ cite?: string;
5
6
  }
6
7
  export interface IPrompt {
7
8
  id: number | string;
@@ -31,3 +32,12 @@ export interface IModel {
31
32
  id: string;
32
33
  name: string;
33
34
  }
35
+ export interface IShortCut {
36
+ label: string;
37
+ prompt: string;
38
+ }
39
+ export interface ISendData {
40
+ content: string;
41
+ cite?: string;
42
+ prompt?: string;
43
+ }