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

Require prompt minimum length (4 chars) #860

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion mesop/web/src/editor_toolbar/editor_toolbar.ng.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@
</div>
}

<button mat-icon-button (click)="sendPrompt()" [disabled]="isLoading">
<button
mat-icon-button
(click)="sendPrompt()"
[disabled]="isLoading"
[matTooltip]="'Generate code'"
>
<mat-icon>send</mat-icon>
</button>

Expand Down
10 changes: 10 additions & 0 deletions mesop/web/src/editor_toolbar/editor_toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ export class EditorToolbar implements OnInit {
}

async sendPrompt() {
if (this.prompt.length < 4) {
this.snackBar.open(
'Please enter a prompt at least 4 characters long',
'Close',
{
duration: 5000,
},
);
return;
}
const prompt = this.prompt;
this.autocompleteService.addHistoryOption(prompt);
this.prompt = '';
Expand Down
Loading