@difizen/libro-ai-native 0.3.3 → 1.0.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/es/ai-inline-completions/inline-completion-contribution.js +1 -1
- package/es/ai-inline-completions/inline-completion-provider.d.ts +5 -5
- package/es/ai-inline-completions/inline-completion-provider.d.ts.map +1 -1
- package/es/ai-inline-completions/inline-completion-provider.js +3 -3
- package/es/ai-inline-completions/inline-completion-request.d.ts +5 -5
- package/es/ai-inline-completions/inline-completion-request.d.ts.map +1 -1
- package/es/ai-inline-completions/inline-completion-request.js +6 -6
- package/es/ai-inline-completions/module.d.ts +1 -1
- package/es/ai-inline-completions/module.d.ts.map +1 -1
- package/es/ai-inline-completions/module.js +3 -3
- package/es/ai-inline-completions/utils.d.ts +3 -3
- package/es/ai-inline-completions/utils.d.ts.map +1 -1
- package/es/ai-native-code-block.js +4 -2
- package/es/ai-native-command-contribution.d.ts +3 -3
- package/es/ai-native-command-contribution.d.ts.map +1 -1
- package/es/ai-native-command-contribution.js +4 -4
- package/es/ai-native-command.d.ts +1 -1
- package/es/ai-native-command.d.ts.map +1 -1
- package/es/ai-native-for-cell-view.d.ts +2 -2
- package/es/ai-native-for-cell-view.d.ts.map +1 -1
- package/es/ai-native-for-cell-view.js +7 -7
- package/es/ai-native-output-top.js +1 -1
- package/es/ai-native-service.d.ts +1 -7
- package/es/ai-native-service.d.ts.map +1 -1
- package/es/ai-native-service.js +9 -10
- package/es/ai-side-toolbar-selector.js +2 -2
- package/es/chat-slot-contribution.d.ts +1 -1
- package/es/chat-slot-contribution.d.ts.map +1 -1
- package/es/chat-slot-contribution.js +2 -2
- package/es/chat-view.d.ts +2 -2
- package/es/chat-view.d.ts.map +1 -1
- package/es/chat-view.js +1 -1
- package/es/error-output-model.js +3 -3
- package/es/libro-ai-msg-item-model.js +1 -1
- package/es/libro-ai-native-chat-service.d.ts.map +1 -1
- package/es/libro-ai-native-chat-service.js +1 -1
- package/es/libro-ai-native-chat-view.js +1 -1
- package/es/libro-ai-native-color-registry.d.ts +2 -2
- package/es/libro-ai-native-color-registry.d.ts.map +1 -1
- package/es/libro-ai-native-color-registry.js +2 -2
- package/es/module.d.ts +1 -1
- package/es/module.d.ts.map +1 -1
- package/es/module.js +1 -1
- package/package.json +4 -5
- package/src/ai-inline-completions/inline-completion-contribution.ts +1 -1
- package/src/ai-inline-completions/inline-completion-provider.ts +7 -7
- package/src/ai-inline-completions/inline-completion-request.ts +5 -5
- package/src/ai-inline-completions/module.ts +3 -3
- package/src/ai-inline-completions/utils.ts +4 -4
- package/src/ai-native-code-block.tsx +3 -3
- package/src/ai-native-command-contribution.tsx +5 -5
- package/src/ai-native-command.ts +1 -1
- package/src/ai-native-for-cell-view.tsx +8 -8
- package/src/ai-native-output-top.tsx +1 -1
- package/src/ai-native-service.ts +13 -7
- package/src/ai-side-toolbar-selector.tsx +2 -2
- package/src/chat-slot-contribution.ts +2 -2
- package/src/chat-view.tsx +2 -2
- package/src/error-output-model.tsx +3 -3
- package/src/libro-ai-msg-item-model.ts +1 -1
- package/src/libro-ai-native-chat-service.ts +1 -1
- package/src/libro-ai-native-chat-view.tsx +1 -1
- package/src/libro-ai-native-color-registry.ts +3 -3
- package/src/module.ts +1 -1
|
@@ -10,7 +10,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
10
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
11
|
import { InlineCompletionContribution } from '@difizen/libro-code-editor';
|
|
12
12
|
import { Sequencer } from '@difizen/libro-code-editor';
|
|
13
|
-
import { inject, singleton } from '@difizen/
|
|
13
|
+
import { inject, singleton } from '@difizen/libro-common/app';
|
|
14
14
|
import { AICompletionProvider } from "./inline-completion-provider.js";
|
|
15
15
|
export var AICompletionContribution = (_dec = singleton({
|
|
16
16
|
contrib: [InlineCompletionContribution]
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { InlineCompletionProvider,
|
|
2
|
-
import {
|
|
1
|
+
import type { InlineCompletionProvider, EditorCancellationToken, IIntelligentCompletionsResult, ICompletionContext } from '@difizen/libro-code-editor';
|
|
2
|
+
import { AiCompletionRequest } from './inline-completion-request.js';
|
|
3
3
|
declare class ReqStack {
|
|
4
|
-
queue:
|
|
4
|
+
queue: AiCompletionRequest[];
|
|
5
5
|
constructor();
|
|
6
|
-
addReq(reqRequest:
|
|
6
|
+
addReq(reqRequest: AiCompletionRequest): void;
|
|
7
7
|
runReq(): Promise<import("@difizen/libro-code-editor").InlineCompletion[]> | undefined;
|
|
8
8
|
cancelReq(): void;
|
|
9
9
|
}
|
|
@@ -12,7 +12,7 @@ export declare class AICompletionProvider implements InlineCompletionProvider {
|
|
|
12
12
|
inlineComletionsDebounceTime: number;
|
|
13
13
|
constructor();
|
|
14
14
|
mount(): void;
|
|
15
|
-
provideInlineCompletionItems(context: ICompletionContext, token:
|
|
15
|
+
provideInlineCompletionItems(context: ICompletionContext, token: EditorCancellationToken): Promise<IIntelligentCompletionsResult<any> | undefined>;
|
|
16
16
|
cancelRequest(): void;
|
|
17
17
|
}
|
|
18
18
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-completion-provider.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/inline-completion-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,
|
|
1
|
+
{"version":3,"file":"inline-completion-provider.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/inline-completion-provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,6BAA6B,EAC7B,kBAAkB,EACnB,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAcrE,cAAM,QAAQ;IACZ,KAAK,EAAE,mBAAmB,EAAE,CAAC;;IAI7B,MAAM,CAAC,UAAU,EAAE,mBAAmB;IAGtC,MAAM;IAWN,SAAS;CASV;AAED,qBACa,oBAAqB,YAAW,wBAAwB;IACnE,QAAQ,EAAE,QAAQ,CAAC;IACnB,4BAA4B,EAAE,MAAM,CAAC;;IAM9B,KAAK,IAAI,IAAI;IAKd,4BAA4B,CAChC,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,uBAAuB;IA4BhC,aAAa;CAKd"}
|
|
@@ -8,8 +8,8 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
8
8
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
9
9
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
10
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
-
import { singleton } from '@difizen/
|
|
12
|
-
import {
|
|
11
|
+
import { singleton } from '@difizen/libro-common/app';
|
|
12
|
+
import { AiCompletionRequest } from "./inline-completion-request.js";
|
|
13
13
|
import { raceCancellation, sleep } from "./utils.js";
|
|
14
14
|
|
|
15
15
|
// 缓存最近一次的补全结果
|
|
@@ -76,7 +76,7 @@ export var AICompletionProvider = (_dec = singleton(), _dec(_class = /*#__PURE__
|
|
|
76
76
|
this.cancelRequest();
|
|
77
77
|
|
|
78
78
|
// 放入队列
|
|
79
|
-
requestImp = new
|
|
79
|
+
requestImp = new AiCompletionRequest(context, token);
|
|
80
80
|
this.reqStack.addReq(requestImp);
|
|
81
81
|
_context.next = 5;
|
|
82
82
|
return raceCancellation(sleep(this.inlineComletionsDebounceTime), token);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { IAICompletionOption, ICompletionContext, IIntelligentCompletionsResult,
|
|
2
|
-
export declare class
|
|
1
|
+
import type { IAICompletionOption, ICompletionContext, IIntelligentCompletionsResult, EditorCancellationToken } from '@difizen/libro-code-editor';
|
|
2
|
+
export declare class AiCompletionRequest {
|
|
3
3
|
context: ICompletionContext;
|
|
4
|
-
token:
|
|
4
|
+
token: EditorCancellationToken;
|
|
5
5
|
isCancelFlag: boolean;
|
|
6
6
|
id: string;
|
|
7
|
-
constructor(context: ICompletionContext, token:
|
|
8
|
-
protected constructRequestContext(context: ICompletionContext, token:
|
|
7
|
+
constructor(context: ICompletionContext, token: EditorCancellationToken);
|
|
8
|
+
protected constructRequestContext(context: ICompletionContext, token: EditorCancellationToken): IAICompletionOption;
|
|
9
9
|
cancelRequest(): void;
|
|
10
10
|
run(): Promise<import("@difizen/libro-code-editor").InlineCompletion[]>;
|
|
11
11
|
protected complete(data: IAICompletionOption): Promise<IIntelligentCompletionsResult | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-completion-request.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/inline-completion-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,6BAA6B,EAC7B,
|
|
1
|
+
{"version":3,"file":"inline-completion-request.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/inline-completion-request.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,6BAA6B,EAC7B,uBAAuB,EACxB,MAAM,4BAA4B,CAAC;AAMpC,qBACa,mBAAmB;IAKrB,OAAO,EAAE,kBAAkB;IAC3B,KAAK,EAAE,uBAAuB;IALvC,YAAY,EAAE,OAAO,CAAC;IACtB,EAAE,EAAE,MAAM,CAAC;gBAGF,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,uBAAuB;IAOvC,SAAS,CAAC,uBAAuB,CAC/B,OAAO,EAAE,kBAAkB,EAC3B,KAAK,EAAE,uBAAuB,GAC7B,mBAAmB;IAgBtB,aAAa;IAKP,GAAG;cAoBO,QAAQ,CACtB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,6BAA6B,GAAG,SAAS,CAAC;CA6BtD"}
|
|
@@ -14,12 +14,12 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
14
14
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
16
16
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
-
import { transient } from '@difizen/
|
|
17
|
+
import { transient } from '@difizen/libro-common/app';
|
|
18
18
|
import { v4 } from 'uuid';
|
|
19
19
|
import { generateInstructionsPrompt } from "./Prompt/instruction.js";
|
|
20
|
-
export var
|
|
21
|
-
function
|
|
22
|
-
_classCallCheck(this,
|
|
20
|
+
export var AiCompletionRequest = (_dec = transient(), _dec(_class = /*#__PURE__*/function () {
|
|
21
|
+
function AiCompletionRequest(context, token) {
|
|
22
|
+
_classCallCheck(this, AiCompletionRequest);
|
|
23
23
|
this.context = context;
|
|
24
24
|
this.token = token;
|
|
25
25
|
this.isCancelFlag = false;
|
|
@@ -27,7 +27,7 @@ export var CompletionRequest = (_dec = transient(), _dec(_class = /*#__PURE__*/f
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// 拼接上下文信息
|
|
30
|
-
_createClass(
|
|
30
|
+
_createClass(AiCompletionRequest, [{
|
|
31
31
|
key: "constructRequestContext",
|
|
32
32
|
value: function constructRequestContext(context, token) {
|
|
33
33
|
// const prompt = lineBasedPromptProcessor.processPrefix(context.prefix);
|
|
@@ -145,5 +145,5 @@ export var CompletionRequest = (_dec = transient(), _dec(_class = /*#__PURE__*/f
|
|
|
145
145
|
return complete;
|
|
146
146
|
}()
|
|
147
147
|
}]);
|
|
148
|
-
return
|
|
148
|
+
return AiCompletionRequest;
|
|
149
149
|
}()) || _class);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAMvD,eAAO,MAAM,uBAAuB,YAEP,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CodeEditorModule } from '@difizen/libro-code-editor';
|
|
2
|
-
import { ManaModule } from '@difizen/
|
|
2
|
+
import { ManaModule } from '@difizen/libro-common/app';
|
|
3
3
|
import { AICompletionContribution } from "./inline-completion-contribution.js";
|
|
4
4
|
import { AICompletionProvider } from "./inline-completion-provider.js";
|
|
5
|
-
import {
|
|
6
|
-
export var LibroAICompletionModule = ManaModule.create().register(
|
|
5
|
+
import { AiCompletionRequest } from "./inline-completion-request.js";
|
|
6
|
+
export var LibroAICompletionModule = ManaModule.create().register(AiCompletionRequest, AICompletionProvider, AICompletionContribution).dependOn(CodeEditorModule);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorCancellationToken } from '@difizen/libro-code-editor';
|
|
2
2
|
declare function processPrefix(prompt: string): string;
|
|
3
3
|
declare function processSuffix(suffix: string): string;
|
|
4
4
|
export declare const lineBasedPromptProcessor: {
|
|
@@ -6,7 +6,7 @@ export declare const lineBasedPromptProcessor: {
|
|
|
6
6
|
processSuffix: typeof processSuffix;
|
|
7
7
|
};
|
|
8
8
|
export declare function sleep(time: number): Promise<void>;
|
|
9
|
-
export declare function raceCancellation<T>(promise: Promise<T>, token:
|
|
10
|
-
export declare function raceCancellation<T>(promise: Promise<T>, token:
|
|
9
|
+
export declare function raceCancellation<T>(promise: Promise<T>, token: EditorCancellationToken): Promise<T | undefined>;
|
|
10
|
+
export declare function raceCancellation<T>(promise: Promise<T>, token: EditorCancellationToken, defaultValue: T): Promise<T>;
|
|
11
11
|
export {};
|
|
12
12
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/ai-inline-completions/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAK1E,iBAAS,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAW7C;AAGD,iBAAS,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAS7C;AAED,eAAO,MAAM,wBAAwB;;;CAGpC,CAAC;AAEF,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,iBAEjC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,uBAAuB,GAC7B,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;AAC1B,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,uBAAuB,EAC9B,YAAY,EAAE,CAAC,GACd,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -9,9 +9,9 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
9
9
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
10
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
11
|
import { CopyOutlined } from '@ant-design/icons';
|
|
12
|
+
import { useInject, ViewInstance } from '@difizen/libro-common/app';
|
|
13
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
12
14
|
import { LibroCodeCellView } from '@difizen/libro-jupyter';
|
|
13
|
-
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
14
|
-
import { l10n } from '@difizen/mana-l10n';
|
|
15
15
|
import { Button, message } from 'antd';
|
|
16
16
|
import copy from 'copy-to-clipboard';
|
|
17
17
|
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
@@ -19,6 +19,8 @@ import { v4 } from 'uuid';
|
|
|
19
19
|
import "./index.less";
|
|
20
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
21
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
22
|
+
// import type { LibroAiNativeChatView } from './libro-ai-native-chat-view.js';
|
|
23
|
+
|
|
22
24
|
export var CodeBlockInCell = function CodeBlockInCell(props) {
|
|
23
25
|
var className = props.className,
|
|
24
26
|
children = props.children;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import type { CommandRegistry, ToolbarRegistry } from '@difizen/libro-common/app';
|
|
2
|
+
import { CommandContribution } from '@difizen/libro-common/app';
|
|
3
|
+
import { ToolbarContribution, ViewManager } from '@difizen/libro-common/app';
|
|
1
4
|
import { LibroCommandRegister, LibroSlotManager } from '@difizen/libro-jupyter';
|
|
2
|
-
import type { CommandRegistry, ToolbarRegistry } from '@difizen/mana-app';
|
|
3
|
-
import { CommandContribution } from '@difizen/mana-app';
|
|
4
|
-
import { ToolbarContribution, ViewManager } from '@difizen/mana-app';
|
|
5
5
|
import { LibroAINativeService } from './ai-native-service.js';
|
|
6
6
|
import { LibroAIChatSlotContribution } from './chat-slot-contribution.js';
|
|
7
7
|
export declare class LibroAINativeCommandContribution implements ToolbarContribution, CommandContribution {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-native-command-contribution.d.ts","sourceRoot":"","sources":["../src/ai-native-command-contribution.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"ai-native-command-contribution.d.ts","sourceRoot":"","sources":["../src/ai-native-command-contribution.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAElF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAa,mBAAmB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExF,OAAO,EACL,oBAAoB,EACpB,gBAAgB,EAKjB,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,OAAO,EAAE,2BAA2B,EAAE,MAAM,6BAA6B,CAAC;AAI1E,qBACa,gCACX,YAAW,mBAAmB,EAAE,mBAAmB;IAErB,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,oBAAoB,CAAC;IAEpF,2BAA2B,EAAE,2BAA2B,CAAC;IAC/B,gBAAgB,EAAE,gBAAgB,CAAC;IAC/B,oBAAoB,EAAE,oBAAoB,CAAC;IACpD,WAAW,EAAE,WAAW,CAAC;IAE9C,oBAAoB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI;IAuBrD,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;CAmMjD"}
|
|
@@ -12,11 +12,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
|
12
12
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
13
13
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
14
14
|
import { CommentOutlined } from '@ant-design/icons';
|
|
15
|
+
import { inject } from '@difizen/libro-common/app';
|
|
16
|
+
import { CommandContribution } from '@difizen/libro-common/app';
|
|
17
|
+
import { singleton, ToolbarContribution, ViewManager } from '@difizen/libro-common/app';
|
|
18
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
15
19
|
import { LibroCommandRegister, LibroSlotManager, LibroSlotView, LibroToolbarArea, LibroCellView, LibroView } from '@difizen/libro-jupyter';
|
|
16
|
-
import { inject } from '@difizen/mana-app';
|
|
17
|
-
import { CommandContribution } from '@difizen/mana-app';
|
|
18
|
-
import { singleton, ToolbarContribution, ViewManager } from '@difizen/mana-app';
|
|
19
|
-
import { l10n } from '@difizen/mana-l10n';
|
|
20
20
|
import { AINativeCommands } from "./ai-native-command.js";
|
|
21
21
|
import { LibroAINativeService } from "./ai-native-service.js";
|
|
22
22
|
import { AIToolbarSelector } from "./ai-side-toolbar-selector.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-native-command.d.ts","sourceRoot":"","sources":["../src/ai-native-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ai-native-command.d.ts","sourceRoot":"","sources":["../src/ai-native-command.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAEzD,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAoB3E,CAAC"}
|
|
@@ -2,8 +2,8 @@ import type { CellView } from '@difizen/libro-jupyter';
|
|
|
2
2
|
import type { IChatMessage } from '@difizen/magent-chat';
|
|
3
3
|
import type { ToAutoFactory } from '@difizen/magent-core';
|
|
4
4
|
import { Fetcher } from '@difizen/magent-core';
|
|
5
|
-
import type { ViewComponent } from '@difizen/
|
|
6
|
-
import { BaseView } from '@difizen/
|
|
5
|
+
import type { ViewComponent } from '@difizen/libro-common/app';
|
|
6
|
+
import { BaseView } from '@difizen/libro-common/app';
|
|
7
7
|
import 'katex/dist/katex.min.css';
|
|
8
8
|
import { LibroAIChatMessageItemModel } from './libro-ai-msg-item-model.js';
|
|
9
9
|
import type { IAINativeForCellViewOption } from './protocol.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-native-for-cell-view.d.ts","sourceRoot":"","sources":["../src/ai-native-for-cell-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ai-native-for-cell-view.d.ts","sourceRoot":"","sources":["../src/ai-native-for-cell-view.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAM/D,OAAO,EAAE,QAAQ,EAAmB,MAAM,2BAA2B,CAAC;AAStE,OAAO,0BAA0B,CAAC;AAKlC,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAC3E,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAGhE,wBAAgB,0BAA0B,mDAiDzC;AAED,qBAEa,wBAAyB,SAAQ,QAAQ;IAC3C,IAAI,EAAE,aAAa,CAA8B;IACzC,OAAO,EAAE,OAAO,CAAC;IAClC,IAAI,EAAE,QAAQ,CAAC;IAEf,6BAA6B,EAAE,aAAa,CAAC,OAAO,2BAA2B,CAAC,CAAC;IAEjF,2BAA2B,CAAC,EAAE,2BAA2B,CAAC;IAG1D,MAAM,UAAS;gBACiB,OAAO,EAAE,0BAA0B;IAMnE,UAAU,WAAkB,YAAY,mBA+DtC;CACH"}
|
|
@@ -24,13 +24,13 @@ import { ChatComponents } from '@difizen/magent-chat';
|
|
|
24
24
|
import { ChatEvent } from '@difizen/magent-chat';
|
|
25
25
|
import { Fetcher } from '@difizen/magent-core';
|
|
26
26
|
import { toAutoFactory } from '@difizen/magent-core';
|
|
27
|
-
import { ViewOption } from '@difizen/
|
|
28
|
-
import { prop } from '@difizen/
|
|
29
|
-
import { useObserve } from '@difizen/
|
|
30
|
-
import { useInject, ViewInstance } from '@difizen/
|
|
31
|
-
import { inject } from '@difizen/
|
|
32
|
-
import { BaseView, transient, view } from '@difizen/
|
|
33
|
-
import { l10n } from '@difizen/
|
|
27
|
+
import { ViewOption } from '@difizen/libro-common/app';
|
|
28
|
+
import { prop } from '@difizen/libro-common/app';
|
|
29
|
+
import { useObserve } from '@difizen/libro-common/app';
|
|
30
|
+
import { useInject, ViewInstance } from '@difizen/libro-common/app';
|
|
31
|
+
import { inject } from '@difizen/libro-common/app';
|
|
32
|
+
import { BaseView, transient, view } from '@difizen/libro-common/app';
|
|
33
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
34
34
|
import { Button } from 'antd';
|
|
35
35
|
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
|
36
36
|
import rehypeKatex from 'rehype-katex';
|
|
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import { useInject, ViewManager, ViewRender } from '@difizen/
|
|
7
|
+
import { useInject, ViewManager, ViewRender } from '@difizen/libro-common/app';
|
|
8
8
|
import { useEffect, useState } from 'react';
|
|
9
9
|
import "./index.less";
|
|
10
10
|
import { LibroAINativeService } from "./ai-native-service.js";
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
+
import { ViewManager } from '@difizen/libro-common/app';
|
|
1
2
|
import type { CellView } from '@difizen/libro-jupyter';
|
|
2
|
-
import { ViewManager } from '@difizen/mana-app';
|
|
3
3
|
import { LibroAINativeForCellView } from './ai-native-for-cell-view.js';
|
|
4
|
-
import type { LibroChatView } from './chat-view.js';
|
|
5
|
-
import type { LibroAiNativeChatView } from './libro-ai-native-chat-view.js';
|
|
6
4
|
export declare class LibroAINativeService {
|
|
7
5
|
showSideToolbar: boolean;
|
|
8
|
-
chatViewMap: Map<string, LibroChatView>;
|
|
9
|
-
showChatMap: Map<string, boolean>;
|
|
10
|
-
cellAIChatMap: Map<string, boolean>;
|
|
11
6
|
viewManager: ViewManager;
|
|
12
7
|
libroAINativeForCellViewMap: Map<string, LibroAINativeForCellView>;
|
|
13
|
-
libroAINativeChatViewMap: Map<string, LibroAiNativeChatView>;
|
|
14
8
|
getOrCreateLibroAINativeForCellView(id: string, cell: CellView): Promise<LibroAINativeForCellView>;
|
|
15
9
|
}
|
|
16
10
|
//# sourceMappingURL=ai-native-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-native-service.d.ts","sourceRoot":"","sources":["../src/ai-native-service.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"ai-native-service.d.ts","sourceRoot":"","sources":["../src/ai-native-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,WAAW,EACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAIxE,qBACa,oBAAoB;IAE/B,eAAe,UAAS;IASxB,WAAW,EAAE,WAAW,CAAC;IAEzB,2BAA2B,EAAE,GAAG,CAAC,MAAM,EAAE,wBAAwB,CAAC,CAAa;IAIzE,mCAAmC,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ;CAarE"}
|
package/es/ai-native-service.js
CHANGED
|
@@ -11,23 +11,23 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
11
11
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
12
12
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
13
13
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
14
|
-
import { getOrigin, inject, prop, singleton, ViewManager } from '@difizen/
|
|
14
|
+
import { getOrigin, inject, prop, singleton, ViewManager } from '@difizen/libro-common/app';
|
|
15
15
|
import { LibroAINativeForCellView } from "./ai-native-for-cell-view.js";
|
|
16
16
|
export var LibroAINativeService = (_dec = singleton(), _dec2 = prop(), _dec3 = inject(ViewManager), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
17
17
|
function LibroAINativeService() {
|
|
18
18
|
_classCallCheck(this, LibroAINativeService);
|
|
19
19
|
_initializerDefineProperty(this, "showSideToolbar", _descriptor, this);
|
|
20
|
-
|
|
21
|
-
//用于控制是否显示当前 libro 层级的 chat 面板
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// chatViewMap: Map<string, LibroChatView> = new Map();
|
|
21
|
+
// //用于控制是否显示当前 libro 层级的 chat 面板
|
|
22
|
+
// showChatMap: Map<string, boolean> = new Map();
|
|
23
|
+
// cellAIChatMap: Map<string, boolean> = new Map();
|
|
24
24
|
_initializerDefineProperty(this, "viewManager", _descriptor2, this);
|
|
25
25
|
this.libroAINativeForCellViewMap = new Map();
|
|
26
|
-
this.libroAINativeChatViewMap = new Map();
|
|
27
26
|
}
|
|
28
27
|
_createClass(LibroAINativeService, [{
|
|
29
28
|
key: "getOrCreateLibroAINativeForCellView",
|
|
30
|
-
value:
|
|
29
|
+
value: // libroAINativeChatViewMap: Map<string, LibroAiNativeChatView> = new Map();
|
|
30
|
+
function () {
|
|
31
31
|
var _getOrCreateLibroAINativeForCellView = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(id, cell) {
|
|
32
32
|
var libroAINativeForCellView;
|
|
33
33
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
@@ -47,10 +47,9 @@ export var LibroAINativeService = (_dec = singleton(), _dec2 = prop(), _dec3 = i
|
|
|
47
47
|
});
|
|
48
48
|
case 7:
|
|
49
49
|
libroAINativeForCellView = _context.sent;
|
|
50
|
-
|
|
51
|
-
case 9:
|
|
50
|
+
case 8:
|
|
52
51
|
return _context.abrupt("return", libroAINativeForCellView);
|
|
53
|
-
case
|
|
52
|
+
case 9:
|
|
54
53
|
case "end":
|
|
55
54
|
return _context.stop();
|
|
56
55
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LibroSideToolbarMenu } from '@difizen/libro-jupyter';
|
|
2
|
-
import { useInject } from '@difizen/
|
|
3
|
-
import { l10n } from '@difizen/
|
|
2
|
+
import { useInject } from '@difizen/libro-common/app';
|
|
3
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
4
4
|
import { Popover } from 'antd';
|
|
5
5
|
import { AINativeCommands } from "./ai-native-command.js";
|
|
6
6
|
import { LibroAINativeService } from "./ai-native-service.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LibroExtensionSlotFactory, LibroSlot } from '@difizen/libro-jupyter';
|
|
2
2
|
import { LibroExtensionSlotContribution } from '@difizen/libro-jupyter';
|
|
3
|
-
import { ViewManager } from '@difizen/
|
|
3
|
+
import { ViewManager } from '@difizen/libro-common/app';
|
|
4
4
|
import { LibroAINativeService } from './ai-native-service.js';
|
|
5
5
|
export declare class LibroAIChatSlotContribution implements LibroExtensionSlotContribution {
|
|
6
6
|
viewManager: ViewManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-slot-contribution.d.ts","sourceRoot":"","sources":["../src/chat-slot-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,yBAAyB,EACzB,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"chat-slot-contribution.d.ts","sourceRoot":"","sources":["../src/chat-slot-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,yBAAyB,EACzB,SAAS,EACV,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,qBACa,2BAA4B,YAAW,8BAA8B;IAC3D,WAAW,EAAE,WAAW,CAAC;IAChB,oBAAoB,EAAE,oBAAoB,CAAC;IAEzE,SAAgB,IAAI,EAAE,SAAS,CAAW;IAE1C,OAAO,EAAE,yBAAyB,CAWhC;IACF,cAAc;;;MAGZ;CACH"}
|
|
@@ -12,8 +12,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
|
|
|
12
12
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
13
13
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
14
14
|
import { LibroExtensionSlotContribution } from '@difizen/libro-jupyter';
|
|
15
|
-
import { ViewManager } from '@difizen/
|
|
16
|
-
import { inject, singleton } from '@difizen/
|
|
15
|
+
import { ViewManager } from '@difizen/libro-common/app';
|
|
16
|
+
import { inject, singleton } from '@difizen/libro-common/app';
|
|
17
17
|
import { LibroAINativeService } from "./ai-native-service.js";
|
|
18
18
|
import { LibroChatView } from "./chat-view.js";
|
|
19
19
|
export var LibroAIChatSlotContribution = (_dec = singleton({
|
package/es/chat-view.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DisplayView, LibroView } from '@difizen/libro-jupyter';
|
|
2
|
-
import type { ConfigurationService } from '@difizen/
|
|
3
|
-
import { BaseView, ViewManager } from '@difizen/
|
|
2
|
+
import type { ConfigurationService } from '@difizen/libro-common/app';
|
|
3
|
+
import { BaseView, ViewManager } from '@difizen/libro-common/app';
|
|
4
4
|
import 'katex/dist/katex.min.css';
|
|
5
5
|
import { LibroAINativeService } from './ai-native-service.js';
|
|
6
6
|
import { LibroAiNativeChatView } from './libro-ai-native-chat-view.js';
|
package/es/chat-view.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat-view.d.ts","sourceRoot":"","sources":["../src/chat-view.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"chat-view.d.ts","sourceRoot":"","sources":["../src/chat-view.tsx"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EACL,QAAQ,EAKR,WAAW,EAIZ,MAAM,2BAA2B,CAAC;AAEnC,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAG5D,eAAO,MAAM,UAAU,+CA6DtB,CAAC;AAEF,qBAEa,aAAc,SAAQ,QAAS,YAAW,WAAW;IAChE,MAAM,EAAE,SAAS,GAAG,SAAS,CAAa;IAC1C,SAAS,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IAChC,WAAW,EAAE,WAAW,CAAC;IAChB,oBAAoB,EAAE,oBAAoB,CAAC;IAEhE,IAAI,gDAAc;IAG3B,QAAQ,EAAE,qBAAqB,CAAC;IAGhC,SAAS,UAAQ;IAEX,mBAAmB,CAAC,MAAM,EAAE,sBAAsB;CAmCzD"}
|
package/es/chat-view.js
CHANGED
|
@@ -20,7 +20,7 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
20
20
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
21
21
|
import { CloseOutlined } from '@ant-design/icons';
|
|
22
22
|
import { LibroContextKey, LibroSlotManager, LibroSlotView } from '@difizen/libro-jupyter';
|
|
23
|
-
import { BaseView, prop, transient, view, inject, ViewManager, useInject, ViewInstance, ViewRender } from '@difizen/
|
|
23
|
+
import { BaseView, prop, transient, view, inject, ViewManager, useInject, ViewInstance, ViewRender } from '@difizen/libro-common/app';
|
|
24
24
|
import { useRef } from 'react';
|
|
25
25
|
import 'katex/dist/katex.min.css'; // 引入 KaTeX 样式
|
|
26
26
|
|
package/es/error-output-model.js
CHANGED
|
@@ -20,9 +20,9 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
|
20
20
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
21
21
|
import { concatMultilineString } from '@difizen/libro-jupyter';
|
|
22
22
|
import { ErrorOutputModel, defaultSanitizer, RenderMimeRegistry, renderText } from '@difizen/libro-jupyter';
|
|
23
|
-
import { prop, transient } from '@difizen/
|
|
24
|
-
import { getOrigin, useInject, view, ViewInstance } from '@difizen/
|
|
25
|
-
import { l10n } from '@difizen/
|
|
23
|
+
import { prop, transient } from '@difizen/libro-common/app';
|
|
24
|
+
import { getOrigin, useInject, view, ViewInstance } from '@difizen/libro-common/app';
|
|
25
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
26
26
|
import { Button } from 'antd';
|
|
27
27
|
import { forwardRef, createRef, useEffect } from 'react';
|
|
28
28
|
import "./index.less";
|
|
@@ -10,7 +10,7 @@ function _applyDecoratedDescriptor(target, property, decorators, descriptor, con
|
|
|
10
10
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
11
11
|
import { AnswerState, ChatEvent } from '@difizen/magent-chat';
|
|
12
12
|
import { autoFactory, AutoFactoryOption } from '@difizen/magent-core';
|
|
13
|
-
import { inject, prop } from '@difizen/
|
|
13
|
+
import { inject, prop } from '@difizen/libro-common/app';
|
|
14
14
|
export var LibroAIChatMessageItemModel = (_dec = autoFactory(), _dec2 = prop(), _dec3 = prop(), _dec4 = prop(), _dec(_class = (_class2 = /*#__PURE__*/function () {
|
|
15
15
|
function LibroAIChatMessageItemModel(option) {
|
|
16
16
|
_classCallCheck(this, LibroAIChatMessageItemModel);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-ai-native-chat-service.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-chat-service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"libro-ai-native-chat-service.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-chat-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAIzD,OAAO,KAAK,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAGxE,qBACa,wBAAyB,SAAQ,gBAAgB;IACnD,IAAI,WACH,kCAAkC,KACzC,QAAQ,gBAAgB,EAAE,CAAC,CAkB5B;IACO,UAAU,WACT,kCAAkC,0BAClB,gBAAgB,KAAK,IAAI,yBAC1B,UAAU,KAAK,IAAI,mBAgE1C;CACH"}
|
|
@@ -15,9 +15,9 @@ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) ===
|
|
|
15
15
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
16
16
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
17
17
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
18
|
+
import { singleton } from '@difizen/libro-common/app';
|
|
18
19
|
import { ChatEvent } from '@difizen/magent-chat';
|
|
19
20
|
import { LibroChatService } from '@difizen/magent-libro';
|
|
20
|
-
import { singleton } from '@difizen/mana-app';
|
|
21
21
|
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
|
22
22
|
import { stringToReadableStream } from "./utils.js";
|
|
23
23
|
export var LibroAINativeChatService = (_dec = singleton(), _dec(_class = /*#__PURE__*/function (_LibroChatService) {
|
|
@@ -19,7 +19,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
19
19
|
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; }
|
|
20
20
|
function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'transform-class-properties is enabled and runs after the decorators transform.'); }
|
|
21
21
|
import { ChatView, ChatComponents } from '@difizen/magent-chat';
|
|
22
|
-
import { inject, prop, transient, view, ViewOption } from '@difizen/
|
|
22
|
+
import { inject, prop, transient, view, ViewOption } from '@difizen/libro-common/app';
|
|
23
23
|
import rehypeKatex from 'rehype-katex';
|
|
24
24
|
import rehypeRaw from 'rehype-raw';
|
|
25
25
|
import breaks from 'remark-breaks';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ColorRegistry } from '@difizen/
|
|
2
|
-
import { ColorContribution } from '@difizen/
|
|
1
|
+
import type { ColorRegistry } from '@difizen/libro-common/app';
|
|
2
|
+
import { ColorContribution } from '@difizen/libro-common/app';
|
|
3
3
|
export declare class LibroAINativeColorRegistry implements ColorContribution {
|
|
4
4
|
registerColors(colors: ColorRegistry): void;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"libro-ai-native-color-registry.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-color-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"libro-ai-native-color-registry.d.ts","sourceRoot":"","sources":["../src/libro-ai-native-color-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,OAAO,EAAa,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEzE,qBACa,0BAA2B,YAAW,iBAAiB;IAClE,cAAc,CAAC,MAAM,EAAE,aAAa,GAAG,IAAI;CA0B5C"}
|
|
@@ -5,8 +5,8 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
5
5
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
import { Color } from '@difizen/
|
|
9
|
-
import { singleton, ColorContribution } from '@difizen/
|
|
8
|
+
import { Color } from '@difizen/libro-common/app';
|
|
9
|
+
import { singleton, ColorContribution } from '@difizen/libro-common/app';
|
|
10
10
|
export var LibroAINativeColorRegistry = (_dec = singleton({
|
|
11
11
|
contrib: ColorContribution
|
|
12
12
|
}), _dec(_class = /*#__PURE__*/function () {
|
package/es/module.d.ts
CHANGED
package/es/module.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAkBvD,eAAO,MAAM,0BAA0B;;CAEtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,YA2BuC,CAAC"}
|
package/es/module.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CodeEditorModule } from '@difizen/libro-code-editor';
|
|
2
|
+
import { ManaModule } from '@difizen/libro-common/app';
|
|
2
3
|
import { CellOutputTopProvider, ErrorOutputModel } from '@difizen/libro-jupyter';
|
|
3
4
|
import { ChatView } from '@difizen/magent-chat';
|
|
4
5
|
import { LibroChatModule, LibroChatService } from '@difizen/magent-libro';
|
|
5
|
-
import { ManaModule } from '@difizen/mana-app';
|
|
6
6
|
import { LibroAICompletionModule } from "./ai-inline-completions/module.js";
|
|
7
7
|
import { LibroAINativeCommandContribution } from "./ai-native-command-contribution.js";
|
|
8
8
|
import { LibroAINativeForCellView } from "./ai-native-for-cell-view.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-ai-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -33,13 +33,12 @@
|
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@ant-design/icons": "^5.4.0",
|
|
36
|
-
"@difizen/libro-code-editor": "^0.
|
|
37
|
-
"@difizen/libro-jupyter": "^0.
|
|
36
|
+
"@difizen/libro-code-editor": "^1.0.0",
|
|
37
|
+
"@difizen/libro-jupyter": "^1.0.0",
|
|
38
38
|
"@difizen/magent-chat": "^0.1.27",
|
|
39
39
|
"@difizen/magent-core": "^0.1.27",
|
|
40
40
|
"@difizen/magent-libro": "^0.1.27",
|
|
41
|
-
"@difizen/
|
|
42
|
-
"@difizen/mana-l10n": "latest",
|
|
41
|
+
"@difizen/libro-common": "^1.0.0",
|
|
43
42
|
"copy-to-clipboard": "^3.3.3",
|
|
44
43
|
"eventsource-parser": "^1.1.2",
|
|
45
44
|
"katex": "^0.16.10",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { InlineCompletionRegistry } from '@difizen/libro-code-editor';
|
|
2
2
|
import { InlineCompletionContribution } from '@difizen/libro-code-editor';
|
|
3
3
|
import { Sequencer } from '@difizen/libro-code-editor';
|
|
4
|
-
import { inject, singleton } from '@difizen/
|
|
4
|
+
import { inject, singleton } from '@difizen/libro-common/app';
|
|
5
5
|
|
|
6
6
|
import { AICompletionProvider } from './inline-completion-provider.js';
|
|
7
7
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
InlineCompletionProvider,
|
|
3
|
-
|
|
3
|
+
EditorCancellationToken,
|
|
4
4
|
IIntelligentCompletionsResult,
|
|
5
5
|
ICompletionContext,
|
|
6
6
|
} from '@difizen/libro-code-editor';
|
|
7
|
-
import { singleton } from '@difizen/
|
|
7
|
+
import { singleton } from '@difizen/libro-common/app';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { AiCompletionRequest } from './inline-completion-request.js';
|
|
10
10
|
import { raceCancellation, sleep } from './utils.js';
|
|
11
11
|
|
|
12
12
|
// 缓存最近一次的补全结果
|
|
@@ -21,11 +21,11 @@ const inlineCompletionCache: {
|
|
|
21
21
|
};
|
|
22
22
|
|
|
23
23
|
class ReqStack {
|
|
24
|
-
queue:
|
|
24
|
+
queue: AiCompletionRequest[];
|
|
25
25
|
constructor() {
|
|
26
26
|
this.queue = [];
|
|
27
27
|
}
|
|
28
|
-
addReq(reqRequest:
|
|
28
|
+
addReq(reqRequest: AiCompletionRequest) {
|
|
29
29
|
this.queue.push(reqRequest);
|
|
30
30
|
}
|
|
31
31
|
runReq() {
|
|
@@ -66,12 +66,12 @@ export class AICompletionProvider implements InlineCompletionProvider {
|
|
|
66
66
|
|
|
67
67
|
async provideInlineCompletionItems(
|
|
68
68
|
context: ICompletionContext,
|
|
69
|
-
token:
|
|
69
|
+
token: EditorCancellationToken,
|
|
70
70
|
) {
|
|
71
71
|
this.cancelRequest();
|
|
72
72
|
|
|
73
73
|
// 放入队列
|
|
74
|
-
const requestImp = new
|
|
74
|
+
const requestImp = new AiCompletionRequest(context, token);
|
|
75
75
|
this.reqStack.addReq(requestImp);
|
|
76
76
|
|
|
77
77
|
await raceCancellation(sleep(this.inlineComletionsDebounceTime), token);
|
|
@@ -2,21 +2,21 @@ import type {
|
|
|
2
2
|
IAICompletionOption,
|
|
3
3
|
ICompletionContext,
|
|
4
4
|
IIntelligentCompletionsResult,
|
|
5
|
-
|
|
5
|
+
EditorCancellationToken,
|
|
6
6
|
} from '@difizen/libro-code-editor';
|
|
7
|
-
import { transient } from '@difizen/
|
|
7
|
+
import { transient } from '@difizen/libro-common/app';
|
|
8
8
|
import { v4 } from 'uuid';
|
|
9
9
|
|
|
10
10
|
import { generateInstructionsPrompt } from './Prompt/instruction.js';
|
|
11
11
|
|
|
12
12
|
@transient()
|
|
13
|
-
export class
|
|
13
|
+
export class AiCompletionRequest {
|
|
14
14
|
isCancelFlag: boolean;
|
|
15
15
|
id: string;
|
|
16
16
|
|
|
17
17
|
constructor(
|
|
18
18
|
public context: ICompletionContext,
|
|
19
|
-
public token:
|
|
19
|
+
public token: EditorCancellationToken,
|
|
20
20
|
) {
|
|
21
21
|
this.isCancelFlag = false;
|
|
22
22
|
this.id = v4();
|
|
@@ -25,7 +25,7 @@ export class CompletionRequest {
|
|
|
25
25
|
// 拼接上下文信息
|
|
26
26
|
protected constructRequestContext(
|
|
27
27
|
context: ICompletionContext,
|
|
28
|
-
token:
|
|
28
|
+
token: EditorCancellationToken,
|
|
29
29
|
): IAICompletionOption {
|
|
30
30
|
// const prompt = lineBasedPromptProcessor.processPrefix(context.prefix);
|
|
31
31
|
// const suffix = lineBasedPromptProcessor.processSuffix(context.suffix);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { CodeEditorModule } from '@difizen/libro-code-editor';
|
|
2
|
-
import { ManaModule } from '@difizen/
|
|
2
|
+
import { ManaModule } from '@difizen/libro-common/app';
|
|
3
3
|
|
|
4
4
|
import { AICompletionContribution } from './inline-completion-contribution.js';
|
|
5
5
|
import { AICompletionProvider } from './inline-completion-provider.js';
|
|
6
|
-
import {
|
|
6
|
+
import { AiCompletionRequest } from './inline-completion-request.js';
|
|
7
7
|
|
|
8
8
|
export const LibroAICompletionModule = ManaModule.create()
|
|
9
|
-
.register(
|
|
9
|
+
.register(AiCompletionRequest, AICompletionProvider, AICompletionContribution)
|
|
10
10
|
.dependOn(CodeEditorModule);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EditorCancellationToken } from '@difizen/libro-code-editor';
|
|
2
2
|
|
|
3
3
|
import { lineBasedCompletionModelConfigs } from './contant.js';
|
|
4
4
|
|
|
@@ -39,16 +39,16 @@ export function sleep(time: number) {
|
|
|
39
39
|
|
|
40
40
|
export function raceCancellation<T>(
|
|
41
41
|
promise: Promise<T>,
|
|
42
|
-
token:
|
|
42
|
+
token: EditorCancellationToken,
|
|
43
43
|
): Promise<T | undefined>;
|
|
44
44
|
export function raceCancellation<T>(
|
|
45
45
|
promise: Promise<T>,
|
|
46
|
-
token:
|
|
46
|
+
token: EditorCancellationToken,
|
|
47
47
|
defaultValue: T,
|
|
48
48
|
): Promise<T>;
|
|
49
49
|
export function raceCancellation<T>(
|
|
50
50
|
promise: Promise<T>,
|
|
51
|
-
token:
|
|
51
|
+
token: EditorCancellationToken,
|
|
52
52
|
defaultValue?: T,
|
|
53
53
|
): Promise<T | undefined> {
|
|
54
54
|
return Promise.race([
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CopyOutlined } from '@ant-design/icons';
|
|
2
|
+
import { useInject, ViewInstance } from '@difizen/libro-common/app';
|
|
3
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
2
4
|
import { LibroCodeCellView } from '@difizen/libro-jupyter';
|
|
3
|
-
import { useInject, ViewInstance } from '@difizen/mana-app';
|
|
4
|
-
import { l10n } from '@difizen/mana-l10n';
|
|
5
5
|
import { Button, message } from 'antd';
|
|
6
6
|
import copy from 'copy-to-clipboard';
|
|
7
7
|
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
|
|
@@ -9,7 +9,7 @@ import { v4 } from 'uuid';
|
|
|
9
9
|
|
|
10
10
|
import './index.less';
|
|
11
11
|
import type { LibroAINativeForCellView } from './ai-native-for-cell-view.js';
|
|
12
|
-
import type { LibroAiNativeChatView } from './libro-ai-native-chat-view.js';
|
|
12
|
+
// import type { LibroAiNativeChatView } from './libro-ai-native-chat-view.js';
|
|
13
13
|
|
|
14
14
|
export const CodeBlockInCell = (props: any) => {
|
|
15
15
|
const { className, children } = props;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
import { CommentOutlined } from '@ant-design/icons';
|
|
2
|
+
import type { CommandRegistry, ToolbarRegistry } from '@difizen/libro-common/app';
|
|
3
|
+
import { inject } from '@difizen/libro-common/app';
|
|
4
|
+
import { CommandContribution } from '@difizen/libro-common/app';
|
|
5
|
+
import { singleton, ToolbarContribution, ViewManager } from '@difizen/libro-common/app';
|
|
6
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
2
7
|
import {
|
|
3
8
|
LibroCommandRegister,
|
|
4
9
|
LibroSlotManager,
|
|
@@ -7,11 +12,6 @@ import {
|
|
|
7
12
|
LibroCellView,
|
|
8
13
|
LibroView,
|
|
9
14
|
} from '@difizen/libro-jupyter';
|
|
10
|
-
import type { CommandRegistry, ToolbarRegistry } from '@difizen/mana-app';
|
|
11
|
-
import { inject } from '@difizen/mana-app';
|
|
12
|
-
import { CommandContribution } from '@difizen/mana-app';
|
|
13
|
-
import { singleton, ToolbarContribution, ViewManager } from '@difizen/mana-app';
|
|
14
|
-
import { l10n } from '@difizen/mana-l10n';
|
|
15
15
|
|
|
16
16
|
import { AINativeCommands } from './ai-native-command.js';
|
|
17
17
|
import { LibroAINativeService } from './ai-native-service.js';
|
package/src/ai-native-command.ts
CHANGED
|
@@ -7,14 +7,14 @@ import { ChatEvent } from '@difizen/magent-chat';
|
|
|
7
7
|
import type { ToAutoFactory } from '@difizen/magent-core';
|
|
8
8
|
import { Fetcher } from '@difizen/magent-core';
|
|
9
9
|
import { toAutoFactory } from '@difizen/magent-core';
|
|
10
|
-
import type { ViewComponent } from '@difizen/
|
|
11
|
-
import { ViewOption } from '@difizen/
|
|
12
|
-
import { prop } from '@difizen/
|
|
13
|
-
import { useObserve } from '@difizen/
|
|
14
|
-
import { useInject, ViewInstance } from '@difizen/
|
|
15
|
-
import { inject } from '@difizen/
|
|
16
|
-
import { BaseView, transient, view } from '@difizen/
|
|
17
|
-
import { l10n } from '@difizen/
|
|
10
|
+
import type { ViewComponent } from '@difizen/libro-common/app';
|
|
11
|
+
import { ViewOption } from '@difizen/libro-common/app';
|
|
12
|
+
import { prop } from '@difizen/libro-common/app';
|
|
13
|
+
import { useObserve } from '@difizen/libro-common/app';
|
|
14
|
+
import { useInject, ViewInstance } from '@difizen/libro-common/app';
|
|
15
|
+
import { inject } from '@difizen/libro-common/app';
|
|
16
|
+
import { BaseView, transient, view } from '@difizen/libro-common/app';
|
|
17
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
18
18
|
import { Button } from 'antd';
|
|
19
19
|
import type { ParsedEvent } from 'eventsource-parser/stream';
|
|
20
20
|
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CellView } from '@difizen/libro-jupyter';
|
|
2
|
-
import { useInject, ViewManager, ViewRender } from '@difizen/
|
|
2
|
+
import { useInject, ViewManager, ViewRender } from '@difizen/libro-common/app';
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import './index.less';
|
|
5
5
|
|
package/src/ai-native-service.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getOrigin,
|
|
3
|
+
inject,
|
|
4
|
+
prop,
|
|
5
|
+
singleton,
|
|
6
|
+
ViewManager,
|
|
7
|
+
} from '@difizen/libro-common/app';
|
|
1
8
|
import type { CellView } from '@difizen/libro-jupyter';
|
|
2
|
-
import { getOrigin, inject, prop, singleton, ViewManager } from '@difizen/mana-app';
|
|
3
9
|
|
|
4
10
|
import { LibroAINativeForCellView } from './ai-native-for-cell-view.js';
|
|
5
11
|
import type { LibroChatView } from './chat-view.js';
|
|
@@ -10,18 +16,18 @@ export class LibroAINativeService {
|
|
|
10
16
|
@prop()
|
|
11
17
|
showSideToolbar = false;
|
|
12
18
|
|
|
13
|
-
chatViewMap: Map<string, LibroChatView> = new Map();
|
|
19
|
+
// chatViewMap: Map<string, LibroChatView> = new Map();
|
|
14
20
|
|
|
15
|
-
//用于控制是否显示当前 libro 层级的 chat 面板
|
|
16
|
-
showChatMap: Map<string, boolean> = new Map();
|
|
21
|
+
// //用于控制是否显示当前 libro 层级的 chat 面板
|
|
22
|
+
// showChatMap: Map<string, boolean> = new Map();
|
|
17
23
|
|
|
18
|
-
cellAIChatMap: Map<string, boolean> = new Map();
|
|
24
|
+
// cellAIChatMap: Map<string, boolean> = new Map();
|
|
19
25
|
@inject(ViewManager)
|
|
20
26
|
viewManager: ViewManager;
|
|
21
27
|
|
|
22
28
|
libroAINativeForCellViewMap: Map<string, LibroAINativeForCellView> = new Map();
|
|
23
29
|
|
|
24
|
-
libroAINativeChatViewMap: Map<string, LibroAiNativeChatView> = new Map();
|
|
30
|
+
// libroAINativeChatViewMap: Map<string, LibroAiNativeChatView> = new Map();
|
|
25
31
|
|
|
26
32
|
async getOrCreateLibroAINativeForCellView(id: string, cell: CellView) {
|
|
27
33
|
let libroAINativeForCellView = this.libroAINativeForCellViewMap.get(id);
|
|
@@ -32,7 +38,7 @@ export class LibroAINativeService {
|
|
|
32
38
|
LibroAINativeForCellView,
|
|
33
39
|
{ id: id, cell: getOrigin(cell) },
|
|
34
40
|
);
|
|
35
|
-
this.libroAINativeForCellViewMap.set(cell.id, libroAINativeForCellView);
|
|
41
|
+
// this.libroAINativeForCellViewMap.set(cell.id, libroAINativeForCellView);
|
|
36
42
|
}
|
|
37
43
|
return libroAINativeForCellView;
|
|
38
44
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LibroSideToolbarMenuItemType } from '@difizen/libro-jupyter';
|
|
2
2
|
import { LibroSideToolbarMenu } from '@difizen/libro-jupyter';
|
|
3
|
-
import { useInject } from '@difizen/
|
|
4
|
-
import { l10n } from '@difizen/
|
|
3
|
+
import { useInject } from '@difizen/libro-common/app';
|
|
4
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
5
5
|
import { Popover } from 'antd';
|
|
6
6
|
|
|
7
7
|
import { AINativeCommands } from './ai-native-command.js';
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
LibroSlot,
|
|
5
5
|
} from '@difizen/libro-jupyter';
|
|
6
6
|
import { LibroExtensionSlotContribution } from '@difizen/libro-jupyter';
|
|
7
|
-
import { ViewManager } from '@difizen/
|
|
8
|
-
import { inject, singleton } from '@difizen/
|
|
7
|
+
import { ViewManager } from '@difizen/libro-common/app';
|
|
8
|
+
import { inject, singleton } from '@difizen/libro-common/app';
|
|
9
9
|
|
|
10
10
|
import { LibroAINativeService } from './ai-native-service.js';
|
|
11
11
|
import { LibroChatView } from './chat-view.js';
|
package/src/chat-view.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
LibroSlotView,
|
|
6
6
|
} from '@difizen/libro-jupyter';
|
|
7
7
|
import type { DisplayView, LibroView } from '@difizen/libro-jupyter';
|
|
8
|
-
import type { ConfigurationService } from '@difizen/
|
|
8
|
+
import type { ConfigurationService } from '@difizen/libro-common/app';
|
|
9
9
|
import {
|
|
10
10
|
BaseView,
|
|
11
11
|
prop,
|
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
useInject,
|
|
17
17
|
ViewInstance,
|
|
18
18
|
ViewRender,
|
|
19
|
-
} from '@difizen/
|
|
19
|
+
} from '@difizen/libro-common/app';
|
|
20
20
|
import { useRef } from 'react';
|
|
21
21
|
import 'katex/dist/katex.min.css'; // 引入 KaTeX 样式
|
|
22
22
|
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
RenderMimeRegistry,
|
|
7
7
|
renderText,
|
|
8
8
|
} from '@difizen/libro-jupyter';
|
|
9
|
-
import { prop, transient } from '@difizen/
|
|
10
|
-
import { getOrigin, useInject, view, ViewInstance } from '@difizen/
|
|
11
|
-
import { l10n } from '@difizen/
|
|
9
|
+
import { prop, transient } from '@difizen/libro-common/app';
|
|
10
|
+
import { getOrigin, useInject, view, ViewInstance } from '@difizen/libro-common/app';
|
|
11
|
+
import { l10n } from '@difizen/libro-common/l10n';
|
|
12
12
|
import { Button } from 'antd';
|
|
13
13
|
import { forwardRef, createRef, useEffect } from 'react';
|
|
14
14
|
|
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
IChatMessageItem,
|
|
10
10
|
} from '@difizen/magent-chat';
|
|
11
11
|
import { autoFactory, AutoFactoryOption } from '@difizen/magent-core';
|
|
12
|
-
import { inject, prop } from '@difizen/
|
|
12
|
+
import { inject, prop } from '@difizen/libro-common/app';
|
|
13
13
|
|
|
14
14
|
@autoFactory()
|
|
15
15
|
export class LibroAIChatMessageItemModel {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { singleton } from '@difizen/libro-common/app';
|
|
1
2
|
import type { IChatEvent, IChatMessageItem } from '@difizen/magent-chat';
|
|
2
3
|
import { ChatEvent } from '@difizen/magent-chat';
|
|
3
4
|
import { LibroChatService } from '@difizen/magent-libro';
|
|
4
|
-
import { singleton } from '@difizen/mana-app';
|
|
5
5
|
import type { ParsedEvent } from 'eventsource-parser/stream';
|
|
6
6
|
import { EventSourceParserStream } from 'eventsource-parser/stream';
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CellView, LibroView } from '@difizen/libro-jupyter';
|
|
2
2
|
import { ChatView, ChatComponents } from '@difizen/magent-chat';
|
|
3
|
-
import { inject, prop, transient, view, ViewOption } from '@difizen/
|
|
3
|
+
import { inject, prop, transient, view, ViewOption } from '@difizen/libro-common/app';
|
|
4
4
|
import rehypeKatex from 'rehype-katex';
|
|
5
5
|
import rehypeRaw from 'rehype-raw';
|
|
6
6
|
import breaks from 'remark-breaks';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ColorRegistry } from '@difizen/
|
|
2
|
-
import { Color } from '@difizen/
|
|
3
|
-
import { singleton, ColorContribution } from '@difizen/
|
|
1
|
+
import type { ColorRegistry } from '@difizen/libro-common/app';
|
|
2
|
+
import { Color } from '@difizen/libro-common/app';
|
|
3
|
+
import { singleton, ColorContribution } from '@difizen/libro-common/app';
|
|
4
4
|
|
|
5
5
|
@singleton({ contrib: ColorContribution })
|
|
6
6
|
export class LibroAINativeColorRegistry implements ColorContribution {
|
package/src/module.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CodeEditorModule } from '@difizen/libro-code-editor';
|
|
2
|
+
import { ManaModule } from '@difizen/libro-common/app';
|
|
2
3
|
import { CellOutputTopProvider, ErrorOutputModel } from '@difizen/libro-jupyter';
|
|
3
4
|
import { ChatView } from '@difizen/magent-chat';
|
|
4
5
|
import { LibroChatModule, LibroChatService } from '@difizen/magent-libro';
|
|
5
|
-
import { ManaModule } from '@difizen/mana-app';
|
|
6
6
|
|
|
7
7
|
import { LibroAICompletionModule } from './ai-inline-completions/module.js';
|
|
8
8
|
import { LibroAINativeCommandContribution } from './ai-native-command-contribution.js';
|