Hansimov commited on
Commit
7796b5b
1 Parent(s): b716bb2

:zap: [Enhance] Logger with no terminator

Browse files
conversation_creater.py CHANGED
@@ -126,14 +126,14 @@ class ConversationConnector:
126
  "text"
127
  ]
128
  delta_content = message_html[delta_content_pointer:]
129
- print(delta_content, end="", flush=True)
130
  delta_content_pointer = len(message_html)
131
 
132
  if message.get("suggestedResponses"):
133
- logger.note("\nSuggested Questions: ")
134
  for suggestion in message.get("suggestedResponses"):
135
  suggestion_text = suggestion.get("text")
136
- logger.mesg(f"- {suggestion_text}")
137
 
138
  elif message_type in ["InternalSearchQuery"]:
139
  message_hidden_text = message["hiddenText"]
@@ -181,8 +181,9 @@ if __name__ == "__main__":
181
  conversation_id=creator.response_content["conversationId"],
182
  )
183
  prompt = "Today's weather of California"
184
- logger.info(f"\n[User]: {prompt}\n")
185
- logger.info(f"[Bing]:")
 
186
  loop = asyncio.get_event_loop()
187
  loop.run_until_complete(conversation_connector.stream_chat(prompt=prompt))
188
  loop.close()
 
126
  "text"
127
  ]
128
  delta_content = message_html[delta_content_pointer:]
129
+ logger.mesg(delta_content, end="")
130
  delta_content_pointer = len(message_html)
131
 
132
  if message.get("suggestedResponses"):
133
+ logger.note("\n\nSuggested Questions: ")
134
  for suggestion in message.get("suggestedResponses"):
135
  suggestion_text = suggestion.get("text")
136
+ logger.file(f"- {suggestion_text}")
137
 
138
  elif message_type in ["InternalSearchQuery"]:
139
  message_hidden_text = message["hiddenText"]
 
181
  conversation_id=creator.response_content["conversationId"],
182
  )
183
  prompt = "Today's weather of California"
184
+ logger.success(f"\n[User]: ", end="")
185
+ logger.mesg(f"{prompt}")
186
+ logger.success(f"\n[Bing]:")
187
  loop = asyncio.get_event_loop()
188
  loop.run_until_complete(conversation_connector.stream_chat(prompt=prompt))
189
  loop.close()
docs/bing-chat-api-cli.png CHANGED
logger/logger.py CHANGED
@@ -137,7 +137,17 @@ class Logger:
137
  if quiet:
138
  self.restore_level()
139
 
140
- def log(self, method, msg, indent=0, fill=False, fill_side="both", *args, **kwargs):
 
 
 
 
 
 
 
 
 
 
141
  if type(msg) == str:
142
  msg_str = msg
143
  else:
@@ -156,6 +166,8 @@ class Logger:
156
  indented_msg = "\n".join([f"{indent_str}{line}" for line in msg_lines])
157
  if fill:
158
  indented_msg = add_fillers(indented_msg, fill_side=fill_side)
 
 
159
  getattr(self.logger, level)(colored(indented_msg, color), *args, **kwargs)
160
 
161
  def bind_functions(self):
 
137
  if quiet:
138
  self.restore_level()
139
 
140
+ def log(
141
+ self,
142
+ method,
143
+ msg,
144
+ indent=0,
145
+ fill=False,
146
+ fill_side="both",
147
+ end="\n",
148
+ *args,
149
+ **kwargs,
150
+ ):
151
  if type(msg) == str:
152
  msg_str = msg
153
  else:
 
166
  indented_msg = "\n".join([f"{indent_str}{line}" for line in msg_lines])
167
  if fill:
168
  indented_msg = add_fillers(indented_msg, fill_side=fill_side)
169
+ handler = self.logger.handlers[0]
170
+ handler.terminator = end
171
  getattr(self.logger, level)(colored(indented_msg, color), *args, **kwargs)
172
 
173
  def bind_functions(self):