Spaces:
Sleeping
Sleeping
Commit
·
207a907
1
Parent(s):
ec91b3f
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,6 +15,8 @@ load_dotenv()
|
|
| 15 |
from huggingface_hub import InferenceClient
|
| 16 |
from langchain import HuggingFaceHub
|
| 17 |
import requests
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# 初始化Chatbot
|
| 20 |
HUGGINGFACEHUB_API_TOKEN = os.getenv('HUGGINGFACEHUB_API_TOKEN')
|
|
@@ -44,10 +46,12 @@ def chat():
|
|
| 44 |
data = request.get_json()
|
| 45 |
#user_query = data['query']
|
| 46 |
#此处的['query']中的query可以自定义名称,例如修改为user_question,那么调用API的代码中,需要相应的使用data = {'user_question': user_query},user_question需一致
|
| 47 |
-
user_query = data['user_question']
|
|
|
|
| 48 |
#temp_user_query=user_query
|
| 49 |
# 调用Chatbot
|
| 50 |
initial_response = llm_chain.run(user_query)
|
|
|
|
| 51 |
#st.write("AI Response")
|
| 52 |
#st.write(initial_response)
|
| 53 |
return jsonify({'response': initial_response})
|
|
|
|
| 15 |
from huggingface_hub import InferenceClient
|
| 16 |
from langchain import HuggingFaceHub
|
| 17 |
import requests
|
| 18 |
+
import uuid
|
| 19 |
+
import sys
|
| 20 |
|
| 21 |
# 初始化Chatbot
|
| 22 |
HUGGINGFACEHUB_API_TOKEN = os.getenv('HUGGINGFACEHUB_API_TOKEN')
|
|
|
|
| 46 |
data = request.get_json()
|
| 47 |
#user_query = data['query']
|
| 48 |
#此处的['query']中的query可以自定义名称,例如修改为user_question,那么调用API的代码中,需要相应的使用data = {'user_question': user_query},user_question需一致
|
| 49 |
+
user_query = data['user_question']
|
| 50 |
+
print("API Input:"+user_query)
|
| 51 |
#temp_user_query=user_query
|
| 52 |
# 调用Chatbot
|
| 53 |
initial_response = llm_chain.run(user_query)
|
| 54 |
+
print("API Call Output:"+initial_response)
|
| 55 |
#st.write("AI Response")
|
| 56 |
#st.write(initial_response)
|
| 57 |
return jsonify({'response': initial_response})
|