binqiangliu commited on
Commit
58793fb
·
1 Parent(s): 28e3292

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -5
app.py CHANGED
@@ -1,11 +1,16 @@
1
  import requests
 
2
  def call_chatbot_api(query):
3
- url = 'https://hf-aichat-api.onrender.com/api/chat' # /api/chat前面使用api.py部署后获得的URL
4
  data = {'query': query}
5
  response = requests.post(url, json=data)
6
  result = response.json()
7
  return result['response']
8
- # 调用Chatbot API
9
- user_query = "hello" # 用户查询,置于英文的""之内
10
- response = call_chatbot_api(user_query)
11
- print(response) # 打印Chatbot的响应
 
 
 
 
 
1
  import requests
2
+
3
  def call_chatbot_api(query):
4
+ url = 'https://hf-aichat-api.onrender.com/api/chat'
5
  data = {'query': query}
6
  response = requests.post(url, json=data)
7
  result = response.json()
8
  return result['response']
9
+
10
+ user_query = st.text_input("Enter your query here:")
11
+ with st.spinner("AI Thinking...Please wait a while to Cheers!"):
12
+ if user_query !="" and not user_query.strip().isspace() and not user_query == "" and not user_query.strip() == "" and not user_query.isspace():
13
+ response = call_chatbot_api(user_query)
14
+ st.write("AI Response:")
15
+ st.write(response)
16
+ print(response) # 打印Chatbot的响应