Skip to content

Commit 5b68ea3

Browse files
authored
Story gen fixes (#9)
* Add apphosting.yaml * Add img logging * Adjust img prompt * Update img prompt * Update story component * Add persistent session storage * Use global var for session mgmt * Remove console log * Fix update button bug * Minor refactors * Add license * Add license
1 parent 36d20d3 commit 5b68ea3

6 files changed

Lines changed: 34 additions & 4 deletions

File tree

genkit-angular-story-generator/src/app/app.config.server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*!
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
18
import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
29
import { provideServerRendering } from '@angular/platform-server';
310
import { provideServerRouting } from '@angular/ssr';

genkit-angular-story-generator/src/app/app.routes.server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*!
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
18
import { RenderMode, ServerRoute } from '@angular/ssr';
29

310
export const serverRoutes: ServerRoute[] = [

genkit-angular-story-generator/src/app/story.service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,13 @@ export class StoryService {
3131
// session management in a production application.
3232
sessionId = linkedSignal<string, string>({
3333
source: () => this.premiseResource.value().storyPremise,
34-
computation: (_agentResponse, previous) =>
35-
(!previous ? Date.now() + '' + Math.floor(Math.random() * 1000000000) : previous.value)
34+
computation: (_newPremise, previous) => !previous ? randomId() : previous.value
3635
});
3736

3837
// Used to determine whether to show the update story button in the UserInputComponenet
3938
hasPremiseUpdated = linkedSignal<string, boolean>({
4039
source: () => this.premiseResource.value().storyPremise,
41-
computation: (newPremise, previous) => (previous || false) && newPremise !== previous!.source
40+
computation: (newPremise, previous) => !!previous && newPremise !== previous!.source
4241
});
4342

4443
// Only clear the session on initial page load
@@ -66,4 +65,8 @@ interface StoryPremise {
6665
storyPremise: string;
6766
nextQuestion: string;
6867
premiseOptions: string[];
68+
}
69+
70+
function randomId(): string {
71+
return Date.now() + '' + Math.floor(Math.random() * 1000000000);
6972
}

genkit-angular-story-generator/src/main.server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*!
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
18
import { bootstrapApplication } from '@angular/platform-browser';
29
import { AppComponent } from './app/app.component';
310
import { config } from './app/app.config.server';

genkit-angular-story-generator/src/prompts.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Return a one sentence string containing the next queston. Do not be conversation
5656
5757
Create some options to answer the question you just created asked. Return a
5858
comma separated list strings: ["example_1", "example_2", "example_3", "example_4", "example_5"].
59-
If it doesn't make sense to offer for options (e.g. character name), return an empty list: [].
6059
If your question asks if the user is satisifed with the story, return an empty list.
6160
6261
The final response should be structured as follows:

genkit-angular-story-generator/src/server.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
/*!
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.dev/license
7+
*/
18
import {
29
AngularNodeAppEngine,
310
createNodeRequestHandler,

0 commit comments

Comments
 (0)