diff --git a/.changeset/unlucky-hounds-shake.md b/.changeset/unlucky-hounds-shake.md new file mode 100644 index 00000000..61a61035 --- /dev/null +++ b/.changeset/unlucky-hounds-shake.md @@ -0,0 +1,36 @@ +--- +'@difizen/libro-cofine-editor': patch +'@difizen/libro-prompt-cell': patch +'@difizen/libro-core': patch +'@difizen/libro-docs': patch +'@difizen/libro-ai-native': patch +'@difizen/libro-app': patch +'@difizen/libro-code-cell': patch +'@difizen/libro-code-editor': patch +'@difizen/libro-codemirror': patch +'@difizen/libro-cofine-editor-contribution': patch +'@difizen/libro-cofine-editor-core': patch +'@difizen/libro-cofine-textmate': patch +'@difizen/libro-common': patch +'@difizen/libro-jupyter': patch +'@difizen/libro-kernel': patch +'@difizen/libro-l10n': patch +'@difizen/libro-lab': patch +'@difizen/libro-language-client': patch +'@difizen/libro-lsp': patch +'@difizen/libro-markdown': patch +'@difizen/libro-markdown-cell': patch +'@difizen/libro-output': patch +'@difizen/libro-raw-cell': patch +'@difizen/libro-rendermime': patch +'@difizen/libro-search': patch +'@difizen/libro-search-code-cell': patch +'@difizen/libro-shared-model': patch +'@difizen/libro-sql-cell': patch +'@difizen/libro-terminal': patch +'@difizen/libro-toc': patch +'@difizen/libro-virtualized': patch +'@difizen/libro-widget': patch +--- + +feat: add interpreter for prompt cell diff --git a/packages/libro-prompt-cell/src/prompt-cell-view.tsx b/packages/libro-prompt-cell/src/prompt-cell-view.tsx index b59e455c..719650ef 100644 --- a/packages/libro-prompt-cell/src/prompt-cell-view.tsx +++ b/packages/libro-prompt-cell/src/prompt-cell-view.tsx @@ -33,7 +33,7 @@ import { Deferred, } from '@difizen/mana-app'; import { l10n } from '@difizen/mana-l10n'; -import { Select, Switch, Tag } from 'antd'; +import { Select, Tag } from 'antd'; import type { DefaultOptionType } from 'antd/es/select/index.js'; import classNames from 'classnames'; import React, { useEffect, useState } from 'react'; @@ -109,14 +109,14 @@ const ChatObjectOptions = (type: string): ChatObjectOptions => { const InterpreterMode = () => { const instance = useInject(ViewInstance); - const handleInterpreterSwitch = (checked: boolean) => { - instance.model.interpreterEnabled = checked; - if (instance.model.chatKey) { - instance.switchInterpreterMode(instance.model.chatKey, checked); - instance.model.promptOutput = undefined; - instance.model.interpreterCode = undefined; - } - }; + // const handleInterpreterSwitch = (checked: boolean) => { + // instance.model.interpreterEnabled = checked; + // if (instance.model.chatKey) { + // instance.switchInterpreterMode(instance.model.chatKey, checked); + // instance.model.promptOutput = undefined; + // instance.model.interpreterCode = undefined; + // } + // }; if (instance.model.supportInterpreter === 'immutable') { return ( @@ -126,20 +126,20 @@ const InterpreterMode = () => { ); } - if (instance.model.supportInterpreter === 'dynamic') { - return ( -
- - {instance.model.interpreterEnabled ? '关闭 Interpreter' : '开启 Interpreter'} - - -
- ); - } + // if (instance.model.supportInterpreter === 'dynamic') { + // return ( + //
+ // + // {instance.model.interpreterEnabled ? '关闭 Interpreter' : '开启 Interpreter'} + // + // + //
+ // ); + // } return null; }; @@ -206,7 +206,7 @@ const PropmtEditorViewComponent = React.forwardRef( // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - const handleChange = (value: string, options: DefaultOptionType) => { + const handleChange = (value: string, options?: DefaultOptionType) => { instance.handleModelNameChange(value, options); setSelectedModel(value); }; @@ -327,8 +327,10 @@ export class LibroPromptCellView extends LibroEditableExecutableCellView { this.model.mimeType = MIME.python; this.outputArea.clear(); this.parent.enterEditMode(); + this.parent.model.savable = false; this.parent.model.runnable = false; } else { + this.parent.model.savable = true; this.model.interpreterCode = this.model.value; this.model.mimeType = 'application/vnd.libro.prompt+json'; this.parent.model.runnable = true; @@ -774,9 +776,11 @@ export class LibroPromptCellView extends LibroEditableExecutableCellView { ) > -1 ); }; - handleModelNameChange = (value: string, option: DefaultOptionType) => { + handleModelNameChange = (value: string, option?: DefaultOptionType) => { this.model.chatKey = value; - this.model.supportInterpreter = option['support_interpreter']; + if (option) { + this.model.supportInterpreter = option['support_interpreter']; + } }; handleVariableNameChange = (value?: string) => { this.model.variableName = value;