@@ -350,6 +350,7 @@ const { data, errors } = await client.queries.generateHaiku({
350
350
351
351
Here's an example of a simple UI that prompts a generative AI model to create a haiku based on user input:
352
352
353
+ <InlineFilter filters = { [" react" , " javascript" , " nextjs" , " react-native" , " vue" ]} >
353
354
``` tsx title="App.tsx"
354
355
import type { Schema } from ' @/amplify/data/resource' ;
355
356
import type { FormEvent } from ' react' ;
@@ -402,6 +403,65 @@ export default function App() {
402
403
);
403
404
}
404
405
```
406
+ </InlineFilter >
407
+
408
+ <InlineFilter filters = { [' angular' ]} >
409
+ ``` ts title="app.component.ts"
410
+ import { Component } from ' @angular/core' ;
411
+ import { FormsModule } from ' @angular/forms' ;
412
+ import type { Schema } from ' ../../../amplify/data/resource' ;
413
+ import { Amplify } from ' aws-amplify' ;
414
+ import { generateClient } from ' aws-amplify/api' ;
415
+ import outputs from ' ../../../amplify_outputs.json' ;
416
+
417
+ Amplify .configure (outputs );
418
+
419
+ const client = generateClient <Schema >();
420
+
421
+ @Component ({
422
+ selector: ' app-haiku' ,
423
+ standalone: true ,
424
+ imports: [FormsModule ],
425
+ template: `
426
+ <main
427
+ class="flex min-h-screen flex-col items-center justify-center p-24 dark:text-white"
428
+ >
429
+ <div>
430
+ <h1 class="text-3xl font-bold text-center mb-4">Haiku Generator</h1>
431
+ <form class="mb-4 self-center max-w-[500px]" (ngSubmit)="sendPrompt()">
432
+ <input
433
+ class="text-black p-2 w-full"
434
+ placeholder="Enter a prompt..."
435
+ name="prompt"
436
+ [(ngModel)]="prompt"
437
+ />
438
+ </form>
439
+ <div class="text-center">
440
+ <pre>{{ answer }}</pre>
441
+ </div>
442
+ </div>
443
+ </main>
444
+ ` ,
445
+ })
446
+ export class HaikuComponent {
447
+ prompt: string = ' ' ;
448
+ answer: string | null = null ;
449
+
450
+ async sendPrompt() {
451
+ const { data, errors } = await client .queries .generateHaiku ({
452
+ prompt: this .prompt ,
453
+ });
454
+
455
+ if (! errors ) {
456
+ this .answer = data ;
457
+ this .prompt = ' ' ;
458
+ } else {
459
+ console .log (errors );
460
+ }
461
+ }
462
+ }
463
+ ```
464
+ </InlineFilter >
405
465
406
466
![ A webpage titled "Haiku Generator" and input field. "Frank Herbert's Dune" is entered and submitted. Shortly after, a haiku is rendered to the page.] ( /images/haiku-generator.gif )
407
467
0 commit comments