Skip to content

Commit

Permalink
Merge pull request #22 from nozomi-koborinai/feature/update-prompts
Browse files Browse the repository at this point in the history
Update prompts
  • Loading branch information
nozomi-koborinai authored Jan 2, 2025
2 parents 370f0f2 + 44b9dd2 commit ccdb458
Show file tree
Hide file tree
Showing 27 changed files with 510 additions and 275 deletions.
File renamed without changes.
16 changes: 8 additions & 8 deletions .github/workflows/backend-cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ on:
branches:
- main
paths:
- "functions/**"
- 'prompts/**'
- 'src/**'

jobs:
changes:
Expand All @@ -27,10 +28,11 @@ jobs:
with:
filters: |
genkit_functions:
- 'functions/**'
- 'prompts/**'
- 'src/**'
deploy_functions:
name: Deploy Functions
name: Deploy Cloud Run Functions
needs:
- changes
if: ${{ needs.changes.outputs.genkit_functions == 'true' }}
Expand All @@ -43,8 +45,8 @@ jobs:
- name: Check out repository
uses: actions/checkout@v3

- name: "Authenticate to Google Cloud"
uses: "google-github-actions/auth@v2"
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: ${{ secrets.WORKLOAD_IDENTITY_PROVIDER_FB }}
service_account: ${{ secrets.SERVICE_ACCOUNT_MAIL_FB }}
Expand All @@ -54,14 +56,12 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- name: Install Dependencies
run: npm install
working-directory: ./functions

- name: Deploy to Functions
run: |
npm install -g firebase-tools
firebase deploy --only functions --force --project=${{ secrets.PROJECT_ID }}
working-directory: ./functions
10 changes: 5 additions & 5 deletions .github/workflows/backend-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ name: CI for Cloud Run Functions on Firebase
on:
pull_request:
paths:
- 'functions/**'
- 'prompts/**'
- 'src/**'
types:
- opened
- synchronize
Expand All @@ -28,7 +29,8 @@ jobs:
with:
filters: |
genkit_functions:
- 'functions/**'
- 'prompts/**'
- 'src/**'
functions_ci:
name: Cloud Run Functions CI
Expand All @@ -47,12 +49,10 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20

- name: Install Dependencies
run: npm install
working-directory: ./functions

- name: Check for linting errors
run: npm run lint
working-directory: ./functions
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ node_modules/
# dataconnect generated files
.dataconnect

.vscode
lib
.vscode
.genkit
File renamed without changes.
83 changes: 65 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,74 @@
# firebase-genkit-sample

## Article
- [English](https://medium.com/@kobofender/orchestrating-firebase-and-ai-8-genkit-architecture-patterns-12e44db40345)
- [Japanese](https://zenn.dev/nozomi_cobo/articles/genkit-architecture)
A sample project demonstrating AI applications using Firebase Cloud Run functions (2nd generation) and Genkit.

## Directory Structure
## 🚀 Features

- Image Analysis (Google AI)
- Web Content Analysis (Google AI)
- Chat Message Generation (Google AI & Firestore)
- Image Generation (Vertex AI)

## 📁 Project Structure

```plain
firebase-genkit-sample/
├── functions/
│ ├── src/
│ │ ├── genkit-functions/
│ │ └── utils/
│ └── prompts/
├── terraform/
└── README.md
├── .github/
│ └── workflows/ # CI/CD Pipelines sample
├── prompts/ # AI prompt templates
├── src/
│ ├── genkit-functions/ # AI function implementations
│ ├── genkit.ts # Genkit configuration
│ └── index.ts # Deploy Functions
└── terraform/ # Terraform configuration for infrastructure setup (not directly related to Genkit, but used for setting up the overall Firebase project infrastructure)
```

## 🛠 Quick Start

0. Install Genkit CLI

```bash
npm i -g genkit
```

## Key Directories and Files
1. Install dependencies

```bash
npm install
```

2. Set environment variables

```bash
export GCLOUD_PROJECT="your-google-cloud-project-id"
export GOOGLE_GENAI_API_KEY="your-api-key"
export GENKIT_ENV="dev"
```

3. Start Genkit emulator for development

```bash
genkit start -- npx tsx --watch src/index.ts
or
genkit start -- firebase emulators:start --inspect-functions
```

4. Deploy to Cloud Run functions (2nd generation)

```bash
firebase deploy --only functions
```

## 📚 Articles

### English

- [Orchestrating Firebase and AI: 8 Genkit Architecture Patterns](https://medium.com/@nozomi-koborinai/orchestrating-firebase-and-ai-8-genkit-architecture-patterns-12e44db40345)
- [How to Develop Firebase Genkit Functions](https://medium.com/@nozomi-koborinai/how-to-develop-firebase-genkit-functions-2677b386a227)
- [Getting Started with AI Image Generation Apps on Flutter, Genkit, and Imagen 3](https://medium.com/@nozomi-koborinai/getting-started-with-ai-image-generation-apps-on-flutter-genkit-and-imagen-3-9a83c63cbdf3)

### Japanese

- `functions/`: Contains Cloud Run Functions for Firebase code
- `src/genkit-functions/`: Genkit function implementations
- `src/utils/`: Utility functions and helpers
- `prompts/`: AI prompt templates
- `terraform/`: Terraform configuration for infrastructure setup (not directly related to Genkit, but used for setting up the overall Firebase project infrastructure)
- `README.md`: This file, providing an overview of the project
- [Firebase & AI のオーケストレーションを実現!Genkit アーキテクチャ 8 選](https://zenn.dev/nozomi_cobo/articles/genkit-architecture)
- [Firebase Genkit Functions 開発のすゝめ](https://zenn.dev/nozomi_cobo/articles/genkit-emulator-suite)
- [Flutter × Genkit × Imagen 3 で始める AI 画像生成アプリ開発入門](https://zenn.dev/nozomi_cobo/articles/flutter-genkit-imagen)
17 changes: 1 addition & 16 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"functions": [
{
"source": "functions",
"source": ".",
"codebase": "default",
"ignore": [
"node_modules",
Expand All @@ -26,21 +26,6 @@
"firestore": {
"port": 8080
},
"database": {
"port": 9000
},
"hosting": {
"port": 5000
},
"pubsub": {
"port": 8085
},
"eventarc": {
"port": 9299
},
"tasks": {
"port": 9499
},
"ui": {
"enabled": true
},
Expand Down
10 changes: 0 additions & 10 deletions functions/.gitignore

This file was deleted.

32 changes: 0 additions & 32 deletions functions/src/genkit-functions/analyzeImageFlow.ts

This file was deleted.

56 changes: 0 additions & 56 deletions functions/src/genkit-functions/analyzeWebContentsFlow.ts

This file was deleted.

54 changes: 0 additions & 54 deletions functions/src/genkit-functions/generateChatMessageFlow.ts

This file was deleted.

Loading

0 comments on commit ccdb458

Please sign in to comment.