Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -46,14 +46,20 @@ def request_to_v2(message, cookie, user_id, channel_id,context=[]):
|
|
46 |
response = requests.post(post_msg_url, headers=headers, data=post_msg_data, verify=False, stream=False)
|
47 |
print(response)
|
48 |
|
49 |
-
print(response.status_code)
|
50 |
-
print(response.request)
|
51 |
bots = ""
|
52 |
print("*"*100)
|
53 |
for data in response.iter_lines():
|
54 |
if data:
|
55 |
print(data)
|
56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
print(data_json)
|
58 |
|
59 |
bots = bots + data_json["completion"]
|
|
|
46 |
response = requests.post(post_msg_url, headers=headers, data=post_msg_data, verify=False, stream=False)
|
47 |
print(response)
|
48 |
|
49 |
+
# print(response.status_code)
|
50 |
+
# print(response.request)
|
51 |
bots = ""
|
52 |
print("*"*100)
|
53 |
for data in response.iter_lines():
|
54 |
if data:
|
55 |
print(data)
|
56 |
+
# 将字节字符串转换为字符串
|
57 |
+
data_str = data.decode('utf-8')
|
58 |
+
|
59 |
+
# 删除开头的 "data: " 部分
|
60 |
+
data_str = data_str.replace("data: ", "")
|
61 |
+
|
62 |
+
data_json = json.loads(data_str)
|
63 |
print(data_json)
|
64 |
|
65 |
bots = bots + data_json["completion"]
|