-
Notifications
You must be signed in to change notification settings - Fork 0
/
summary.py
59 lines (41 loc) · 1.16 KB
/
summary.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import requests as rq
# with open('test.txt', 'r', encoding='utf-8') as f:
# url = "http://185.189.167.245:8000/summarize"
# data = {
# 'dialog': f.read()
# }
# resp = rq.post(url, json=data)
# print(resp.status_code)
# if resp.status_code == 200:
# res = resp.json()
# print(res)
# @app.route('/rag-answer', methods=['POST'])
# def rag_answer():
# # data = request.json
# # context = data['context']
# # query = data['query']
# url = "http://185.189.167.245:8000/rag-answer"
# data = {
# 'context': msg_history.to_json(),
# 'query': question
# }
# answer = get_rag_answer(context, query)
# return jsonify({"answer": answer})
class SummaryAI:
def __init__(self):
pass
def get_summary(self, msg_history):
url = "http://185.189.167.245:8000/summarize"
data = {
'table': msg_history.to_json(force_ascii=False)
}
resp = rq.post(url, json=data).json()
return resp['summary']
def answer_question(self, msg_history, question = ''):
url = "http://185.189.167.245:8000/rag-answer"
data = {
'table': msg_history.to_json(force_ascii=False),
'query': question
}
resp = rq.post(url, json=data).json()
return resp['answer']