xiaogpt 3.4__py3-none-any.whl → 3.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
xiaogpt/cli.py CHANGED
@@ -111,9 +111,10 @@ def main():
111
111
  )
112
112
  parser.add_argument(
113
113
  "--verbose",
114
+ "-v",
114
115
  dest="verbose",
115
- action="store_true",
116
- default=None,
116
+ action="count",
117
+ default=0,
117
118
  help="show info",
118
119
  )
119
120
  parser.add_argument(
xiaogpt/config.py CHANGED
@@ -77,7 +77,7 @@ class Config:
77
77
  api_base: str | None = None
78
78
  deployment_id: str | None = None
79
79
  use_command: bool = False
80
- verbose: bool = False
80
+ verbose: int = 0
81
81
  start_conversation: str = "开始持续对话"
82
82
  end_conversation: str = "结束持续对话"
83
83
  stream: bool = False
xiaogpt/tts/live.py CHANGED
@@ -27,11 +27,15 @@ class HTTPRequestHandler(BaseHTTPRequestHandler):
27
27
  self.end_headers()
28
28
  key = self.path.split("/")[-1]
29
29
  queue = get_queue(key)
30
+ chunks: list[bytes] = []
30
31
  while True:
31
32
  chunk = queue.get()
33
+ chunks.append(chunk)
32
34
  if chunk == b"":
33
35
  break
34
36
  self.wfile.write(chunk)
37
+ for chunk in chunks:
38
+ queue.put_nowait(chunk)
35
39
 
36
40
  def log_message(self, format, *args):
37
41
  logger.debug(f"{self.address_string()} - {format}", *args)
@@ -76,6 +80,7 @@ class TetosLiveTTS(TTS):
76
80
 
77
81
  while True:
78
82
  if await self.get_if_xiaoai_is_playing():
83
+ logger.debug("Xiaoai is playing, waiting")
79
84
  await asyncio.sleep(1)
80
85
  else:
81
86
  break
xiaogpt/xiaogpt.py CHANGED
@@ -57,15 +57,20 @@ class MiGPT:
57
57
  async def poll_latest_ask(self):
58
58
  async with ClientSession() as session:
59
59
  session._cookie_jar = self.cookie_jar
60
+ log_polling = int(self.config.verbose) > 1
60
61
  while True:
61
- self.log.debug(
62
- "Listening new message, timestamp: %s", self.last_timestamp
63
- )
62
+ if log_polling:
63
+ self.log.debug(
64
+ "Listening new message, timestamp: %s", self.last_timestamp
65
+ )
64
66
  new_record = await self.get_latest_ask_from_xiaoai(session)
65
67
  start = time.perf_counter()
66
- self.log.debug(
67
- "Polling_event, timestamp: %s %s", self.last_timestamp, new_record
68
- )
68
+ if log_polling:
69
+ self.log.debug(
70
+ "Polling_event, timestamp: %s %s",
71
+ self.last_timestamp,
72
+ new_record,
73
+ )
69
74
  await self.polling_event.wait()
70
75
  if (
71
76
  self.config.mute_xiaoai
@@ -75,7 +80,10 @@ class MiGPT:
75
80
  await self.stop_if_xiaoai_is_playing()
76
81
  if (d := time.perf_counter() - start) < 1:
77
82
  # sleep to avoid too many request
78
- self.log.debug("Sleep %f, timestamp: %s", d, self.last_timestamp)
83
+ if log_polling:
84
+ self.log.debug(
85
+ "Sleep %f, timestamp: %s", d, self.last_timestamp
86
+ )
79
87
  # if you want force mute xiaoai, comment this line below.
80
88
  await asyncio.sleep(1 - d)
81
89
 
@@ -334,6 +342,7 @@ class MiGPT:
334
342
  async def stop_if_xiaoai_is_playing(self):
335
343
  is_playing = await self.get_if_xiaoai_is_playing()
336
344
  if is_playing:
345
+ self.log.debug("Muting xiaoai")
337
346
  # stop it
338
347
  await self.mina_service.player_pause(self.device_id)
339
348
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xiaogpt
3
- Version: 3.4
3
+ Version: 3.5
4
4
  Summary: Play ChatGPT or other LLM with xiaomi AI speaker
5
5
  Author-Email: yihong0618 <zouzou0208@gmail.com>
6
6
  License: MIT
@@ -1,7 +1,7 @@
1
- xiaogpt-3.4.dist-info/METADATA,sha256=JZdIj1t1yuHoWkRqXOzO0Uo6rS1Q3pJ52TlLJQ0VpPg,31516
2
- xiaogpt-3.4.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
- xiaogpt-3.4.dist-info/entry_points.txt,sha256=q4WRS7kS4kQ5kZX57Fq40VrhCi74NZcyRPRX4JP2veo,61
4
- xiaogpt-3.4.dist-info/licenses/LICENSE,sha256=XdClh516MvlnOf9749JZHCxSB7y6_fyXcWmLDz6IkZY,1063
1
+ xiaogpt-3.5.dist-info/METADATA,sha256=fqymHqLmsFnNBE2G332D8ZbdmEFJ0gI3q08OXn6M3j0,31516
2
+ xiaogpt-3.5.dist-info/WHEEL,sha256=thaaA2w1JzcGC48WYufAs8nrYZjJm8LqNfnXFOFyCC4,90
3
+ xiaogpt-3.5.dist-info/entry_points.txt,sha256=q4WRS7kS4kQ5kZX57Fq40VrhCi74NZcyRPRX4JP2veo,61
4
+ xiaogpt-3.5.dist-info/licenses/LICENSE,sha256=XdClh516MvlnOf9749JZHCxSB7y6_fyXcWmLDz6IkZY,1063
5
5
  xiaogpt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
6
  xiaogpt/__main__.py,sha256=MSmt_5Xg84uHqzTN38JwgseJK8rsJn_11A8WD99VtEo,61
7
7
  xiaogpt/bot/__init__.py,sha256=BDGvj1JuWVw47qfREWGKnSXeiFg6DVJJAz2rHVryqmc,1160
@@ -15,8 +15,8 @@ xiaogpt/bot/llama_bot.py,sha256=HRR_ycuC6DY5MQTKauXEayQ0o_JKk9t-ea3mblscm8E,708
15
15
  xiaogpt/bot/moonshot_bot.py,sha256=PrVRBskZx-U0lH_3RVe89QJa7WKHYqhpft0089pYQz0,822
16
16
  xiaogpt/bot/qwen_bot.py,sha256=rFCOz5uiUsuhePjPozdCecNv5HGiUTNEhHYNw3Exexs,3590
17
17
  xiaogpt/bot/yi_bot.py,sha256=D7JEIh8KPVMvlOLaEVr9ahvyMaJLGToHP_gWU3RoYPc,784
18
- xiaogpt/cli.py,sha256=HXKkW5yg2q8qCruzjMjNTgcjsvs-qoZWPg6mNC_XSB8,5926
19
- xiaogpt/config.py,sha256=mwlJ26_Yv6BriPuWgZaaxotPCr6rO4MahlJXquawJt0,7048
18
+ xiaogpt/cli.py,sha256=iUPQwiZqIpzu1HoinneijBEfVKV7F_f_YMgqPPZM5lA,5932
19
+ xiaogpt/config.py,sha256=GpK3RXJI_B5YBKMxErAh9wUH1FWqVbQppZM4f7B-EoI,7043
20
20
  xiaogpt/langchain/callbacks.py,sha256=yR9AXQt9OHVYBWC47Q1I_BUT4Xg9iM44vnW2vv0BLpE,2616
21
21
  xiaogpt/langchain/chain.py,sha256=z0cqRlL0ElWnf31ByxZBN7AKOT-svXQDt5_NDft_nYc,1495
22
22
  xiaogpt/langchain/examples/email/mail_box.py,sha256=xauqrjE4-G4XPQnokUPE-MZgAaHQ_VrUDLlbfYTdCoo,6372
@@ -24,8 +24,8 @@ xiaogpt/langchain/examples/email/mail_summary_tools.py,sha256=6cWvBJUaA7iaywcHdb
24
24
  xiaogpt/tts/__init__.py,sha256=75_W5ZhON87RSutiLhJB29Ub-634iI2IlTEZd0alao8,210
25
25
  xiaogpt/tts/base.py,sha256=8vP8fIksSZttmrMaUT4vtiDbkfijkr9lbhyod1_5tc4,1440
26
26
  xiaogpt/tts/file.py,sha256=pWzozktMAgJraPiANWQC5dB4EQcL9QCwJWbX_M4hqWE,3721
27
- xiaogpt/tts/live.py,sha256=tmyW26TRTau1Ci_7aHiNyzv-UfzoaiWgnlxz4gA62yw,3109
27
+ xiaogpt/tts/live.py,sha256=7-NpuOU7E6GNht1PHjAA8_miXdFVDk8C7aL-sY1xqPE,3299
28
28
  xiaogpt/tts/mi.py,sha256=1MzCB27DBohPQ_4Xz4W_FV9p-chJFDavOHB89NviLcM,1095
29
29
  xiaogpt/utils.py,sha256=YYmRDNtccxqB9gyN_xhKZwgL1_PNYEp7So_-jt2tiVg,2668
30
- xiaogpt/xiaogpt.py,sha256=Og982fJSlzbMhcjP_Hj5dj1dKS-31y4gXA8sZRwZOPI,16366
31
- xiaogpt-3.4.dist-info/RECORD,,
30
+ xiaogpt/xiaogpt.py,sha256=zHZFijx-tH6vi3roB1uluZUhqLUnhmYNUR367GXVixg,16696
31
+ xiaogpt-3.5.dist-info/RECORD,,
File without changes