Spaces:
Runtime error
Runtime error
Commit
·
6765a9d
1
Parent(s):
1a96d1f
Update main.py
Browse files
main.py
CHANGED
|
@@ -47,10 +47,10 @@ llm_chain = LLMChain(llm=llm, prompt=PromptTemplate.from_template(prompt_templat
|
|
| 47 |
|
| 48 |
# 定义API端点
|
| 49 |
app = Flask(__name__)
|
| 50 |
-
|
| 51 |
-
|
| 52 |
#def chat():
|
| 53 |
-
def chat():
|
| 54 |
data = request.get_json()
|
| 55 |
#user_query = data['query']
|
| 56 |
#此处的['query']中的query可以自定义名称,例如修改为user_question,那么调用API的代码中,需要相应的使用data = {'user_question': user_query},user_question需一致
|
|
@@ -58,6 +58,7 @@ def chat():
|
|
| 58 |
# 调用Chatbot
|
| 59 |
initial_response = llm_chain.run(user_query)
|
| 60 |
#return jsonify({'response': initial_response})
|
|
|
|
| 61 |
return {'response': initial_response}
|
| 62 |
|
| 63 |
#if __name__ == "__main__":
|
|
|
|
| 47 |
|
| 48 |
# 定义API端点
|
| 49 |
app = Flask(__name__)
|
| 50 |
+
#@app.route('/', methods=['POST'])
|
| 51 |
+
@app.route('/api/chat', methods=['POST'])
|
| 52 |
#def chat():
|
| 53 |
+
async def chat():
|
| 54 |
data = request.get_json()
|
| 55 |
#user_query = data['query']
|
| 56 |
#此处的['query']中的query可以自定义名称,例如修改为user_question,那么调用API的代码中,需要相应的使用data = {'user_question': user_query},user_question需一致
|
|
|
|
| 58 |
# 调用Chatbot
|
| 59 |
initial_response = llm_chain.run(user_query)
|
| 60 |
#return jsonify({'response': initial_response})
|
| 61 |
+
#找到问题了:jsonify在Huggingface不支持;在Github然后部署到Render是可以的!
|
| 62 |
return {'response': initial_response}
|
| 63 |
|
| 64 |
#if __name__ == "__main__":
|