t.me/xtekky
commited on
Commit
·
76571f2
1
Parent(s):
24f10a3
updated poe api (gpt4)
Browse filesfixed tls_client issue by switching to request Session, and update the poe api
- poe/__init__.py +2 -3
- poe/api.py +116 -31
- poe/cookies.txt +6 -0
- poe/graphql/ChatListPaginationQuery.graphql +69 -7
- poe/graphql/SendMessageMutation.graphql +40 -0
- testing/poe_test.py +13 -0
poe/__init__.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
from poe.api import Client as PoeClient
|
2 |
from poe.mail import Mail
|
3 |
-
from
|
4 |
from re import search, findall
|
5 |
from json import loads
|
6 |
from time import sleep, time
|
@@ -48,11 +48,10 @@ class PoeResponse:
|
|
48 |
def json(self) -> dict:
|
49 |
return self.response_dict
|
50 |
|
51 |
-
|
52 |
class Account:
|
53 |
def create(proxy: None or str = None, logging: bool = False):
|
54 |
|
55 |
-
client = Session(
|
56 |
client.proxies = {
|
57 |
'http': f'http://{proxy}',
|
58 |
'https': f'http://{proxy}'} if proxy else None
|
|
|
1 |
from poe.api import Client as PoeClient
|
2 |
from poe.mail import Mail
|
3 |
+
from requests import Session
|
4 |
from re import search, findall
|
5 |
from json import loads
|
6 |
from time import sleep, time
|
|
|
48 |
def json(self) -> dict:
|
49 |
return self.response_dict
|
50 |
|
|
|
51 |
class Account:
|
52 |
def create(proxy: None or str = None, logging: bool = False):
|
53 |
|
54 |
+
client = Session()
|
55 |
client.proxies = {
|
56 |
'http': f'http://{proxy}',
|
57 |
'https': f'http://{proxy}'} if proxy else None
|
poe/api.py
CHANGED
@@ -22,6 +22,7 @@ import logging
|
|
22 |
import time
|
23 |
import queue
|
24 |
import threading
|
|
|
25 |
import websocket
|
26 |
from pathlib import Path
|
27 |
from urllib.parse import urlparse
|
@@ -124,6 +125,15 @@ class Client:
|
|
124 |
|
125 |
return next_data
|
126 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
def get_bots(self):
|
128 |
viewer = self.next_data["props"]["pageProps"]["payload"]["viewer"]
|
129 |
if not "availableBots" in viewer:
|
@@ -132,13 +142,7 @@ class Client:
|
|
132 |
|
133 |
bots = {}
|
134 |
for bot in bot_list:
|
135 |
-
|
136 |
-
logger.info("Downloading "+url)
|
137 |
-
|
138 |
-
r = request_with_retries(self.session.get, url)
|
139 |
-
|
140 |
-
chat_data = r.json()[
|
141 |
-
"pageProps"]["payload"]["chatOfBotDisplayName"]
|
142 |
bots[chat_data["defaultBotObject"]["nickname"]] = chat_data
|
143 |
|
144 |
return bots
|
@@ -165,11 +169,8 @@ class Client:
|
|
165 |
return f'wss://{self.ws_domain}.tch.{channel["baseHost"]}/up/{channel["boxName"]}/updates'+query
|
166 |
|
167 |
def send_query(self, query_name, variables):
|
168 |
-
# print(f'send_query: {query_name} {variables}')
|
169 |
-
|
170 |
for i in range(20):
|
171 |
payload = generate_payload(query_name, variables)
|
172 |
-
# print(f'query_payload: {query_name} {variables}')
|
173 |
r = request_with_retries(
|
174 |
self.session.post, self.gql_url, json=payload, headers=self.gql_headers)
|
175 |
data = r.json()
|
@@ -216,7 +217,8 @@ class Client:
|
|
216 |
header={"User-Agent": user_agent},
|
217 |
on_message=self.on_message,
|
218 |
on_open=self.on_ws_connect,
|
219 |
-
on_error=self.on_ws_error
|
|
|
220 |
)
|
221 |
t = threading.Thread(target=self.ws_run_thread, daemon=True)
|
222 |
t.start()
|
@@ -231,27 +233,44 @@ class Client:
|
|
231 |
def on_ws_connect(self, ws):
|
232 |
self.ws_connected = True
|
233 |
|
|
|
|
|
|
|
|
|
234 |
def on_ws_error(self, ws, error):
|
235 |
-
logger.warn(f"Websocket returned error: {error}")
|
236 |
self.disconnect_ws()
|
237 |
self.connect_ws()
|
238 |
|
239 |
def on_message(self, ws, msg):
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
copied_dict = self.active_messages.copy()
|
245 |
-
for key, value in copied_dict.items():
|
246 |
-
# add the message to the appropriate queue
|
247 |
-
if value == message["messageId"] and key in self.message_queues:
|
248 |
-
self.message_queues[key].put(message)
|
249 |
return
|
250 |
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
|
256 |
def send_message(self, chatbot, message, with_chat_break=False, timeout=20):
|
257 |
# if there is another active message, wait until it has finished sending
|
@@ -262,8 +281,11 @@ class Client:
|
|
262 |
self.active_messages["pending"] = None
|
263 |
|
264 |
logger.info(f"Sending message to {chatbot}: {message}")
|
265 |
-
|
266 |
-
|
|
|
|
|
|
|
267 |
"bot": chatbot,
|
268 |
"query": message,
|
269 |
"chatId": self.bots[chatbot]["chatId"],
|
@@ -272,11 +294,11 @@ class Client:
|
|
272 |
})
|
273 |
del self.active_messages["pending"]
|
274 |
|
275 |
-
if not message_data["data"]["
|
276 |
raise RuntimeError(f"Daily limit reached for {chatbot}.")
|
277 |
try:
|
278 |
-
human_message = message_data["data"]["
|
279 |
-
human_message_id = human_message["
|
280 |
except TypeError:
|
281 |
raise RuntimeError(
|
282 |
f"An unknown error occured. Raw response data: {message_data}")
|
@@ -313,4 +335,67 @@ class Client:
|
|
313 |
del self.active_messages[human_message_id]
|
314 |
del self.message_queues[human_message_id]
|
315 |
|
316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
import time
|
23 |
import queue
|
24 |
import threading
|
25 |
+
import traceback
|
26 |
import websocket
|
27 |
from pathlib import Path
|
28 |
from urllib.parse import urlparse
|
|
|
125 |
|
126 |
return next_data
|
127 |
|
128 |
+
def get_bot(self, display_name):
|
129 |
+
url = f'https://poe.com/_next/data/{self.next_data["buildId"]}/{display_name}.json'
|
130 |
+
logger.info("Downloading "+url)
|
131 |
+
|
132 |
+
r = request_with_retries(self.session.get, url)
|
133 |
+
|
134 |
+
chat_data = r.json()["pageProps"]["payload"]["chatOfBotDisplayName"]
|
135 |
+
return chat_data
|
136 |
+
|
137 |
def get_bots(self):
|
138 |
viewer = self.next_data["props"]["pageProps"]["payload"]["viewer"]
|
139 |
if not "availableBots" in viewer:
|
|
|
142 |
|
143 |
bots = {}
|
144 |
for bot in bot_list:
|
145 |
+
chat_data = self.get_bot(bot["displayName"].lower())
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
bots[chat_data["defaultBotObject"]["nickname"]] = chat_data
|
147 |
|
148 |
return bots
|
|
|
169 |
return f'wss://{self.ws_domain}.tch.{channel["baseHost"]}/up/{channel["boxName"]}/updates'+query
|
170 |
|
171 |
def send_query(self, query_name, variables):
|
|
|
|
|
172 |
for i in range(20):
|
173 |
payload = generate_payload(query_name, variables)
|
|
|
174 |
r = request_with_retries(
|
175 |
self.session.post, self.gql_url, json=payload, headers=self.gql_headers)
|
176 |
data = r.json()
|
|
|
217 |
header={"User-Agent": user_agent},
|
218 |
on_message=self.on_message,
|
219 |
on_open=self.on_ws_connect,
|
220 |
+
on_error=self.on_ws_error,
|
221 |
+
on_close=self.on_ws_close
|
222 |
)
|
223 |
t = threading.Thread(target=self.ws_run_thread, daemon=True)
|
224 |
t.start()
|
|
|
233 |
def on_ws_connect(self, ws):
|
234 |
self.ws_connected = True
|
235 |
|
236 |
+
def on_ws_close(self, ws, close_status_code):
|
237 |
+
self.ws_connected = False
|
238 |
+
logger.warn(f"Websocket closed with status {close_status_code}")
|
239 |
+
|
240 |
def on_ws_error(self, ws, error):
|
|
|
241 |
self.disconnect_ws()
|
242 |
self.connect_ws()
|
243 |
|
244 |
def on_message(self, ws, msg):
|
245 |
+
try:
|
246 |
+
data = json.loads(msg)
|
247 |
+
|
248 |
+
if not "messages" in data:
|
|
|
|
|
|
|
|
|
|
|
249 |
return
|
250 |
|
251 |
+
for message_str in data["messages"]:
|
252 |
+
message_data = json.loads(message_str)
|
253 |
+
if message_data["message_type"] != "subscriptionUpdate":
|
254 |
+
continue
|
255 |
+
message = message_data["payload"]["data"]["messageAdded"]
|
256 |
+
|
257 |
+
copied_dict = self.active_messages.copy()
|
258 |
+
for key, value in copied_dict.items():
|
259 |
+
# add the message to the appropriate queue
|
260 |
+
if value == message["messageId"] and key in self.message_queues:
|
261 |
+
self.message_queues[key].put(message)
|
262 |
+
return
|
263 |
+
|
264 |
+
# indicate that the response id is tied to the human message id
|
265 |
+
elif key != "pending" and value == None and message["state"] != "complete":
|
266 |
+
self.active_messages[key] = message["messageId"]
|
267 |
+
self.message_queues[key].put(message)
|
268 |
+
return
|
269 |
+
|
270 |
+
except Exception:
|
271 |
+
logger.error(traceback.format_exc())
|
272 |
+
self.disconnect_ws()
|
273 |
+
self.connect_ws()
|
274 |
|
275 |
def send_message(self, chatbot, message, with_chat_break=False, timeout=20):
|
276 |
# if there is another active message, wait until it has finished sending
|
|
|
281 |
self.active_messages["pending"] = None
|
282 |
|
283 |
logger.info(f"Sending message to {chatbot}: {message}")
|
284 |
+
# reconnect websocket
|
285 |
+
if not self.ws_connected:
|
286 |
+
self.disconnect_ws()
|
287 |
+
self.connect_ws()
|
288 |
+
message_data = self.send_query("SendMessageMutation", {
|
289 |
"bot": chatbot,
|
290 |
"query": message,
|
291 |
"chatId": self.bots[chatbot]["chatId"],
|
|
|
294 |
})
|
295 |
del self.active_messages["pending"]
|
296 |
|
297 |
+
if not message_data["data"]["messageEdgeCreate"]["message"]:
|
298 |
raise RuntimeError(f"Daily limit reached for {chatbot}.")
|
299 |
try:
|
300 |
+
human_message = message_data["data"]["messageEdgeCreate"]["message"]
|
301 |
+
human_message_id = human_message["node"]["messageId"]
|
302 |
except TypeError:
|
303 |
raise RuntimeError(
|
304 |
f"An unknown error occured. Raw response data: {message_data}")
|
|
|
335 |
del self.active_messages[human_message_id]
|
336 |
del self.message_queues[human_message_id]
|
337 |
|
338 |
+
def send_chat_break(self, chatbot):
|
339 |
+
logger.info(f"Sending chat break to {chatbot}")
|
340 |
+
result = self.send_query("AddMessageBreakMutation", {
|
341 |
+
"chatId": self.bots[chatbot]["chatId"]
|
342 |
+
})
|
343 |
+
return result["data"]["messageBreakCreate"]["message"]
|
344 |
+
|
345 |
+
def get_message_history(self, chatbot, count=25, cursor=None):
|
346 |
+
logger.info(f"Downloading {count} messages from {chatbot}")
|
347 |
+
|
348 |
+
if cursor == None:
|
349 |
+
chat_data = self.get_bot(self.bot_names[chatbot])
|
350 |
+
if not chat_data["messagesConnection"]["edges"]:
|
351 |
+
return []
|
352 |
+
cursor = chat_data["messagesConnection"]["edges"][-1]["cursor"]
|
353 |
+
|
354 |
+
cursor = str(cursor)
|
355 |
+
if count > 50:
|
356 |
+
messages = self.get_message_history(
|
357 |
+
chatbot, count=50, cursor=cursor)
|
358 |
+
while count > 0:
|
359 |
+
new_cursor = messages[0]["cursor"]
|
360 |
+
new_messages = self.get_message_history(
|
361 |
+
chatbot, min(50, count), cursor=new_cursor)
|
362 |
+
messages = new_messages + messages
|
363 |
+
count -= 50
|
364 |
+
return messages
|
365 |
+
|
366 |
+
result = self.send_query("ChatListPaginationQuery", {
|
367 |
+
"count": count,
|
368 |
+
"cursor": cursor,
|
369 |
+
"id": self.bots[chatbot]["id"]
|
370 |
+
})
|
371 |
+
return result["data"]["node"]["messagesConnection"]["edges"]
|
372 |
+
|
373 |
+
def delete_message(self, message_ids):
|
374 |
+
logger.info(f"Deleting messages: {message_ids}")
|
375 |
+
if not type(message_ids) is list:
|
376 |
+
message_ids = [int(message_ids)]
|
377 |
+
|
378 |
+
result = self.send_query("DeleteMessageMutation", {
|
379 |
+
"messageIds": message_ids
|
380 |
+
})
|
381 |
+
|
382 |
+
def purge_conversation(self, chatbot, count=-1):
|
383 |
+
logger.info(f"Purging messages from {chatbot}")
|
384 |
+
last_messages = self.get_message_history(chatbot, count=50)[::-1]
|
385 |
+
while last_messages:
|
386 |
+
message_ids = []
|
387 |
+
for message in last_messages:
|
388 |
+
if count == 0:
|
389 |
+
break
|
390 |
+
count -= 1
|
391 |
+
message_ids.append(message["node"]["messageId"])
|
392 |
+
|
393 |
+
self.delete_message(message_ids)
|
394 |
+
|
395 |
+
if count == 0:
|
396 |
+
return
|
397 |
+
last_messages = self.get_message_history(chatbot, count=50)[::-1]
|
398 |
+
logger.info(f"No more messages left to delete.")
|
399 |
+
|
400 |
+
|
401 |
+
load_queries()
|
poe/cookies.txt
CHANGED
@@ -1 +1,7 @@
|
|
1 |
SmPiNXZI9hBTuf3viz74PA==
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
SmPiNXZI9hBTuf3viz74PA==
|
2 |
+
zw7RoKQfeEehiaelYMRWeA==
|
3 |
+
NEttgJ_rRQdO05Tppx6hFw==
|
4 |
+
3OnmC0r9njYdNWhWszdQJg==
|
5 |
+
8hZKR7MxwUTEHvO45TEViw==
|
6 |
+
Eea6BqK0AmosTKzoI3AAow==
|
7 |
+
pUEbtxobN_QUSpLIR8RGww==
|
poe/graphql/ChatListPaginationQuery.graphql
CHANGED
@@ -11,6 +11,12 @@ query ChatListPaginationQuery(
|
|
11 |
}
|
12 |
|
13 |
fragment BotImage_bot on Bot {
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
image {
|
15 |
__typename
|
16 |
... on LocalBotImage {
|
@@ -20,7 +26,7 @@ fragment BotImage_bot on Bot {
|
|
20 |
url
|
21 |
}
|
22 |
}
|
23 |
-
|
24 |
}
|
25 |
|
26 |
fragment ChatMessageDownvotedButton_message on Message {
|
@@ -33,7 +39,7 @@ fragment ChatMessageDropdownMenu_message on Message {
|
|
33 |
messageId
|
34 |
vote
|
35 |
text
|
36 |
-
|
37 |
...chatHelpers_isBotMessage
|
38 |
}
|
39 |
|
@@ -54,6 +60,9 @@ fragment ChatMessageInputView_chat on Chat {
|
|
54 |
dailyBalance
|
55 |
shouldShowRemainingMessageCount
|
56 |
}
|
|
|
|
|
|
|
57 |
id
|
58 |
}
|
59 |
shouldShowDisclaimer
|
@@ -88,6 +97,10 @@ fragment ChatMessageSuggestedReplies_SuggestedReplyButton_message on Message {
|
|
88 |
fragment ChatMessageSuggestedReplies_chat on Chat {
|
89 |
...ChatWelcomeView_chat
|
90 |
...ChatMessageSuggestedReplies_SuggestedReplyButton_chat
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
|
93 |
fragment ChatMessageSuggestedReplies_message on Message {
|
@@ -97,10 +110,13 @@ fragment ChatMessageSuggestedReplies_message on Message {
|
|
97 |
|
98 |
fragment ChatMessage_chat on Chat {
|
99 |
defaultBotObject {
|
100 |
-
|
|
|
|
|
101 |
messageLimit {
|
102 |
...ChatPageRateLimitedBanner_messageLimit
|
103 |
}
|
|
|
104 |
id
|
105 |
}
|
106 |
...ChatMessageSuggestedReplies_chat
|
@@ -114,6 +130,7 @@ fragment ChatMessage_message on Message {
|
|
114 |
author
|
115 |
linkifiedText
|
116 |
state
|
|
|
117 |
...ChatMessageSuggestedReplies_message
|
118 |
...ChatMessageFeedbackButtons_message
|
119 |
...ChatMessageOverflowButton_message
|
@@ -122,12 +139,15 @@ fragment ChatMessage_message on Message {
|
|
122 |
...chatHelpers_isChatBreak
|
123 |
...chatHelpers_useTimeoutLevel
|
124 |
...MarkdownLinkInner_message
|
|
|
125 |
}
|
126 |
|
127 |
fragment ChatMessagesView_chat on Chat {
|
128 |
...ChatMessage_chat
|
129 |
...ChatWelcomeView_chat
|
|
|
130 |
defaultBotObject {
|
|
|
131 |
messageLimit {
|
132 |
...ChatPageRateLimitedBanner_messageLimit
|
133 |
}
|
@@ -152,23 +172,42 @@ fragment ChatPageDeleteFooter_chat on Chat {
|
|
152 |
}
|
153 |
|
154 |
fragment ChatPageDisclaimer_bot on Bot {
|
155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
}
|
157 |
|
158 |
fragment ChatPageMain_chat_1G22uz on Chat {
|
159 |
id
|
160 |
chatId
|
161 |
-
...ChatMessageInputView_chat
|
162 |
...ChatPageShareFooter_chat
|
163 |
...ChatPageDeleteFooter_chat
|
164 |
...ChatMessagesView_chat
|
165 |
...MarkdownLinkInner_chat
|
166 |
...chatHelpers_useUpdateStaleChat_chat
|
167 |
...ChatSubscriptionPaywallContextWrapper_chat
|
|
|
168 |
messagesConnection(last: $count, before: $cursor) {
|
169 |
edges {
|
170 |
...ChatMessagesView_edges
|
171 |
-
...
|
172 |
...MarkdownLinkInner_edges
|
173 |
node {
|
174 |
...chatHelpers_useUpdateStaleChat_message
|
@@ -217,6 +256,11 @@ fragment ChatWelcomeView_chat on Chat {
|
|
217 |
}
|
218 |
}
|
219 |
|
|
|
|
|
|
|
|
|
|
|
220 |
fragment MarkdownLinkInner_chat on Chat {
|
221 |
id
|
222 |
chatId
|
@@ -263,6 +307,15 @@ fragment SubscriptionPaywallModal_bot on Bot {
|
|
263 |
...BotImage_bot
|
264 |
}
|
265 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
fragment chatHelpers_isBotMessage on Message {
|
267 |
...chatHelpers_isHumanMessage
|
268 |
...chatHelpers_isChatBreak
|
@@ -292,8 +345,8 @@ fragment chatHelpers_useSendMessage_chat on Chat {
|
|
292 |
id
|
293 |
chatId
|
294 |
defaultBotObject {
|
295 |
-
nickname
|
296 |
id
|
|
|
297 |
}
|
298 |
shouldShowDisclaimer
|
299 |
}
|
@@ -303,10 +356,19 @@ fragment chatHelpers_useTimeoutLevel on Message {
|
|
303 |
state
|
304 |
text
|
305 |
messageId
|
|
|
|
|
|
|
|
|
|
|
306 |
}
|
307 |
|
308 |
fragment chatHelpers_useUpdateStaleChat_chat on Chat {
|
309 |
chatId
|
|
|
|
|
|
|
|
|
310 |
...chatHelpers_useSendChatBreak_chat
|
311 |
}
|
312 |
|
|
|
11 |
}
|
12 |
|
13 |
fragment BotImage_bot on Bot {
|
14 |
+
displayName
|
15 |
+
...botHelpers_useDeletion_bot
|
16 |
+
...BotImage_useProfileImage_bot
|
17 |
+
}
|
18 |
+
|
19 |
+
fragment BotImage_useProfileImage_bot on Bot {
|
20 |
image {
|
21 |
__typename
|
22 |
... on LocalBotImage {
|
|
|
26 |
url
|
27 |
}
|
28 |
}
|
29 |
+
...botHelpers_useDeletion_bot
|
30 |
}
|
31 |
|
32 |
fragment ChatMessageDownvotedButton_message on Message {
|
|
|
39 |
messageId
|
40 |
vote
|
41 |
text
|
42 |
+
author
|
43 |
...chatHelpers_isBotMessage
|
44 |
}
|
45 |
|
|
|
60 |
dailyBalance
|
61 |
shouldShowRemainingMessageCount
|
62 |
}
|
63 |
+
hasClearContext
|
64 |
+
isDown
|
65 |
+
...botHelpers_useDeletion_bot
|
66 |
id
|
67 |
}
|
68 |
shouldShowDisclaimer
|
|
|
97 |
fragment ChatMessageSuggestedReplies_chat on Chat {
|
98 |
...ChatWelcomeView_chat
|
99 |
...ChatMessageSuggestedReplies_SuggestedReplyButton_chat
|
100 |
+
defaultBotObject {
|
101 |
+
hasWelcomeTopics
|
102 |
+
id
|
103 |
+
}
|
104 |
}
|
105 |
|
106 |
fragment ChatMessageSuggestedReplies_message on Message {
|
|
|
110 |
|
111 |
fragment ChatMessage_chat on Chat {
|
112 |
defaultBotObject {
|
113 |
+
hasWelcomeTopics
|
114 |
+
hasSuggestedReplies
|
115 |
+
disclaimerText
|
116 |
messageLimit {
|
117 |
...ChatPageRateLimitedBanner_messageLimit
|
118 |
}
|
119 |
+
...ChatPageDisclaimer_bot
|
120 |
id
|
121 |
}
|
122 |
...ChatMessageSuggestedReplies_chat
|
|
|
130 |
author
|
131 |
linkifiedText
|
132 |
state
|
133 |
+
contentType
|
134 |
...ChatMessageSuggestedReplies_message
|
135 |
...ChatMessageFeedbackButtons_message
|
136 |
...ChatMessageOverflowButton_message
|
|
|
139 |
...chatHelpers_isChatBreak
|
140 |
...chatHelpers_useTimeoutLevel
|
141 |
...MarkdownLinkInner_message
|
142 |
+
...IdAnnotation_node
|
143 |
}
|
144 |
|
145 |
fragment ChatMessagesView_chat on Chat {
|
146 |
...ChatMessage_chat
|
147 |
...ChatWelcomeView_chat
|
148 |
+
...IdAnnotation_node
|
149 |
defaultBotObject {
|
150 |
+
hasWelcomeTopics
|
151 |
messageLimit {
|
152 |
...ChatPageRateLimitedBanner_messageLimit
|
153 |
}
|
|
|
172 |
}
|
173 |
|
174 |
fragment ChatPageDisclaimer_bot on Bot {
|
175 |
+
disclaimerText
|
176 |
+
}
|
177 |
+
|
178 |
+
fragment ChatPageMainFooter_chat on Chat {
|
179 |
+
defaultBotObject {
|
180 |
+
...ChatPageMainFooter_useAccessMessage_bot
|
181 |
+
id
|
182 |
+
}
|
183 |
+
...ChatMessageInputView_chat
|
184 |
+
...ChatPageShareFooter_chat
|
185 |
+
...ChatPageDeleteFooter_chat
|
186 |
+
}
|
187 |
+
|
188 |
+
fragment ChatPageMainFooter_edges on MessageEdge {
|
189 |
+
...ChatMessageInputView_edges
|
190 |
+
}
|
191 |
+
|
192 |
+
fragment ChatPageMainFooter_useAccessMessage_bot on Bot {
|
193 |
+
...botHelpers_useDeletion_bot
|
194 |
+
...botHelpers_useViewerCanAccessPrivateBot
|
195 |
}
|
196 |
|
197 |
fragment ChatPageMain_chat_1G22uz on Chat {
|
198 |
id
|
199 |
chatId
|
|
|
200 |
...ChatPageShareFooter_chat
|
201 |
...ChatPageDeleteFooter_chat
|
202 |
...ChatMessagesView_chat
|
203 |
...MarkdownLinkInner_chat
|
204 |
...chatHelpers_useUpdateStaleChat_chat
|
205 |
...ChatSubscriptionPaywallContextWrapper_chat
|
206 |
+
...ChatPageMainFooter_chat
|
207 |
messagesConnection(last: $count, before: $cursor) {
|
208 |
edges {
|
209 |
...ChatMessagesView_edges
|
210 |
+
...ChatPageMainFooter_edges
|
211 |
...MarkdownLinkInner_edges
|
212 |
node {
|
213 |
...chatHelpers_useUpdateStaleChat_message
|
|
|
256 |
}
|
257 |
}
|
258 |
|
259 |
+
fragment IdAnnotation_node on Node {
|
260 |
+
__isNode: __typename
|
261 |
+
id
|
262 |
+
}
|
263 |
+
|
264 |
fragment MarkdownLinkInner_chat on Chat {
|
265 |
id
|
266 |
chatId
|
|
|
307 |
...BotImage_bot
|
308 |
}
|
309 |
|
310 |
+
fragment botHelpers_useDeletion_bot on Bot {
|
311 |
+
deletionState
|
312 |
+
}
|
313 |
+
|
314 |
+
fragment botHelpers_useViewerCanAccessPrivateBot on Bot {
|
315 |
+
isPrivateBot
|
316 |
+
viewerIsCreator
|
317 |
+
}
|
318 |
+
|
319 |
fragment chatHelpers_isBotMessage on Message {
|
320 |
...chatHelpers_isHumanMessage
|
321 |
...chatHelpers_isChatBreak
|
|
|
345 |
id
|
346 |
chatId
|
347 |
defaultBotObject {
|
|
|
348 |
id
|
349 |
+
nickname
|
350 |
}
|
351 |
shouldShowDisclaimer
|
352 |
}
|
|
|
356 |
state
|
357 |
text
|
358 |
messageId
|
359 |
+
chat {
|
360 |
+
chatId
|
361 |
+
defaultBotNickname
|
362 |
+
id
|
363 |
+
}
|
364 |
}
|
365 |
|
366 |
fragment chatHelpers_useUpdateStaleChat_chat on Chat {
|
367 |
chatId
|
368 |
+
defaultBotObject {
|
369 |
+
contextClearWindowSecs
|
370 |
+
id
|
371 |
+
}
|
372 |
...chatHelpers_useSendChatBreak_chat
|
373 |
}
|
374 |
|
poe/graphql/SendMessageMutation.graphql
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
mutation chatHelpers_sendMessageMutation_Mutation(
|
2 |
+
$chatId: BigInt!
|
3 |
+
$bot: String!
|
4 |
+
$query: String!
|
5 |
+
$source: MessageSource
|
6 |
+
$withChatBreak: Boolean!
|
7 |
+
) {
|
8 |
+
messageEdgeCreate(chatId: $chatId, bot: $bot, query: $query, source: $source, withChatBreak: $withChatBreak) {
|
9 |
+
chatBreak {
|
10 |
+
cursor
|
11 |
+
node {
|
12 |
+
id
|
13 |
+
messageId
|
14 |
+
text
|
15 |
+
author
|
16 |
+
suggestedReplies
|
17 |
+
creationTime
|
18 |
+
state
|
19 |
+
}
|
20 |
+
id
|
21 |
+
}
|
22 |
+
message {
|
23 |
+
cursor
|
24 |
+
node {
|
25 |
+
id
|
26 |
+
messageId
|
27 |
+
text
|
28 |
+
author
|
29 |
+
suggestedReplies
|
30 |
+
creationTime
|
31 |
+
state
|
32 |
+
chat {
|
33 |
+
shouldShowDisclaimer
|
34 |
+
id
|
35 |
+
}
|
36 |
+
}
|
37 |
+
id
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
testing/poe_test.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import poe
|
2 |
+
from time import sleep
|
3 |
+
|
4 |
+
token = poe.Account.create(proxy = 'xtekky:[email protected]:12321',logging = True)
|
5 |
+
print('token', token)
|
6 |
+
|
7 |
+
sleep(2)
|
8 |
+
|
9 |
+
for response in poe.StreamingCompletion.create(model = 'gpt-4',
|
10 |
+
prompt = 'hello world',
|
11 |
+
token = token):
|
12 |
+
|
13 |
+
print(response.completion.choices[0].text, end="", flush=True)
|