@difizen/libro-prompt-cell 0.1.13 → 0.1.15

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.
Files changed (42) hide show
  1. package/README.md +7 -0
  2. package/es/index.less +6 -0
  3. package/es/input-handler/chat-record-input.d.ts +12 -0
  4. package/es/input-handler/chat-record-input.d.ts.map +1 -0
  5. package/es/input-handler/chat-record-input.js +92 -0
  6. package/es/input-handler/index.d.ts +3 -0
  7. package/es/input-handler/index.d.ts.map +1 -0
  8. package/es/input-handler/index.js +2 -0
  9. package/es/input-handler/index.less +91 -0
  10. package/es/input-handler/variable-name-input.d.ts +18 -0
  11. package/es/input-handler/variable-name-input.d.ts.map +1 -0
  12. package/es/input-handler/variable-name-input.js +120 -0
  13. package/es/libro-formatter-prompt-magic-contribution.d.ts +9 -0
  14. package/es/libro-formatter-prompt-magic-contribution.d.ts.map +1 -1
  15. package/es/libro-formatter-prompt-magic-contribution.js +12 -3
  16. package/es/module.js +2 -2
  17. package/es/prompt-cell-model.d.ts +16 -0
  18. package/es/prompt-cell-model.d.ts.map +1 -1
  19. package/es/prompt-cell-model.js +49 -13
  20. package/es/prompt-cell-script.d.ts +3 -2
  21. package/es/prompt-cell-script.d.ts.map +1 -1
  22. package/es/prompt-cell-script.js +13 -4
  23. package/es/prompt-cell-view.d.ts +33 -13
  24. package/es/prompt-cell-view.d.ts.map +1 -1
  25. package/es/prompt-cell-view.js +326 -181
  26. package/es/prompt-output-render.js +15 -16
  27. package/package.json +11 -7
  28. package/src/index.less +6 -0
  29. package/src/input-handler/chat-record-input.tsx +93 -0
  30. package/src/input-handler/index.less +91 -0
  31. package/src/input-handler/index.ts +2 -0
  32. package/src/input-handler/variable-name-input.tsx +121 -0
  33. package/src/libro-formatter-prompt-magic-contribution.ts +13 -2
  34. package/src/module.ts +2 -2
  35. package/src/prompt-cell-model.ts +26 -0
  36. package/src/prompt-cell-script.ts +8 -3
  37. package/src/prompt-cell-view.tsx +233 -92
  38. package/src/prompt-output-render.tsx +1 -1
  39. package/es/prompt-cell-output-area.d.ts +0 -14
  40. package/es/prompt-cell-output-area.d.ts.map +0 -1
  41. package/es/prompt-cell-output-area.js +0 -74
  42. package/src/prompt-cell-output-area.tsx +0 -59
@@ -1,4 +1,13 @@
1
- export var PromptScript;
2
- (function (_PromptScript) {
3
- var get_models = _PromptScript.get_models = 'import json\nfrom aistudio_notebook.prompt_flow import prompt_model_registry\nmodel_list = list(prompt_model_registry.promptModelRegistry.get_models().keys())\nmodel_data = json.dumps(model_list)\nprint(model_data)\n';
4
- })(PromptScript || (PromptScript = {}));
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ var _dec, _class;
3
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ 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); }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ import { singleton } from '@difizen/mana-app';
9
+ export var PromptScript = (_dec = singleton(), _dec(_class = /*#__PURE__*/_createClass(function PromptScript() {
10
+ _classCallCheck(this, PromptScript);
11
+ this.getChatObjects = "from libro_server import chat_object_manager\nchat_object_manager.dump_list_json()";
12
+ this.getChatRecoreds = "from libro_server import chat_record_provider\nchat_record_provider.get_records()";
13
+ })) || _class);
@@ -2,34 +2,43 @@ import { CodeEditorManager } from '@difizen/libro-code-editor';
2
2
  import type { CodeEditorViewOptions, IRange, CodeEditorView } from '@difizen/libro-code-editor';
3
3
  import type { IOutput } from '@difizen/libro-common';
4
4
  import type { LibroCell, CellViewOptions } from '@difizen/libro-core';
5
- import { CellService, LibroExecutableCellView, LibroOutputArea, LibroViewTracker } from '@difizen/libro-core';
5
+ import { LibroOutputArea } from '@difizen/libro-core';
6
+ import { CellService, LibroExecutableCellView, LibroViewTracker, LirboContextKey } from '@difizen/libro-core';
6
7
  import type { KernelMessage } from '@difizen/libro-jupyter';
7
8
  import { ViewManager } from '@difizen/mana-app';
8
9
  import { Deferred } from '@difizen/mana-app';
9
10
  import React from 'react';
