Skip to content

Commit d73a231

Browse files
committed
Working on required changes to deploy via firebase
1 parent 9275393 commit d73a231

File tree

6 files changed

+31
-19
lines changed

6 files changed

+31
-19
lines changed

firebase.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,20 @@
44
"cleanUrls": true,
55
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"]
66
},
7-
"functions": {
8-
"predeploy": ["yarn build:functions"],
9-
"source": "functions",
10-
"runtime": "nodejs18",
11-
"runtimeConfig": ".runtimeconfig.json"
12-
},
7+
"functions": [
8+
{
9+
"predeploy": ["yarn build:functions"],
10+
"source": "functions",
11+
"codebase": "maple",
12+
"runtime": "nodejs18"
13+
"runtimeConfig": ".runtimeconfig.json"
14+
},
15+
{
16+
"source": "llm",
17+
"codebase": "maple-llm",
18+
"runtime": "python312"
19+
}
20+
],
1321
"firestore": {
1422
"rules": "firestore.rules",
1523
"indexes": "firestore.indexes.json"

llm/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
llm-api/
1+
venv/
22
__pycache__/
33
databases/

llm/cloudbuild.yaml

Lines changed: 0 additions & 4 deletions
This file was deleted.

llm/api.py renamed to llm/main.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
from flask import Flask, jsonify, abort, request
22
from llm_functions import get_summary_api_function, get_tags_api_function
33
import json
4+
from firebase_admin import initialize_app
5+
from firebase_functions import https_fn
46

7+
initialize_app()
58
app = Flask(__name__)
69

710

@@ -40,3 +43,9 @@ def tags():
4043
abort(500, description="Unable to generate tags")
4144

4245
return jsonify(tags["tags"])
46+
47+
48+
@https_fn.on_request(secrets=["OPENAI_DEV"])
49+
def httpsflaskexample(req: https_fn.Request) -> https_fn.Response:
50+
with app.request_context(req.environ):
51+
return app.full_dispatch_request()

llm/readme.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,17 +128,14 @@ This project uses OpenAI's API for various language processing tasks. To use the
128128
Set up a virtual environment and run the Flask app
129129
130130
```
131-
python3 -m venv llm-api
132-
source llm-api/bin/activate # .fish if using fish
131+
python3 -m venv venv
132+
source venv/bin/activate # .fish if using fish
133133
pip3 install -r requirements.txt
134-
python3 -m flask --app api run
134+
python3 -m flask --app main run
135135
```
136136
137137
TODO:
138138
139-
- [ ] Get an OpenAPI key
140-
- [ ] Attempt to run the summary function locally using the flask API
141-
- [ ] Try to add deploy this using cloud functions and `cloudbuild.yaml`
142-
Found some cloud functions documentation here,
143-
https://medium.com/@rez.archer/mastering-serverless-flask-apis-on-google-cloud-a-ci-cd-pipeline-setup-253b6de1c1ad
139+
- [x] Get an OpenAPI key `firebase functions:secrets:access OPENAI_DEV`
140+
- [ ] Try to deploy the function `firebase deploy --only functions:maple-llm`
144141
- [ ] Alphabetize the requirements.txt file

llm/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,3 +185,5 @@ Flask==3.1.0
185185
itsdangerous==2.2.0
186186
Werkzeug==3.1.3
187187
pytest==8.3.5
188+
firebase-admin==6.7.0
189+
firebase-functions==0.4.2

0 commit comments

Comments
 (0)