File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -278,6 +278,7 @@ def set_my_llm_cache(cache_file: Path=LLM_CACHE) -> SQLiteCache:
278
278
Set an LLM cache, which allows for previously executed completions to be
279
279
loaded from disk instead of repeatedly queried.
280
280
"""
281
+ cache_file .parent .mkdir (exist_ok = True )
281
282
set_llm_cache (SQLiteCache (database_path = cache_file ))
282
283
283
284
@dataclass ()
Original file line number Diff line number Diff line change 2
2
from llm_functions import get_summary_api_function , get_tags_api_function
3
3
import json
4
4
from firebase_admin import initialize_app
5
- from firebase_functions import https_fn
5
+ from firebase_functions import https_fn , options
6
6
7
7
initialize_app ()
8
8
app = Flask (__name__ )
@@ -28,7 +28,6 @@ def summary():
28
28
29
29
return jsonify (summary ["summary" ])
30
30
31
-
32
31
@app .route ("/tags" , methods = ["POST" ])
33
32
def tags ():
34
33
body = json .loads (request .data )
@@ -44,8 +43,11 @@ def tags():
44
43
45
44
return jsonify (tags ["tags" ])
46
45
46
+ @app .route ("/ready" , methods = ["GET" ])
47
+ def ready ():
48
+ return ""
47
49
48
- @https_fn .on_request (secrets = ["OPENAI_DEV" ])
50
+ @https_fn .on_request (secrets = ["OPENAI_DEV" ], timeout_sec = 300 , memory = options . MemoryOption . GB_1 )
49
51
def httpsflaskexample (req : https_fn .Request ) -> https_fn .Response :
50
52
with app .request_context (req .environ ):
51
53
return app .full_dispatch_request ()
Original file line number Diff line number Diff line change @@ -138,5 +138,20 @@ TODO:
138
138
139
139
- [x] Get an OpenAPI key `firebase functions:secrets:access OPENAI_DEV`
140
140
- [ ] Need to get docker running locally `yarn compose up --build`
141
- - [ ] Try to deploy the function `firebase deploy --only functions:maple-llm`
142
- - [ ] Alphabetize the requirements.txt file
141
+ - [x] Try to deploy the function `firebase deploy --only functions:maple-llm`
142
+ - [x] Alphabetize the requirements.txt file
143
+ - [ ] Add some deploying/testing from the command line notes
144
+ ```bash
145
+ # not sure if the GOOGLE_APPLICATION_CREDENTIALS is strictly necessary, but I
146
+ # had a number of problems with authorization
147
+ GOOGLE_APPLICATION_CREDENTIALS=/path/to/application_default_credentials.json \
148
+ firebase deploy --only functions:maple-llm --debug
149
+
150
+ # This is an example curl command for hitting the production function
151
+ curl \
152
+ -X POST \
153
+ -H "Content-Type: application/json" \
154
+ -H "Authorization: Bearer $(gcloud auth print-identity-token)" \
155
+ -d '{"bill_id": "1234","bill_title": "A title","bill_text": "Some bill text"}' \
156
+ https://httpsflaskexample-ke6znoupgq-uc.a.run.app/summary
157
+ ```
You can’t perform that action at this time.
0 commit comments