10
- import type { LibroPromptCellModel } from './prompt-cell-model.js';
11
- export interface IModelSelectionItem {
12
- value: string;
13
- label: string;
11
+ import { LibroPromptCellModel } from './prompt-cell-model.js';
12
+ import { PromptScript } from './prompt-cell-script.js';
13
+ import './index.less';
14
+ export interface ChatObject {
15
+ name: string;
16
+ type: string;
17
+ order: number;
18
+ key: string;
14
19
  }
15
- export interface IModelItem {
16
- value: string;
20
+ export interface ChatObjectOptions {
21
+ order?: number;
22
+ color?: string;
17
23
  }
18
- export declare const CellEditorMemo: React.NamedExoticComponent<{}>;
24
+ export declare const CellEditor: React.NamedExoticComponent<{}>;
19
25
  export declare class LibroPromptCellView extends LibroExecutableCellView {
26
+ protected lirboContextKey: LirboContextKey;
20
27
  view: React.ForwardRefExoticComponent<React.RefAttributes<HTMLDivElement>>;
21
28
  model: LibroPromptCellModel;
22
- modelSelection: IModelSelectionItem[];
29
+ chatObjects: ChatObject[];
30
+ contextChatRecords: string[];
31
+ get sortedChatItems(): ChatObject[];
32
+ get chatRecords(): string[];
23
33
  viewManager: ViewManager;
24
34
  codeEditorManager: CodeEditorManager;
35
+ promptScript: PromptScript;
25
36
  outputs: IOutput[];
26
37
  libroViewTracker: LibroViewTracker;
27
38
  editorView?: CodeEditorView;
28
39
  protected outputAreaDeferred: Deferred<LibroOutputArea>;
29
40
  get outputAreaReady(): Promise<LibroOutputArea>;
30
- protected editorViewReadyDeferred: Deferred<void>;
31
- get editorReady(): Promise<void>;
32
- constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, libroViewTracker: LibroViewTracker, codeEditorManager: CodeEditorManager);
41
+ constructor(options: CellViewOptions, cellService: CellService, viewManager: ViewManager, libroViewTracker: LibroViewTracker);
33
42
  outputWatch(): void;
34
43
  toJSON(): LibroCell;
35
44
  onViewMount(): void;
@@ -38,6 +47,7 @@ export declare class LibroPromptCellView extends LibroExecutableCellView {
38
47
  protected afterEditorReady(): Promise<void>;
39
48
  shouldEnterEditorMode(e: React.FocusEvent<HTMLElement>): boolean;
40
49
  blur: () => void;
50
+ protected focusEditor(): void;
41
51
  focus: (toEdit: boolean) => void;
42
52
  clearExecution: () => void;
43
53
  getSelections: () => [];
@@ -47,6 +57,16 @@ export declare class LibroPromptCellView extends LibroExecutableCellView {
47
57
  };
48
58
  run(): Promise<boolean>;
49
59
  fetch: (content: KernelMessage.IExecuteRequestMsg['content'], ioCallback: (msg: KernelMessage.IIOPubMessage) => any) => Promise<KernelMessage.IExecuteReplyMsg>;
50
- handleQueryResponse: (response: KernelMessage.IIOPubMessage) => void;
60
+ updateChatObjects: () => Promise<KernelMessage.IExecuteReplyMsg>;
61
+ updateChatRecords: () => Promise<KernelMessage.IExecuteReplyMsg>;
62
+ toSelectionOption: (item: ChatObject) => {
63
+ value: string;
64
+ label: import("react/jsx-runtime").JSX.Element;
65
+ };
66
+ handleQueryResponse: (response: KernelMessage.IIOPubMessage, cb: (result: string) => void) => void;
67
+ checkVariableNameAvailable: (variableName: string) => boolean;
68
+ handleModelNameChange: (value: string) => void;
69
+ handleVariableNameChange: (value: string) => void;
70
+ handleRecordChange: (value: string) => void;
51
71
  }
52
72
  //# sourceMappingURL=prompt-cell-view.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompt-cell-view.d.ts","sourceRoot":"","sources":["../src/prompt-cell-view.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EACV,qBAAqB,EACrB,MAAM,EACN,cAAc,EACf,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAa,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhE,OAAO,KAAK,EAEV,SAAS,EACT,eAAe,EAChB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,eAAe,EACf,gBAAgB,EAEjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAiB,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE3E,OAAO,EAQL,WAAW,EAIZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAA8B,MAAM,OAAO,CAAC;AAEnD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AACD,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;CACf;AAYD,eAAO,MAAM,cAAc,gCAAyB,CAAC;AAsErD,qBAEa,mBAAoB,SAAQ,uBAAuB;IACrD,IAAI,uEAA6B;IAElC,KAAK,EAAE,oBAAoB,CAAC;IAGpC,cAAc,EAAE,mBAAmB,EAAE,CAAM;IAE3C,WAAW,EAAE,WAAW,CAAC;IAEzB,iBAAiB,EAAE,iBAA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