Skip to content

Commit

Permalink
fix(prompt): ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinesmilelk authored and BroKun committed Dec 12, 2023
1 parent bc9ab65 commit 57ab0f6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
12 changes: 6 additions & 6 deletions packages/libro-prompt-cell/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@
"lint:tsc": "tsc --noEmit"
},
"dependencies": {
"@difizen/libro-code-editor": "^0.0.2-alpha.0",
"@difizen/libro-jupyter": "0.0.2-alpha.0",
"@difizen/libro-rendermime": "^0.0.2-alpha.0",
"@difizen/libro-codemirror": "^0.0.2-alpha.0",
"@difizen/libro-common": "^0.0.2-alpha.0",
"@difizen/libro-core": "^0.0.2-alpha.0",
"@difizen/libro-code-editor": "^0.1.0",
"@difizen/libro-jupyter": "^0.1.0",
"@difizen/libro-rendermime": "^0.1.0",
"@difizen/libro-codemirror": "^0.1.0",
"@difizen/libro-common": "^0.1.0",
"@difizen/libro-core": "^0.1.0",
"@difizen/mana-app": "latest",
"highlight.js": "^11.8.0",
"marked": "^5.1.1",
Expand Down
4 changes: 1 addition & 3 deletions packages/libro-prompt-cell/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import assert from 'assert';

import { LibroPromptCellView, LibroPromptCellModelFactory } from './index.js';
import 'reflect-metadata';

describe('libro-prompt-cell', () => {
it('#import', () => {
assert(LibroPromptCellView);
assert(LibroPromptCellModelFactory);
assert(true);
});
});
2 changes: 1 addition & 1 deletion packages/libro-prompt-cell/src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ManaModule } from '@difizen/mana-app';

import { PromptCellContribution } from './prompt-cell-contribution.js';
import { LibroPromptCellModel } from './prompt-cell-model.js';
import { LibroPromptOutputArea } from './prompt-cell-outputArea.js';
import { LibroPromptOutputArea } from './prompt-cell-output-area.js';
import { LibroPromptCellModelFactory } from './prompt-cell-protocol.js';
import { LibroPromptCellView } from './prompt-cell-view.js';
import { LibroPromptOutputMimeTypeContribution } from './prompt-output-rendermime-contribution.js';
Expand Down
22 changes: 10 additions & 12 deletions packages/libro-prompt-cell/src/prompt-cell-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ const PropmtEditorViewComponent = React.forwardRef<HTMLDivElement>(
.then(() => {
if (instance.modelSelection.length > 0) {
setSelectedModel(instance.modelSelection[0].label);
(instance.model as LibroPromptCellModel).modelType =
instance.modelSelection[0].label;
instance.model.modelType = instance.modelSelection[0].label;
return;
}
return;
Expand All @@ -81,7 +80,7 @@ const PropmtEditorViewComponent = React.forwardRef<HTMLDivElement>(
}, [instance]);

const handleChange = (value: string) => {
(instance.model as LibroPromptCellModel).modelType = value;
instance.model.modelType = value;
setSelectedModel(value);
};

Expand Down Expand Up @@ -120,6 +119,8 @@ const PropmtEditorViewComponent = React.forwardRef<HTMLDivElement>(
export class LibroPromptCellView extends LibroExecutableCellView {
override view = PropmtEditorViewComponent;

declare model: LibroPromptCellModel;

@prop()
modelSelection: IModelSelectionItem[] = [];

Expand Down Expand Up @@ -326,7 +327,7 @@ export class LibroPromptCellView extends LibroExecutableCellView {

// const cellContent = '%prompt ' + toBase64(this.model.value) + ',model:';
const promptObj = {
model_name: (this.model as LibroPromptCellModel).modelType || 'CodeGPT',
model_name: this.model.modelType || 'CodeGPT',
prompt: this.model.value,
};

Expand All @@ -353,25 +354,22 @@ export class LibroPromptCellView extends LibroExecutableCellView {
future.onIOPub = (msg: any) => {
this.model.msgChangeEmitter.fire(msg);
if (msg.header.msg_type === 'execute_input') {
(this.model as LibroPromptCellModel).kernelExecuting = true;
this.model.kernelExecuting = true;
startTimeStr = msg.header.date as string;
const meta = (this.model as LibroPromptCellModel).metadata
.execution as ExecutionMeta;
const meta = this.model.metadata.execution as ExecutionMeta;
if (meta) {
meta['shell.execute_reply.started'] = startTimeStr;
}
}
if (msg.header.msg_type === 'error') {
(this.model as LibroPromptCellModel).hasExecutedError = true;
this.model.hasExecutedError = true;
}
};

const msgPromise = await future.done;
this.model.executing = false;
(this.model as LibroPromptCellModel).kernelExecuting = false;
(this.model as LibroPromptCellModel).hasExecutedSuccess = !(
this.model as LibroPromptCellModel
).hasExecutedError;
this.model.kernelExecuting = false;
this.model.hasExecutedSuccess = !this.model.hasExecutedError;

startTimeStr = msgPromise.metadata['started'] as string; // 更新startTimeStr
const endTimeStr = msgPromise.header.date;
Expand Down

0 comments on commit 57ab0f6

Please sign in to comment.