Skip to content

Commit

Permalink
Merge pull request #23 from juanfranciscocis/Vertex-AI-Playground
Browse files Browse the repository at this point in the history
New Features:
  • Loading branch information
juanfranciscocis authored Jul 9, 2024
2 parents 5761054 + 45ca4e5 commit 685d2f9
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ const routes: Routes = [
path: 'graph-trace',
loadChildren: () => import('./pages/graph-trace/graph-trace.module').then( m => m.GraphTracePageModule)
},
{
path: 'ai',
loadChildren: () => import('./pages/ai/ai.module').then( m => m.AiPageModule)
},
];

@NgModule({
Expand Down
17 changes: 17 additions & 0 deletions src/app/pages/ai/ai-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { AiPage } from './ai.page';

const routes: Routes = [
{
path: '',
component: AiPage
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AiPageRoutingModule {}
20 changes: 20 additions & 0 deletions src/app/pages/ai/ai.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';

import { IonicModule } from '@ionic/angular';

import { AiPageRoutingModule } from './ai-routing.module';

import { AiPage } from './ai.page';

@NgModule({
imports: [
CommonModule,
FormsModule,
IonicModule,
AiPageRoutingModule
],
declarations: [AiPage]
})
export class AiPageModule {}
26 changes: 26 additions & 0 deletions src/app/pages/ai/ai.page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<ion-header [translucent]="true">
<ion-toolbar>
<ion-title>ai</ion-title>
</ion-toolbar>
</ion-header>

<ion-content [fullscreen]="true">
<ion-header collapse="condense">
<ion-toolbar>
<ion-title size="large">ai</ion-title>
</ion-toolbar>
</ion-header>

<ion-grid>
<ion-row>
<ion-col size="6" size-md="6" size-lg="6">
<ion-input class="" label="Enter a question" placeholder="Enter a question" type="text" labelPlacement="stacked" [(ngModel)]="question"></ion-input>
<ion-button (click)="askQuestionNow()" class="m-4" color="primary">Ask</ion-button>
</ion-col>
</ion-row>
</ion-grid>




</ion-content>
Empty file added src/app/pages/ai/ai.page.scss
Empty file.
17 changes: 17 additions & 0 deletions src/app/pages/ai/ai.page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AiPage } from './ai.page';

describe('AiPage', () => {
let component: AiPage;
let fixture: ComponentFixture<AiPage>;

beforeEach(() => {
fixture = TestBed.createComponent(AiPage);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
26 changes: 26 additions & 0 deletions src/app/pages/ai/ai.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Component, inject, OnInit} from '@angular/core';
import {getGenerativeModel, VertexAI} from "@angular/fire/vertexai-preview";

@Component({
selector: 'app-ai',
templateUrl: './ai.page.html',
styleUrls: ['./ai.page.scss'],
})
export class AiPage implements OnInit {
question: string | undefined;
private vertexAI:VertexAI = inject(VertexAI);


constructor() { }

ngOnInit() {
}

askQuestionNow() {
const model = getGenerativeModel(this.vertexAI, {model: "gemini-1.5-flash"});
model.generateContent(this.question!).then(response => {
console.log(response.response.text());
});
}

}

0 comments on commit 685d2f9

Please sign in to comment.