Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web/admin: fix error when prompt previewing fails when loading the page #5290

Merged
merged 1 commit into from
Apr 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions web/src/admin/stages/prompt/PromptForm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ export class PromptForm extends ModelForm<Prompt, string> {
const prompt = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsRetrieve({
promptUuid: pk,
});
this.preview = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsPreviewCreate({
promptRequest: prompt,
});
await this.refreshPreview(prompt);
return prompt;
}

async refreshPreview(): Promise<void> {
const data = this.serializeForm();
if (!data) {
return;
async refreshPreview(prompt?: Prompt): Promise<void> {
if (!prompt) {
prompt = this.serializeForm();
if (!prompt) {
return;
}
}
try {
this.preview = await new StagesApi(DEFAULT_CONFIG).stagesPromptPromptsPreviewCreate({
promptRequest: data,
promptRequest: prompt,
});
this.previewError = undefined;
} catch (exc) {
Expand Down