-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathviews.py
30 lines (23 loc) · 1 KB
/
views.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
from flask import Blueprint, render_template, request
import chroma, googledocs
from query import get_completion_from_local
views = Blueprint(__name__, "views")
@views.route("/")
def index():
return render_template("home.html")
@views.route("/submit", methods=["POST"])
def submit():
if request.method == "POST":
google_link = request.form.get("inputField")
input_data = googledocs.getContent(google_link)
chroma.addToCollection(input_data, 'googleDocs')
return render_template("home.html", process_data=None)
@views.route("/query", methods=["POST"])
def query():
if request.method == "POST":
# example: "What might be causing my anxiety?"
query = request.form.get("queryField")
resp = chroma.getRelevantResponses(query)
# completion = get_completion_from_openassistant(query, resp['documents'])
completion = get_completion_from_local(query, resp['documents'])
return render_template("home.html", processed_data=completion)