-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapp.py
53 lines (38 loc) · 1.17 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
49
50
51
52
53
from flask import Flask, render_template
from flask import request, jsonify, abort
from langchain.llms import Cohere
app = Flask(__name__)
def answer_from_knowledgebase(message):
# TODO: Write your code here
return ""
def search_knowledgebase(message):
# TODO: Write your code here
sources = ""
return sources
def answer_as_chatbot(message):
# TODO: Write your code here
return ""
@app.route('/kbanswer', methods=['POST'])
def kbanswer():
# TODO: Write your code here
# call answer_from_knowledebase(message)
# Return the response as JSON
return
@app.route('/search', methods=['POST'])
def search():
# Search the knowledgebase and generate a response
# (call search_knowledgebase())
# Return the response as JSON
return
@app.route('/answer', methods=['POST'])
def answer():
message = request.json['message']
# Generate a response
response_message = answer_as_chatbot(message)
# Return the response as JSON
return jsonify({'message': response_message}), 200
@app.route("/")
def index():
return render_template("index.html", title="")
if __name__ == "__main__":
app.run()