Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -45,20 +45,20 @@ def request_to_v2(message, cookie, user_id, channel_id,context=[]):
|
|
45 |
|
46 |
try:
|
47 |
response = requests.post(post_msg_url, headers=headers, data=post_msg_data, verify=False,timeout = timeout,impersonate="chrome110")
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
bots += data_json["completion"]
|
59 |
print(bots)
|
60 |
context += [bots]
|
61 |
responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
|
|
|
62 |
return responses, context
|
63 |
|
64 |
except Exception as e:
|
|
|
45 |
|
46 |
try:
|
47 |
response = requests.post(post_msg_url, headers=headers, data=post_msg_data, verify=False,timeout = timeout,impersonate="chrome110")
|
48 |
+
decoded_data = response.content.decode("utf-8")
|
49 |
+
decoded_data = re.sub('\n+', '\n', decoded_data).strip()
|
50 |
+
data_strings = decoded_data.split('\n')
|
51 |
+
completions = []
|
52 |
+
for data_string in data_strings:
|
53 |
+
json_str = data_string[6:].strip()
|
54 |
+
data = json.loads(json_str)
|
55 |
+
if 'completion' in data:
|
56 |
+
completions.append(data['completion'])
|
57 |
+
bots = ''.join(completions)
|
|
|
58 |
print(bots)
|
59 |
context += [bots]
|
60 |
responses = [(u, b) for u, b in zip(context[::2], context[1::2])]
|
61 |
+
print("a"*100)
|
62 |
return responses, context
|
63 |
|
64 |
except Exception as e:
|