-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathmain.py
More file actions
36 lines (29 loc) · 1.26 KB
/
main.py
File metadata and controls
36 lines (29 loc) · 1.26 KB
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
28
29
30
31
32
33
34
35
36
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(cors=options.CorsOptions(cors_origins=['*']))
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', [])
print(chat)
responses = {}
for llm in llms:
responses = hist_aware_answers(llm, query) # , chat_history)
# responses[llm] = response
return https_fn.Response(dumps(responses), mimetype='application/json')
@https_fn.on_call()
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', [])
print(chat)
responses = {}
for llm in llms:
responses = hist_aware_answers(llm, query) # , chat_history)
# responses[llm] = response
return responses
@https_fn.on_request(cors=options.CorsOptions(cors_origins=['*']))
def get_test(req: https_fn.Request) -> https_fn.Response:
return https_fn.Response('Hello World!', mimetype='application/json')