Spaces:
Runtime error
Runtime error
Commit
·
f6379c4
1
Parent(s):
cd38fcd
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,8 +5,12 @@ def call_chatbot_api(query):
|
|
| 5 |
url = 'https://hf-aichat-api.onrender.com/api/chat' #OKed
|
| 6 |
# url = 'https://hf-aichatboapi.onrender.com/api/chat' #Failed
|
| 7 |
# url = 'https://newaichatapi.onrender.com/api/chat' #Failed: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
|
| 8 |
-
data = {'query': query}
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
result = response.json()
|
| 11 |
return result['response']
|
| 12 |
|
|
|
|
| 5 |
url = 'https://hf-aichat-api.onrender.com/api/chat' #OKed
|
| 6 |
# url = 'https://hf-aichatboapi.onrender.com/api/chat' #Failed
|
| 7 |
# url = 'https://newaichatapi.onrender.com/api/chat' #Failed: JSONDecodeError: Expecting value: line 1 column 1 (char 0)
|
| 8 |
+
#data = {'query': query}
|
| 9 |
+
#在API设置中,将#user_query = data['query']中的query修改为user_question,因此在此处的API调用代码中,需要相应的使用data = {'user_question': query}
|
| 10 |
+
data = {'user_question': query}
|
| 11 |
+
#data sample示例: {'query': 'Hello'},这个就是json格式,然后,这个data将作为json传递给API(在API设置的data = request.get_json()中被提取并赋值给data)
|
| 12 |
+
#这个API调用程序代码,首先是为API准备数据,并且是json格式的
|
| 13 |
+
response = requests.post(url, json=data)
|
| 14 |
result = response.json()
|
| 15 |
return result['response']
|
| 16 |
|