Hansimov commited on
Commit
1bbf682
1 Parent(s): 51ca36f

:zap: [Enhance] Cleanse console outputs

Browse files
Files changed (2) hide show
  1. conversation_connector.py +4 -8
  2. message_parser.py +3 -2
conversation_connector.py CHANGED
@@ -88,33 +88,29 @@ class ConversationConnector:
88
  async def stream_chat(self, prompt=""):
89
  await self.init_wss_connection()
90
  await self.send_chathub_request(prompt)
91
-
92
  message_parser = MessageParser()
93
  while not self.wss.closed:
94
  response_lines_str = await self.wss.receive_str()
95
-
96
  if isinstance(response_lines_str, str):
97
  response_lines = response_lines_str.split("\x1e")
98
  else:
99
  continue
100
-
101
  for line in response_lines:
102
  if not line:
103
  continue
104
-
105
  data = json.loads(line)
106
-
107
  # Stream: Meaningful Messages
108
  if data.get("type") == 1:
109
  message_parser.parse(data)
110
  # Stream: List of all messages in the whole conversation
111
  elif data.get("type") == 2:
112
  if data.get("item"):
113
- item = data.get("item")
114
- logger.note("\n[Saving chat messages ...]")
 
115
  # Stream: End of Conversation
116
  elif data.get("type") == 3:
117
- logger.success("[Finished]")
118
  self.invocation_id += 1
119
  await self.wss.close()
120
  await self.aiohttp_session.close()
 
88
  async def stream_chat(self, prompt=""):
89
  await self.init_wss_connection()
90
  await self.send_chathub_request(prompt)
 
91
  message_parser = MessageParser()
92
  while not self.wss.closed:
93
  response_lines_str = await self.wss.receive_str()
 
94
  if isinstance(response_lines_str, str):
95
  response_lines = response_lines_str.split("\x1e")
96
  else:
97
  continue
 
98
  for line in response_lines:
99
  if not line:
100
  continue
 
101
  data = json.loads(line)
 
102
  # Stream: Meaningful Messages
103
  if data.get("type") == 1:
104
  message_parser.parse(data)
105
  # Stream: List of all messages in the whole conversation
106
  elif data.get("type") == 2:
107
  if data.get("item"):
108
+ # item = data.get("item")
109
+ # logger.note("\n[Saving chat messages ...]")
110
+ pass
111
  # Stream: End of Conversation
112
  elif data.get("type") == 3:
113
+ logger.success("\n[Finished]")
114
  self.invocation_id += 1
115
  await self.wss.close()
116
  await self.aiohttp_session.close()
message_parser.py CHANGED
@@ -23,7 +23,7 @@ class MessageParser:
23
  self.delta_content_pointer = len(content)
24
  # Message: Suggested Questions
25
  if message.get("suggestedResponses"):
26
- logger.note("\n\nSuggested Questions: ")
27
  for suggestion in message.get("suggestedResponses"):
28
  suggestion_text = suggestion.get("text")
29
  logger.file(f"- {suggestion_text}")
@@ -36,7 +36,8 @@ class MessageParser:
36
  logger.note("[Analyzing search results ...]")
37
  # Message: Loader status, such as "Generating Answers"
38
  elif message_type in ["InternalLoaderMessage"]:
39
- logger.note("[Generating answers ...]\n")
 
40
  # Message: Render Cards for Webpages
41
  elif message_type in ["RenderCardRequest"]:
42
  continue
 
23
  self.delta_content_pointer = len(content)
24
  # Message: Suggested Questions
25
  if message.get("suggestedResponses"):
26
+ logger.note("\nSuggested Questions: ")
27
  for suggestion in message.get("suggestedResponses"):
28
  suggestion_text = suggestion.get("text")
29
  logger.file(f"- {suggestion_text}")
 
36
  logger.note("[Analyzing search results ...]")
37
  # Message: Loader status, such as "Generating Answers"
38
  elif message_type in ["InternalLoaderMessage"]:
39
+ # logger.note("[Generating answers ...]\n")
40
+ pass
41
  # Message: Render Cards for Webpages
42
  elif message_type in ["RenderCardRequest"]:
43
  continue