Skip to content

Commit 4e4c5cf

Browse files
authored
Merge pull request #301 from firebase/i1521-2
docs: Migrates Genkit sample apps, incorporating them into Firebase quickstart-nodejs repo.
2 parents cf70e02 + 32a288d commit 4e4c5cf

File tree

118 files changed

+5023
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+5023
-0
lines changed

genkit/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Genkit samples
2+
3+
Take a look at some samples of Genkit in use:
4+
5+
- [js-coffee-shop](js-coffee-shop/): "AI barista", demonstrating simple
6+
LLM usage
7+
- [js-menu](js-menu/): Progressively more sophisticated versions of a
8+
menu understanding app
9+
- [chatbot](chatbot/): A simple chatbot with a JavaScript frontend
10+
- [js-angular](js-angular/): Demo of streaming to an Angular frontend
11+
- [js-schoolAgent](js-schoolAgent/): A simple school assistant system with a routing agent and specialized agents
12+
- [prompts](prompts/): Shows off several prompting techniques

genkit/chatbot/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib

genkit/chatbot/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Chatbot
2+
3+
This is a simple chatbot. You can pick which model to use.
4+
5+
Prerequisite
6+
7+
- install Genkit (`npm i -g genkit`)
8+
- Google Cloud project with Vertex AI API enabled (https://pantheon.corp.google.com/apis/library/aiplatform.googleapis.com)
9+
- gcloud CLI installed (https://cloud.google.com/sdk/docs/install-sdk)
10+
- to use Llama 3.1 405b enable it in the Vertex AI [Model Garden](https://console.cloud.google.com/vertex-ai/publishers/meta/model-garden/llama3-405b-instruct-maas)
11+
12+
The sample is using Vertex AI, so you'll need to auth:
13+
14+
```bash
15+
gcloud auth login
16+
gcloud auth application-default login --project YOUR_PROJECT
17+
```
18+
19+
Clone this code
20+
21+
```
22+
git clone https://github.com/firebase/genkit
23+
cd genkit/samples/chatbot
24+
```
25+
26+
Install deps and run the chatbot app
27+
28+
```bash
29+
npm run setup
30+
npm start
31+
```
32+
33+
Point your browser to http://localhost:4200/
34+
35+
Inspect runs in http://localhost:4000/

genkit/chatbot/eval.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{
3+
"conversationId": "1234",
4+
"prompt": "tell me a joke"
5+
},
6+
{
7+
"conversationId": "2345",
8+
"prompt": "wtite a python program that prints out weather for the current location"
9+
}
10+
]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false

genkit/chatbot/genkit-app/.gitignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db

genkit/chatbot/genkit-app/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# GenkitApp
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 18.0.2.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.dev/tools/cli) page.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"genkit-app": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "scss"
11+
}
12+
},
13+
"root": "",
14+
"sourceRoot": "src",
15+
"prefix": "app",
16+
"architect": {
17+
"build": {
18+
"builder": "@angular-devkit/build-angular:application",
19+
"options": {
20+
"outputPath": "dist/genkit-app",
21+
"index": "src/index.html",
22+
"browser": "src/main.ts",
23+
"polyfills": ["zone.js"],
24+
"tsConfig": "tsconfig.app.json",
25+
"inlineStyleLanguage": "scss",
26+
"assets": [
27+
{
28+
"glob": "**/*",
29+
"input": "public"
30+
}
31+
],
32+
"styles": [
33+
"@angular/material/prebuilt-themes/azure-blue.css",
34+
"src/styles.scss",
35+
"node_modules/prismjs/plugins/line-numbers/prism-line-numbers.css"
36+
],
37+
"scripts": [
38+
"node_modules/prismjs/prism.js",
39+
"node_modules/prismjs/components/prism-csharp.min.js",
40+
"node_modules/prismjs/components/prism-css.min.js",
41+
"node_modules/prismjs/plugins/line-highlight/prism-line-highlight.js"
42+
]
43+
},
44+
"configurations": {
45+
"production": {
46+
"budgets": [
47+
{
48+
"type": "initial",
49+
"maximumWarning": "500kB",
50+
"maximumError": "1MB"
51+
},
52+
{
53+
"type": "anyComponentStyle",
54+
"maximumWarning": "2kB",
55+
"maximumError": "4kB"
56+
}
57+
],
58+
"outputHashing": "all"
59+
},
60+
"development": {
61+
"optimization": false,
62+
"extractLicenses": false,
63+
"sourceMap": true
64+
}
65+
},
66+
"defaultConfiguration": "production"
67+
},
68+
"serve": {
69+
"builder": "@angular-devkit/build-angular:dev-server",
70+
"configurations": {
71+
"production": {
72+
"buildTarget": "genkit-app:build:production"
73+
},
74+
"development": {
75+
"buildTarget": "genkit-app:build:development"
76+
}
77+
},
78+
"defaultConfiguration": "development"
79+
},
80+
"extract-i18n": {
81+
"builder": "@angular-devkit/build-angular:extract-i18n"
82+
},
83+
"test": {
84+
"builder": "@angular-devkit/build-angular:karma",
85+
"options": {
86+
"polyfills": ["zone.js", "zone.js/testing"],
87+
"tsConfig": "tsconfig.spec.json",
88+
"inlineStyleLanguage": "scss",
89+
"assets": [
90+
{
91+
"glob": "**/*",
92+
"input": "public"
93+
}
94+
],
95+
"styles": [
96+
"@angular/material/prebuilt-themes/azure-blue.css",
97+
"src/styles.scss"
98+
],
99+
"scripts": []
100+
}
101+
}
102+
}
103+
}
104+
}
105+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "genkit-app",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development",
9+
"test": "ng test"
10+
},
11+
"private": true,
12+
"dependencies": {
13+
"@angular/animations": "^18.0.0",
14+
"@angular/cdk": "^18.0.1",
15+
"@angular/common": "^18.0.0",
16+
"@angular/compiler": "^18.0.0",
17+
"@angular/core": "^18.0.0",
18+
"@angular/forms": "^18.0.0",
19+
"@angular/material": "^18.0.1",
20+
"@angular/platform-browser": "^18.0.0",
21+
"@angular/platform-browser-dynamic": "^18.0.0",
22+
"@angular/router": "^18.0.0",
23+
"marked": "^12.0.2",
24+
"ngx-markdown": "^18.0.0",
25+
"prismjs": "^1.29.0",
26+
"rxjs": "~7.8.0",
27+
"tslib": "^2.3.0",
28+
"zone.js": "~0.14.3",
29+
"genkit": "^0.9.0-rc || ^0.9"
30+
},
31+
"devDependencies": {
32+
"@angular-devkit/build-angular": "^18.0.2",
33+
"@angular/cli": "^18.0.2",
34+
"@angular/compiler-cli": "^18.0.0",
35+
"@types/jasmine": "~5.1.0",
36+
"jasmine-core": "~5.1.0",
37+
"karma": "~6.4.0",
38+
"karma-chrome-launcher": "~3.2.0",
39+
"karma-coverage": "~2.2.0",
40+
"karma-jasmine": "~5.1.0",
41+
"karma-jasmine-html-reporter": "~2.1.0",
42+
"typescript": "~5.4.2"
43+
}
44+
}
14.7 KB
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!--
2+
Copyright 2024 Google LLC
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
-->
16+
17+
<div class="wrapper">
18+
<mat-toolbar color="secondary">
19+
<a routerLink="/" class="home-link">Chat with an LLM</a>
20+
21+
<mat-tab-nav-panel #tabPanel></mat-tab-nav-panel>
22+
23+
<div class="flex-spacer"></div>
24+
<a
25+
mat-icon-button
26+
href="https://firebase.google.com/docs/genkit"
27+
matTooltip="Docs"
28+
target="_blank">
29+
<mat-icon>description</mat-icon>
30+
</a>
31+
</mat-toolbar>
32+
33+
<article>
34+
<router-outlet></router-outlet>
35+
</article>
36+
</div>

0 commit comments

Comments
 (0)