Skip to content
Open
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,641 changes: 4,539 additions & 3,102 deletions starters/angular/ai-chatbot/package-lock.json

Large diffs are not rendered by default.

29 changes: 15 additions & 14 deletions starters/angular/ai-chatbot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
},
"private": true,
"dependencies": {
"@angular/common": "^20.0.0",
"@angular/compiler": "^20.0.0",
"@angular/core": "^20.0.0",
"@angular/forms": "^20.0.0",
"@angular/platform-browser": "^20.0.0",
"@angular/platform-browser-dynamic": "^20.0.0",
"@angular/platform-server": "^20.0.0",
"@angular/router": "^20.0.0",
"@angular/ssr": "^20.0.0",
"@angular/common": "^21.0.0",
"@angular/compiler": "^21.0.0",
"@angular/core": "^21.0.0",
"@angular/forms": "^21.0.0",
"@angular/platform-browser": "^21.0.0",
"@angular/platform-browser-dynamic": "^21.0.0",
"@angular/platform-server": "^21.0.0",
"@angular/router": "^21.0.0",
"@angular/ssr": "^21.0.0",
"@google/generative-ai": "^0.24.0",
"@ngx-templates/shared": "^1.0.3",
"@ngx-templates/shared": "^1.0.4",
"@types/showdown": "^2.0.6",
"express": "^4.18.2",
"immutable": "^5.0.3",
Expand All @@ -32,9 +32,10 @@
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^20.0.0",
"@angular/cli": "^20.0.0",
"@angular/compiler-cli": "^20.0.0",
"@angular-devkit/build-angular": "^21.0.0",
"@angular/build": "^21.0.0",
"@angular/cli": "^21.0.0",
"@angular/compiler-cli": "^21.0.0",
"@types/express": "^4.17.17",
"@types/jasmine": "~5.1.0",
"@types/node": "^18.18.0",
Expand All @@ -45,6 +46,6 @@
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.8.3"
"typescript": "~5.9.3"
}
}
16 changes: 14 additions & 2 deletions starters/angular/ai-chatbot/src/main.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { bootstrapApplication } from '@angular/platform-browser';
import { provideZoneChangeDetection } from '@angular/core';
import {
bootstrapApplication,
BootstrapContext,
} from '@angular/platform-browser';
import { AppComponent } from './app/app.component';
import { config } from './app/app.config.server';

const bootstrap = () => bootstrapApplication(AppComponent, config);
const bootstrap = (context: BootstrapContext) =>
bootstrapApplication(
AppComponent,
{
...config,
providers: [provideZoneChangeDetection(), ...config.providers],
},
context,
);

export default bootstrap;
7 changes: 5 additions & 2 deletions starters/angular/ai-chatbot/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ const angularApp = new AngularNodeAppEngine();

app.use(express.json());


// Assign your Google AI API key as an environment variable
const genAI = new GoogleGenerativeAI(process.env['API_KEY'] || '');
const ctx = new Map();

const GEMINI_MODEL = 'gemini-2.5-flash';

// Used for converting MD => HTML.
const converter = new Converter();

Expand All @@ -42,7 +45,7 @@ function printRequestData(req: express.Request) {
app.post('/api/gemini', async (req, res) => {
let model = ctx.get(req.path);
if (!model) {
model = genAI.getGenerativeModel({ model: 'gemini-1.5-flash' });
model = genAI.getGenerativeModel({ model: GEMINI_MODEL });
ctx.set(req.path, model);
}

Expand All @@ -62,7 +65,7 @@ app.post('/api/gemini', async (req, res) => {
app.post('/api/gemini-chat', async (req, res) => {
let chat = ctx.get(req.path);
if (!chat) {
const model = genAI.getGenerativeModel({ model: 'gemini-1.5-flash' });
const model = genAI.getGenerativeModel({ model: GEMINI_MODEL });
chat = model.startChat({
history: [
{
Expand Down
Loading