generated from amosproj/amos202Xss0Y-projname
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
27 lines (22 loc) · 1.02 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from json import dumps
# from handlers import get_response_from_llm
from chain import hist_aware_answers
from firebase_functions import https_fn, options
@https_fn.on_request(memory=options.MemoryOption.GB_32, cpu=8, timeout_sec=540)
def get_response_url(req: https_fn.Request) -> https_fn.Response:
query = req.get_json().get('query', '')
llms = req.get_json().get('llms', ['gpt-4', 'gemini', 'claude'])
chat = req.get_json().get('history', [])
responses = {}
for llm in llms:
responses[llm] = hist_aware_answers(llm, query, chat)
return https_fn.Response(dumps(responses), mimetype='application/json')
@https_fn.on_call(memory=options.MemoryOption.GB_32, cpu=8, timeout_sec=540)
def get_response(req: https_fn.CallableRequest):
query = req.data.get('query', '')
llms = req.get_json().get('llms', ['gpt-4', 'gemini', 'claude'])
chat = req.get_json().get('history', [])
responses = {}
for llm in llms:
responses[llm] = hist_aware_answers(llm, query, chat)
return responses