-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
48 lines (35 loc) · 1.42 KB
/
app.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
# app.py
from flask import Flask, render_template, request, jsonify
import search
import analysis
import output
import summarizer
import requests
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/submit', methods=['POST'])
def submit():
data = request.get_json()
prompt = data['prompt']
query = data.get('query', None)
# Fetch the search results
search_results = search.get_search_results(query, prompt)
# Pass the prompt to the get_search_results function
research_body, case_infos = analysis.filter_and_rank_cases(prompt, query, search_results)
# Analyze and rank the results
results, case_infos = analysis.filter_and_rank_cases(prompt, query, search_results)
# Generate the response
answer, summarize_buttons = output.generate_response(prompt, results, case_infos)
return jsonify({"answer": answer, "summarize_buttons": summarize_buttons})
@app.route('/summarize', methods=['POST'])
def summarize():
data = request.get_json()
url = data['url'] # Update to use JSON URL
response = requests.get(url)
case_data = response.json() # Parse the response as JSON
summary = summarizer.summarize_case(url) # Pass the parsed JSON data to the summarize_case function
return jsonify({"summary": summary})
# if __name__ == '__main__':
# app.run(debug=true)