myagent-ai 1.23.48 → 1.23.50

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.
package/core/stt.py CHANGED
@@ -68,6 +68,29 @@ async def _stt_sensevoice(audio_data: bytes, audio_format: Optional[str] = None)
68
68
  os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
69
69
  'models', 'sensevoice',
70
70
  )
71
+ # [v1.23.49] 首次加载:将 ModelScope 缓存复制到本地 model_dir,后续不再联网
72
+ if not os.path.isdir(model_dir) or not os.listdir(model_dir):
73
+ import shutil
74
+ ms_cache = os.path.expanduser("~/.cache/modelscope/hub/models/iic/SenseVoiceSmall")
75
+ if os.path.isdir(ms_cache) and os.listdir(ms_cache):
76
+ os.makedirs(model_dir, exist_ok=True)
77
+ logger.info(f"复制 SenseVoice 模型: {ms_cache} -> {model_dir}")
78
+ # 复制模型文件(排除缓存元数据)
79
+ for item in os.listdir(ms_cache):
80
+ if item.endswith('.tmp') or item in ('.lock', '__pycache__'):
81
+ continue
82
+ src = os.path.join(ms_cache, item)
83
+ dst = os.path.join(model_dir, item)
84
+ if os.path.isdir(src):
85
+ if os.path.exists(dst):
86
+ shutil.rmtree(dst)
87
+ shutil.copytree(src, dst)
88
+ else:
89
+ shutil.copy2(src, dst)
90
+ else:
91
+ # ModelScope 缓存也没有,首次下载到本地
92
+ os.makedirs(model_dir, exist_ok=True)
93
+ logger.info("SenseVoice 模型首次下载到本地...")
71
94
  _sensevoice_model = AutoModel(
72
95
  model="iic/SenseVoiceSmall",
73
96
  model_dir=model_dir,
@@ -75,7 +98,7 @@ async def _stt_sensevoice(audio_data: bytes, audio_format: Optional[str] = None)
75
98
  disable_pbar=True,
76
99
  disable_update=True,
77
100
  )
78
- logger.info("SenseVoice 模型已加载 (iic/SenseVoiceSmall, CPU)")
101
+ logger.info("SenseVoice 模型已加载 (iic/SenseVoiceSmall, CPU, 本地缓存)")
79
102
 
80
103
  # [v1.23.2] 增强: pydub 转换失败记录警告、WAV 头验证、音频长度检查
81
104
  wav_data = _convert_to_wav(audio_data, audio_format)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "myagent-ai",
3
- "version": "1.23.48",
3
+ "version": "1.23.50",
4
4
  "description": "本地桌面端执行型AI助手 - Open Interpreter 风格 | Local Desktop Execution-Oriented AI Assistant",
5
5
  "main": "main.py",
6
6
  "bin": {
@@ -43,4 +43,4 @@
43
43
  "python": ">=3.10",
44
44
  "node": ">=18"
45
45
  }
46
- }
46
+ }
package/scripts/cli.py CHANGED
@@ -378,9 +378,11 @@ async def cmd_ls(args):
378
378
  """列出目录内容"""
379
379
  import argparse
380
380
  # [v1.23.46] 过滤系统 ls 参数(-l, -a, -la 等)
381
+ # [v1.23.48] 过滤纯数字参数(LLM 误传如 myagent-ai ls 2)
382
+ args = [a for a in args if not a.isdigit()]
381
383
  args = _filter_unknown_args(args, allowed_prefixes={"-p", "--pattern", "-r", "--recursive", "--max"})
382
384
  p = argparse.ArgumentParser(prog="myagent-ai ls", description="列出目录内容")
383
- p.add_argument("path", help="目录路径")
385
+ p.add_argument("path", nargs="?", default=".", help="目录路径 (默认当前目录)")
384
386
  p.add_argument("-p", "--pattern", default="*", help="文件匹配模式 (如 *.py)")
385
387
  p.add_argument("-r", "--recursive", action="store_true", help="递归列出")
386
388
  p.add_argument("--max", type=int, default=500, help="最大返回条目数 (默认500)")