-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
30 lines (25 loc) · 952 Bytes
/
app.py
File metadata and controls
30 lines (25 loc) · 952 Bytes
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 Flask, render_template, request
from agent_builder import ProductAgent
from exception import CustomException
import markdown
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def index():
response = None
error = None
if request.method == 'POST':
try:
task = request.form.get('query')
if not task:
error = "Please enter a search query"
else:
product_agent = ProductAgent()
agent_response = product_agent.perform_task(task)
response_content = agent_response.content
# Convert response to HTML for proper rendering
response = markdown.markdown(str(response_content))
except Exception as e:
raise CustomException(e)
return render_template('index.html', response=response, error=error)
if __name__ == "__main__":
app.run(debug=True)