Hansimov commited on
Commit
5095a2b
1 Parent(s): 8b87c2e

:recycle: [Refactor] Seperate construct_chathub_request_payload()

Browse files
Files changed (1) hide show
  1. conversation_connector.py +12 -9
conversation_connector.py CHANGED
@@ -61,6 +61,16 @@ class ConversationConnector:
61
  await self.wss.receive_str()
62
  await self.wss_send({"type": 6})
63
 
 
 
 
 
 
 
 
 
 
 
64
  async def stream_chat(self, prompt=""):
65
  self.aiohttp_session = aiohttp.ClientSession(cookies=self.cookies)
66
  request_headers_constructor = ConversationConnectRequestHeadersConstructor()
@@ -71,15 +81,8 @@ class ConversationConnector:
71
  )
72
 
73
  await self.init_handshake()
74
- chathub_request_constructor = ChathubRequestConstructor(
75
- prompt=prompt,
76
- conversation_style="precise",
77
- client_id=self.client_id,
78
- conversation_id=self.conversation_id,
79
- invocation_id=self.invocation_id,
80
- )
81
-
82
- await self.wss_send(chathub_request_constructor.request_payload)
83
 
84
  delta_content_pointer = 0
85
  while not self.wss.closed:
 
61
  await self.wss.receive_str()
62
  await self.wss_send({"type": 6})
63
 
64
+ def construct_chathub_request_payload(self, prompt):
65
+ chathub_request_constructor = ChathubRequestConstructor(
66
+ prompt=prompt,
67
+ conversation_style="precise",
68
+ client_id=self.client_id,
69
+ conversation_id=self.conversation_id,
70
+ invocation_id=self.invocation_id,
71
+ )
72
+ self.connect_request_payload = chathub_request_constructor.request_payload
73
+
74
  async def stream_chat(self, prompt=""):
75
  self.aiohttp_session = aiohttp.ClientSession(cookies=self.cookies)
76
  request_headers_constructor = ConversationConnectRequestHeadersConstructor()
 
81
  )
82
 
83
  await self.init_handshake()
84
+ self.construct_chathub_request_payload(prompt)
85
+ await self.wss_send(self.connect_request_payload)
 
 
 
 
 
 
 
86
 
87
  delta_content_pointer = 0
88
  while not self.wss.closed: