Skip to content

Commit 7901748

Browse files
committed
Initial working commit
1 parent 69f46cc commit 7901748

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

infra/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
build:
3030
context: ..
3131
dockerfile: infra/Dockerfile.firebase
32-
command: yarn emulators:start
32+
command: yarn emulators:start --debug # TODO: REMOVE THIS
3333
working_dir: /app
3434
depends_on:
3535
init:

infra/firebase.compose.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"runtime": "nodejs18"
1313
},
1414
{
15-
"predeploy": ["source /app/llm/venv/bin/activate && python3.10 -m pip install -r /app/llm/requirements.txt"],
15+
"predeploy": [". llm/venv/bin/activate && python3.10 -m pip install -r llm/requirements.txt"],
1616
"source": "llm",
1717
"codebase": "maple-llm",
1818
"runtime": "python310"

llm/main.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from firebase_admin import initialize_app
55
from firebase_functions import https_fn, options
6+
import os
67

78
initialize_app()
89
app = Flask(__name__)
@@ -12,8 +13,14 @@ def is_intersection(keys, required_keys):
1213
return (keys & required_keys) == required_keys
1314

1415

16+
def set_openai_api_key():
17+
if os.environ.get("OPENAI_DEV") != None:
18+
os.environ["OPENAI_API_KEY"] = os.environ["OPENAI_DEV"]
19+
20+
1521
@app.route("/summary", methods=["POST"])
1622
def summary():
23+
set_openai_api_key()
1724
body = json.loads(request.data)
1825
# We require bill_id, bill_title, bill_text to exist as keys in the POST
1926
if not is_intersection(body.keys(), {"bill_id", "bill_title", "bill_text"}):
@@ -28,8 +35,10 @@ def summary():
2835

2936
return jsonify(summary["summary"])
3037

38+
3139
@app.route("/tags", methods=["POST"])
3240
def tags():
41+
set_openai_api_key()
3342
body = json.loads(request.data)
3443
# We require bill_id, bill_title, bill_text to exist as keys in the POST
3544
# Note: & is essentially set intersection
@@ -43,11 +52,15 @@ def tags():
4352

4453
return jsonify(tags["tags"])
4554

55+
4656
@app.route("/ready", methods=["GET"])
4757
def ready():
4858
return ""
4959

50-
@https_fn.on_request(secrets=["OPENAI_DEV"], timeout_sec=300, memory=options.MemoryOption.GB_1)
60+
61+
@https_fn.on_request(
62+
secrets=["OPENAI_DEV"], timeout_sec=300, memory=options.MemoryOption.GB_1
63+
)
5164
def httpsflaskexample(req: https_fn.Request) -> https_fn.Response:
5265
with app.request_context(req.environ):
5366
return app.full_dispatch_request()

0 commit comments

Comments
 (0)