-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
40 lines (31 loc) · 1.17 KB
/
Copy pathmain.py
File metadata and controls
40 lines (31 loc) · 1.17 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
37
38
39
40
from flask import Flask, request, render_template, jsonify
from dotenv import load_dotenv
from utils import store_docs, get_response, get_chroma_client
# Load the OPENAI KEY from the env.sh file
load_dotenv('env.sh') # Specify path to your env file
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/process', methods=['POST'])
def process():
data = request.json
url = data['url']
organization_name = data['organization_name']
organization_info = data['organization_info']
contact_info = data['contact_info']
# Store webpage content into vector store
store_docs(url)
return jsonify({'message': 'Content processed successfully!'})
@app.route('/ask', methods=['POST'])
def ask():
data = request.json
question = data['question']
organization_name = data['organization_name']
organization_info = data['organization_info']
contact_info = data['contact_info']
# Get response
response = get_response(question, organization_name, organization_info, contact_info)
return jsonify({'answer': response, 'question': question})
if __name__ == "__main__":
app.run(debug=True)