jarvis-ai-assistant 0.1.219__tar.gz → 0.1.220__tar.gz

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.
Files changed (112) hide show
  1. {jarvis_ai_assistant-0.1.219/src/jarvis_ai_assistant.egg-info → jarvis_ai_assistant-0.1.220}/PKG-INFO +87 -8
  2. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/README.md +71 -2
  3. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/pyproject.toml +18 -6
  4. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/setup.py +19 -8
  5. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/__init__.py +1 -1
  6. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_agent/__init__.py +36 -89
  7. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_data/config_schema.json +30 -0
  8. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/yuanbao.py +3 -1
  9. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/__init__.py +11 -0
  10. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/cache.py +87 -0
  11. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/cli.py +297 -0
  12. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/embedding_manager.py +109 -0
  13. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/llm_interface.py +130 -0
  14. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/query_rewriter.py +63 -0
  15. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/rag_pipeline.py +177 -0
  16. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/reranker.py +56 -0
  17. jarvis_ai_assistant-0.1.220/src/jarvis/jarvis_rag/retriever.py +201 -0
  18. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/config.py +71 -0
  19. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220/src/jarvis_ai_assistant.egg-info}/PKG-INFO +87 -8
  20. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis_ai_assistant.egg-info/SOURCES.txt +9 -0
  21. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis_ai_assistant.egg-info/entry_points.txt +1 -0
  22. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis_ai_assistant.egg-info/requires.txt +13 -3
  23. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/LICENSE +0 -0
  24. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/MANIFEST.in +0 -0
  25. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/setup.cfg +0 -0
  26. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_agent/builtin_input_handler.py +0 -0
  27. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_agent/edit_file_handler.py +0 -0
  28. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_agent/jarvis.py +0 -0
  29. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_agent/main.py +0 -0
  30. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_agent/output_handler.py +0 -0
  31. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_agent/shell_input_handler.py +0 -0
  32. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_agent/__init__.py +0 -0
  33. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_agent/code_agent.py +0 -0
  34. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_agent/lint.py +0 -0
  35. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/__init__.py +0 -0
  36. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/c_cpp.py +0 -0
  37. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/csharp.py +0 -0
  38. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/data_format.py +0 -0
  39. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/devops.py +0 -0
  40. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/docs.py +0 -0
  41. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/go.py +0 -0
  42. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/infrastructure.py +0 -0
  43. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/java.py +0 -0
  44. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/javascript.py +0 -0
  45. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/kotlin.py +0 -0
  46. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/loader.py +0 -0
  47. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/php.py +0 -0
  48. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/python.py +0 -0
  49. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/ruby.py +0 -0
  50. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/rust.py +0 -0
  51. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/shell.py +0 -0
  52. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/sql.py +0 -0
  53. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/swift.py +0 -0
  54. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/checklists/web.py +0 -0
  55. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_code_analysis/code_review.py +0 -0
  56. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_data/tiktoken/9b5ad71b2ce5302211f9c61530b329a4922fc6a4 +0 -0
  57. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_git_details/__init__.py +0 -0
  58. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_git_details/main.py +0 -0
  59. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_git_squash/__init__.py +0 -0
  60. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_git_squash/main.py +0 -0
  61. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_git_utils/git_commiter.py +0 -0
  62. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_mcp/__init__.py +0 -0
  63. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_mcp/sse_mcp_client.py +0 -0
  64. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_mcp/stdio_mcp_client.py +0 -0
  65. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_mcp/streamable_mcp_client.py +0 -0
  66. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_methodology/main.py +0 -0
  67. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_multi_agent/__init__.py +0 -0
  68. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_multi_agent/main.py +0 -0
  69. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/__init__.py +0 -0
  70. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/ai8.py +0 -0
  71. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/base.py +0 -0
  72. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/human.py +0 -0
  73. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/kimi.py +0 -0
  74. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/openai.py +0 -0
  75. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/oyi.py +0 -0
  76. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/registry.py +0 -0
  77. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform/tongyi.py +0 -0
  78. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform_manager/__init__.py +0 -0
  79. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform_manager/main.py +0 -0
  80. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_platform_manager/service.py +0 -0
  81. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_smart_shell/__init__.py +0 -0
  82. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_smart_shell/main.py +0 -0
  83. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/__init__.py +0 -0
  84. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/ask_user.py +0 -0
  85. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/base.py +0 -0
  86. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/cli/__init__.py +0 -0
  87. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/cli/main.py +0 -0
  88. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/edit_file.py +0 -0
  89. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/execute_script.py +0 -0
  90. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/file_analyzer.py +0 -0
  91. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/generate_new_tool.py +0 -0
  92. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/methodology.py +0 -0
  93. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/read_code.py +0 -0
  94. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/read_webpage.py +0 -0
  95. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/registry.py +0 -0
  96. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/rewrite_file.py +0 -0
  97. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/search_web.py +0 -0
  98. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_tools/virtual_tty.py +0 -0
  99. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/__init__.py +0 -0
  100. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/builtin_replace_map.py +0 -0
  101. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/embedding.py +0 -0
  102. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/file_processors.py +0 -0
  103. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/git_utils.py +0 -0
  104. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/globals.py +0 -0
  105. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/http.py +0 -0
  106. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/input.py +0 -0
  107. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/methodology.py +0 -0
  108. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/output.py +0 -0
  109. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/tag.py +0 -0
  110. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis/jarvis_utils/utils.py +0 -0
  111. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis_ai_assistant.egg-info/dependency_links.txt +0 -0
  112. {jarvis_ai_assistant-0.1.219 → jarvis_ai_assistant-0.1.220}/src/jarvis_ai_assistant.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jarvis-ai-assistant
3
- Version: 0.1.219
3
+ Version: 0.1.220
4
4
  Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
5
  Home-page: https://github.com/skyfireitdiy/Jarvis
6
6
  Author: skyfire
@@ -33,11 +33,11 @@ Classifier: Intended Audience :: Developers
33
33
  Classifier: License :: OSI Approved :: MIT License
34
34
  Classifier: Operating System :: POSIX :: Linux
35
35
  Classifier: Programming Language :: Python :: 3
36
- Classifier: Programming Language :: Python :: 3.8
37
36
  Classifier: Programming Language :: Python :: 3.9
38
37
  Classifier: Programming Language :: Python :: 3.10
39
38
  Classifier: Programming Language :: Python :: 3.11
40
- Requires-Python: >=3.8
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Requires-Python: >=3.9
41
41
  Description-Content-Type: text/markdown
42
42
  License-File: LICENSE
43
43
  Requires-Dist: requests==2.32.3
@@ -56,9 +56,19 @@ Requires-Dist: tabulate==0.9.0
56
56
  Requires-Dist: pyte==0.8.2
57
57
  Requires-Dist: httpx>=0.28.1
58
58
  Requires-Dist: pyyaml>=5.3.1
59
- Requires-Dist: ddgs==6.1.8
60
- Requires-Dist: beautifulsoup4==4.12.3
61
- Requires-Dist: lxml==5.2.2
59
+ Requires-Dist: ddgs==9.0.2
60
+ Requires-Dist: beautifulsoup4==4.13.4
61
+ Requires-Dist: lxml==6.0.0
62
+ Requires-Dist: langchain
63
+ Requires-Dist: langchain-community
64
+ Requires-Dist: langchain-huggingface
65
+ Requires-Dist: chromadb
66
+ Requires-Dist: diskcache
67
+ Requires-Dist: sentence-transformers==2.7.0
68
+ Requires-Dist: torch>=2.6
69
+ Requires-Dist: typer
70
+ Requires-Dist: unstructured[md]
71
+ Requires-Dist: rank-bm25
62
72
  Provides-Extra: dev
63
73
  Requires-Dist: pytest; extra == "dev"
64
74
  Requires-Dist: black; extra == "dev"
@@ -553,7 +563,76 @@ OPENAI_API_BASE: https://api.openai.com/v1
553
563
  | search_web | 使用互联网搜索 |
554
564
  | virtual_tty | 控制虚拟终端执行操作 |
555
565
 
556
- ### 2. 命令替换功能
566
+ ### 2. 🧠 RAG增强知识库 (`jarvis-rag`)
567
+
568
+ `jarvis-rag` 是一个强大的命令行工具,用于构建、管理和查询本地化的RAG(检索增强生成)知识库。它允许您将自己的文档(代码、笔记、文章等)作为外部知识源,让AI能够基于这些具体内容进行回答,而不是仅仅依赖其通用训练数据。
569
+
570
+ #### 核心功能
571
+
572
+ - **本地化知识库**:所有文档索引和数据都存储在本地,确保数据隐私和安全。
573
+ - **智能文档加载**:自动识别并加载多种文本文件,无需关心文件后缀。
574
+ - **灵活的查询**:支持使用项目默认的“思考”模型或动态指定任意已注册的LLM进行查询。
575
+ - **配置驱动**:通过 `config.toml` 或 `.jarvis/config.yaml` 进行集中配置。
576
+
577
+ #### 子命令说明
578
+
579
+ ##### 2.1 添加文档到知识库 (`add`)
580
+
581
+ 此命令用于将文件、目录或符合通配符模式的文档添加到知识库中。
582
+
583
+ ```bash
584
+ # 基本用法
585
+ jarvis-rag add <文件路径/目录路径/通配符模式>...
586
+
587
+ # 示例
588
+ # 1. 添加单个文件
589
+ jarvis-rag add ./docs/my_document.md
590
+
591
+ # 2. 添加整个目录(将递归扫描所有文本文件)
592
+ jarvis-rag add ./src/
593
+
594
+ # 3. 使用通配符添加所有Python文件
595
+ jarvis-rag add 'src/**/*.py'
596
+
597
+ # 4. 混合添加
598
+ jarvis-rag add README.md ./docs/ 'src/jarvis/jarvis_rag/*.py'
599
+ ```
600
+
601
+ **参数与选项:**
602
+
603
+ | 参数/选项 | 描述 |
604
+ |---|---|
605
+ | `paths` | **[必需]** 一个或多个文件路径、目录路径或用引号包裹的通配符模式。 |
606
+ | `--collection` | 指定知识库的集合名称(默认为 `jarvis_rag_collection`)。 |
607
+ | `--embedding-mode` | 覆盖全局配置,强制使用特定嵌入模式 (`performance` 或 `accuracy`)。 |
608
+ | `--db-path` | 覆盖全局配置,指定向量数据库的存储路径。 |
609
+
610
+ ##### 2.2 查询知识库 (`query`)
611
+
612
+ 此命令用于向已建立的知识库提出问题。
613
+
614
+ ```bash
615
+ # 基本用法
616
+ jarvis-rag query "你的问题"
617
+
618
+ # 示例
619
+ # 1. 使用默认配置进行查询
620
+ jarvis-rag query "请总结一下我添加的文档的核心内容"
621
+
622
+ # 2. 指定使用Kimi模型进行查询
623
+ jarvis-rag query "代码中的 'PlatformRegistry' 类是做什么用的?" --platform kimi --model moonshot-v1-8k
624
+ ```
625
+
626
+ **参数与选项:**
627
+
628
+ | 参数/选项 | 描述 |
629
+ |---|---|
630
+ | `question` | **[必需]** 你要向知识库提出的问题。 |
631
+ | `--collection` | 指定要查询的知识库集合名称。 |
632
+ | `--platform` | 指定一个平台名称来回答问题,覆盖默认的“思考”模型。 |
633
+ | `--model` | 指定一个模型名称来回答问题,需要与 `--platform` 同时使用。 |
634
+
635
+ ### 3. 命令替换功能
557
636
  支持使用特殊标记`'<tag>'`触发命令替换功能:
558
637
 
559
638
  | 标记 | 功能 |
@@ -568,7 +647,7 @@ OPENAI_API_BASE: https://api.openai.com/v1
568
647
  | `'Check'` | 执行静态代码检查,包括错误和风格问题 |
569
648
  | `'SaveSession'` | 保存当前会话并退出 |
570
649
 
571
- ### 3. 自定义替换配置
650
+ ### 4. 自定义替换配置
572
651
  在`~/.jarvis/config.yaml`中添加:
573
652
  ```yaml
574
653
  JARVIS_REPLACE_MAP:
@@ -480,7 +480,76 @@ OPENAI_API_BASE: https://api.openai.com/v1
480
480
  | search_web | 使用互联网搜索 |
481
481
  | virtual_tty | 控制虚拟终端执行操作 |
482
482
 
483
- ### 2. 命令替换功能
483
+ ### 2. 🧠 RAG增强知识库 (`jarvis-rag`)
484
+
485
+ `jarvis-rag` 是一个强大的命令行工具,用于构建、管理和查询本地化的RAG(检索增强生成)知识库。它允许您将自己的文档(代码、笔记、文章等)作为外部知识源,让AI能够基于这些具体内容进行回答,而不是仅仅依赖其通用训练数据。
486
+
487
+ #### 核心功能
488
+
489
+ - **本地化知识库**:所有文档索引和数据都存储在本地,确保数据隐私和安全。
490
+ - **智能文档加载**:自动识别并加载多种文本文件,无需关心文件后缀。
491
+ - **灵活的查询**:支持使用项目默认的“思考”模型或动态指定任意已注册的LLM进行查询。
492
+ - **配置驱动**:通过 `config.toml` 或 `.jarvis/config.yaml` 进行集中配置。
493
+
494
+ #### 子命令说明
495
+
496
+ ##### 2.1 添加文档到知识库 (`add`)
497
+
498
+ 此命令用于将文件、目录或符合通配符模式的文档添加到知识库中。
499
+
500
+ ```bash
501
+ # 基本用法
502
+ jarvis-rag add <文件路径/目录路径/通配符模式>...
503
+
504
+ # 示例
505
+ # 1. 添加单个文件
506
+ jarvis-rag add ./docs/my_document.md
507
+
508
+ # 2. 添加整个目录(将递归扫描所有文本文件)
509
+ jarvis-rag add ./src/
510
+
511
+ # 3. 使用通配符添加所有Python文件
512
+ jarvis-rag add 'src/**/*.py'
513
+
514
+ # 4. 混合添加
515
+ jarvis-rag add README.md ./docs/ 'src/jarvis/jarvis_rag/*.py'
516
+ ```
517
+
518
+ **参数与选项:**
519
+
520
+ | 参数/选项 | 描述 |
521
+ |---|---|
522
+ | `paths` | **[必需]** 一个或多个文件路径、目录路径或用引号包裹的通配符模式。 |
523
+ | `--collection` | 指定知识库的集合名称(默认为 `jarvis_rag_collection`)。 |
524
+ | `--embedding-mode` | 覆盖全局配置,强制使用特定嵌入模式 (`performance` 或 `accuracy`)。 |
525
+ | `--db-path` | 覆盖全局配置,指定向量数据库的存储路径。 |
526
+
527
+ ##### 2.2 查询知识库 (`query`)
528
+
529
+ 此命令用于向已建立的知识库提出问题。
530
+
531
+ ```bash
532
+ # 基本用法
533
+ jarvis-rag query "你的问题"
534
+
535
+ # 示例
536
+ # 1. 使用默认配置进行查询
537
+ jarvis-rag query "请总结一下我添加的文档的核心内容"
538
+
539
+ # 2. 指定使用Kimi模型进行查询
540
+ jarvis-rag query "代码中的 'PlatformRegistry' 类是做什么用的?" --platform kimi --model moonshot-v1-8k
541
+ ```
542
+
543
+ **参数与选项:**
544
+
545
+ | 参数/选项 | 描述 |
546
+ |---|---|
547
+ | `question` | **[必需]** 你要向知识库提出的问题。 |
548
+ | `--collection` | 指定要查询的知识库集合名称。 |
549
+ | `--platform` | 指定一个平台名称来回答问题,覆盖默认的“思考”模型。 |
550
+ | `--model` | 指定一个模型名称来回答问题,需要与 `--platform` 同时使用。 |
551
+
552
+ ### 3. 命令替换功能
484
553
  支持使用特殊标记`'<tag>'`触发命令替换功能:
485
554
 
486
555
  | 标记 | 功能 |
@@ -495,7 +564,7 @@ OPENAI_API_BASE: https://api.openai.com/v1
495
564
  | `'Check'` | 执行静态代码检查,包括错误和风格问题 |
496
565
  | `'SaveSession'` | 保存当前会话并退出 |
497
566
 
498
- ### 3. 自定义替换配置
567
+ ### 4. 自定义替换配置
499
568
  在`~/.jarvis/config.yaml`中添加:
500
569
  ```yaml
501
570
  JARVIS_REPLACE_MAP:
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "jarvis-ai-assistant"
7
- version = "0.1.219"
7
+ version = "0.1.220"
8
8
  description = "Jarvis: An AI assistant that uses tools to interact with the system"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "skyfire", email = "skyfireitdiy@hotmail.com" }]
@@ -15,10 +15,10 @@ classifiers = [
15
15
  "License :: OSI Approved :: MIT License",
16
16
  "Operating System :: POSIX :: Linux",
17
17
  "Programming Language :: Python :: 3",
18
- "Programming Language :: Python :: 3.8",
19
18
  "Programming Language :: Python :: 3.9",
20
19
  "Programming Language :: Python :: 3.10",
21
20
  "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
22
  ]
23
23
  keywords = ["jarvis", "ai", "assistant", "tools", "automation"]
24
24
  dependencies = [
@@ -38,11 +38,22 @@ dependencies = [
38
38
  "pyte==0.8.2",
39
39
  "httpx>=0.28.1",
40
40
  "pyyaml>=5.3.1",
41
- "ddgs==6.1.8",
42
- "beautifulsoup4==4.12.3",
43
- "lxml==5.2.2",
41
+ "ddgs==9.0.2",
42
+ "beautifulsoup4==4.13.4",
43
+ "lxml==6.0.0",
44
+ # RAG dependencies
45
+ "langchain",
46
+ "langchain-community",
47
+ "langchain-huggingface",
48
+ "chromadb",
49
+ "diskcache",
50
+ "sentence-transformers==2.7.0",
51
+ "torch>=2.6",
52
+ "typer",
53
+ "unstructured[md]",
54
+ "rank-bm25",
44
55
  ]
45
- requires-python = ">=3.8"
56
+ requires-python = ">=3.9"
46
57
 
47
58
  [project.optional-dependencies]
48
59
  dev = ["pytest", "black", "isort", "mypy", "build", "twine"]
@@ -67,3 +78,4 @@ jarvis-agent = "jarvis.jarvis_agent.main:main"
67
78
  jarvis-tool = "jarvis.jarvis_tools.cli.main:main"
68
79
  jarvis-git-details = "jarvis.jarvis_git_details.main:main"
69
80
  jarvis-methodology = "jarvis.jarvis_methodology.main:main"
81
+ jarvis-rag = "jarvis.jarvis_rag.cli:main"
@@ -3,7 +3,7 @@ from setuptools import setup, find_packages # type: ignore
3
3
 
4
4
  setup(
5
5
  name="jarvis-ai-assistant",
6
- version="0.1.219",
6
+ version="0.1.220",
7
7
  author="skyfire",
8
8
  author_email="skyfireitdiy@hotmail.com",
9
9
  description="An AI assistant that uses various tools to interact with the system",
@@ -33,12 +33,22 @@ setup(
33
33
  "pyte==0.8.2",
34
34
  "httpx>=0.28.1",
35
35
  "pyyaml>=5.3.1",
36
- "ddgs==6.1.8",
37
- "beautifulsoup4==4.12.3",
38
- "lxml==5.2.2",
36
+ "ddgs==9.0.2",
37
+ "beautifulsoup4==4.13.4",
38
+ "lxml==6.0.0",
39
+ # RAG dependencies
40
+ "langchain",
41
+ "langchain-community",
42
+ "langchain-huggingface",
43
+ "chromadb",
44
+ "diskcache",
45
+ "sentence-transformers==2.7.0",
46
+ "torch>=2.6",
47
+ "typer",
48
+ "unstructured[md]",
49
+ "rank-bm25",
39
50
  ],
40
- extras_require={"dev": ["pytest", "black",
41
- "isort", "mypy", "build", "twine"]},
51
+ extras_require={"dev": ["pytest", "black", "isort", "mypy", "build", "twine"]},
42
52
  entry_points={
43
53
  "console_scripts": [
44
54
  "jarvis=jarvis.jarvis_agent.jarvis:main",
@@ -57,18 +67,19 @@ setup(
57
67
  "jarvis-tool=jarvis.jarvis_tools.cli.main:main",
58
68
  "jarvis-git-details=jarvis.jarvis_git_details.main:main",
59
69
  "jarvis-methodology=jarvis.jarvis_methodology.main:main",
70
+ "jarvis-rag=jarvis.jarvis_rag.cli:main",
60
71
  ],
61
72
  },
62
- python_requires=">=3.8",
73
+ python_requires=">=3.9",
63
74
  classifiers=[
64
75
  "Development Status :: 3 - Alpha",
65
76
  "Intended Audience :: Developers",
66
77
  "License :: OSI Approved :: MIT License",
67
78
  "Operating System :: POSIX :: Linux",
68
79
  "Programming Language :: Python :: 3",
69
- "Programming Language :: Python :: 3.8",
70
80
  "Programming Language :: Python :: 3.9",
71
81
  "Programming Language :: Python :: 3.10",
72
82
  "Programming Language :: Python :: 3.11",
83
+ "Programming Language :: Python :: 3.12",
73
84
  ],
74
85
  )
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  """Jarvis AI Assistant"""
3
3
 
4
- __version__ = "0.1.219"
4
+ __version__ = "0.1.220"
@@ -36,94 +36,49 @@ from jarvis.jarvis_utils.tag import ct, ot
36
36
  origin_agent_system_prompt = f"""
37
37
  <role>
38
38
  # 🤖 角色
39
- 你是一个专业的任务执行助手,擅长根据用户需求生成详细的任务执行计划并执行。
39
+ 你是一个专业的任务执行助手,根据用户需求制定并执行详细的计划。
40
40
  </role>
41
41
 
42
- <requirements>
43
- # 🔥 绝对行动要求
44
- 1. 每个响应必须包含且仅包含一个工具调用
45
- 2. 唯一例外:任务结束
46
- 3. 空响应会触发致命错误
47
- </requirements>
48
-
49
- <violations>
50
- # 🚫 违规示例
51
- - 没有工具调用的分析 → 永久挂起
52
- - 未选择的多选项 → 永久挂起
53
- - 请求用户确认 → 永久挂起
54
- </violations>
42
+ <rules>
43
+ # 核心规则
44
+ 1. **单步操作**: 每个响应必须包含且仅包含一个工具调用。
45
+ 2. **任务终结**: 当任务完成时,明确指出任务已完成。这是唯一可以不调用工具的例外。
46
+ 3. **无响应错误**: 空响应或仅有分析无工具调用的响应是致命错误,会导致系统挂起。
47
+ 4. **决策即工具**: 所有的决策和分析都必须通过工具调用来体现。
48
+ 5. **等待结果**: 在继续下一步之前,必须等待当前工具的执行结果。
49
+ 6. **持续推进**: 除非任务完成,否则必须生成可操作的下一步。
50
+ 7. **记录沉淀**: 如果解决方案有普适价值,应记录为方法论。
51
+ 8. **用户语言**: 始终使用用户的语言进行交流。
52
+ </rules>
55
53
 
56
54
  <workflow>
57
- # 🔄 问题解决流程
58
- 1. 问题分析
59
- - 重述问题以确认理解
60
- - 分析根本原因(针对问题分析任务)
61
- - 定义清晰、可实现的目标
62
- → 必须调用分析工具
63
-
64
- 2. 解决方案设计
65
- - 生成多个可执行的解决方案
66
- - 评估并选择最优方案
67
- - 使用PlantUML创建详细行动计划
68
- → 必须调用设计工具
69
-
70
- 3. 执行
71
- - 一次执行一个步骤
72
- - 每个步骤只使用一个工具
73
- - 等待工具结果后再继续
74
- - 监控结果并根据需要调整
75
- → 必须调用执行工具
76
-
77
- 4. 任务完成
78
- - 验证目标完成情况
79
- - 如有价值则记录方法论
55
+ # 🔄 工作流程
56
+ 1. **分析**: 理解和分析问题,定义清晰的目标。
57
+ 2. **设计**: 设计解决方案并制定详细的行动计划。
58
+ 3. **执行**: 按照计划,一次一个步骤地执行。
59
+ 4. **完成**: 验证任务是否达成目标,并进行总结。
80
60
  </workflow>
81
61
 
82
- <principles>
83
- # ⚖️ 操作原则
84
- - 每个步骤一个操作
85
- - 下一步前必须等待结果
86
- - 除非任务完成否则必须生成可操作步骤
87
- - 根据反馈调整计划
88
- - 记录可复用的解决方案
89
- - 使用完成命令结束任务
90
- - 操作之间不能有中间思考状态
91
- - 所有决策必须表现为工具调用
92
- </principles>
93
-
94
- <rules>
95
- # ❗ 重要规则
96
- 1. 每个步骤只能使用一个操作
97
- 2. 必须等待操作执行结果
98
- 3. 必须验证任务完成情况
99
- 4. 必须生成可操作步骤
100
- 5. 如果无需操作必须使用完成命令
101
- 6. 永远不要使对话处于等待状态
102
- 7. 始终使用用户语言交流
103
- 8. 必须记录有价值的方法论
104
- 9. 违反操作协议将导致系统崩溃
105
- 10. 空响应会触发永久挂起
106
- </rules>
107
-
108
62
  <system_info>
109
- # 系统信息:
110
- {platform.platform()}
111
- {platform.version()}
112
-
113
- # 当前时间
114
- {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
63
+ # 系统信息
64
+ - OS: {platform.platform()} {platform.version()}
65
+ - Time: {datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")}
115
66
  </system_info>
116
67
  """
117
68
 
118
69
 
119
70
  class OutputHandlerProtocol(Protocol):
120
- def name(self) -> str: ...
71
+ def name(self) -> str:
72
+ ...
121
73
 
122
- def can_handle(self, response: str) -> bool: ...
74
+ def can_handle(self, response: str) -> bool:
75
+ ...
123
76
 
124
- def prompt(self) -> str: ...
77
+ def prompt(self) -> str:
78
+ ...
125
79
 
126
- def handle(self, response: str, agent: Any) -> Tuple[bool, Any]: ...
80
+ def handle(self, response: str, agent: Any) -> Tuple[bool, Any]:
81
+ ...
127
82
 
128
83
 
129
84
  class Agent:
@@ -189,9 +144,7 @@ class Agent:
189
144
  if isinstance(platform, str):
190
145
  self.model = PlatformRegistry().create_platform(platform)
191
146
  if self.model is None:
192
- PrettyOutput.print(
193
- f"平台 {platform} 不存在,将使用普通模型", OutputType.WARNING
194
- )
147
+ PrettyOutput.print(f"平台 {platform} 不存在,将使用普通模型", OutputType.WARNING)
195
148
  self.model = PlatformRegistry().get_normal_platform()
196
149
  else:
197
150
  self.model = platform
@@ -816,18 +769,14 @@ arguments:
816
769
 
817
770
  if get_interrupt():
818
771
  set_interrupt(False)
819
- user_input = self.multiline_inputer(
820
- f"模型交互期间被中断,请输入用户干预信息:"
821
- )
772
+ user_input = self.multiline_inputer(f"模型交互期间被中断,请输入用户干预信息:")
822
773
  if user_input:
823
774
  # 如果有工具调用且用户确认继续,则将干预信息和工具执行结果拼接为prompt
824
775
  if any(
825
776
  handler.can_handle(current_response)
826
777
  for handler in self.output_handler
827
778
  ):
828
- if user_confirm(
829
- "检测到有工具调用,是否继续处理工具调用?", True
830
- ):
779
+ if user_confirm("检测到有工具调用,是否继续处理工具调用?", True):
831
780
  self.prompt = f"{user_input}\n\n{current_response}"
832
781
  continue
833
782
  self.prompt += f"{user_input}"
@@ -873,9 +822,7 @@ arguments:
873
822
  if self.use_methodology:
874
823
  if not upload_methodology(self.model, other_files=self.files):
875
824
  if self.files:
876
- PrettyOutput.print(
877
- "文件上传失败,将忽略文件列表", OutputType.WARNING
878
- )
825
+ PrettyOutput.print("文件上传失败,将忽略文件列表", OutputType.WARNING)
879
826
  # 上传失败则回退到本地加载
880
827
  msg = self.prompt
881
828
  for handler in self.input_handler:
@@ -883,14 +830,14 @@ arguments:
883
830
  self.prompt = f"{self.prompt}\n\n以下是历史类似问题的执行经验,可参考:\n{load_methodology(msg, self.get_tool_registry())}"
884
831
  else:
885
832
  if self.files:
886
- self.prompt = f"{self.prompt}\n\n上传的文件包含历史对话信息和方法论文件,可以从中获取一些经验信息。"
833
+ self.prompt = (
834
+ f"{self.prompt}\n\n上传的文件包含历史对话信息和方法论文件,可以从中获取一些经验信息。"
835
+ )
887
836
  else:
888
837
  self.prompt = f"{self.prompt}\n\n上传的文件包含历史对话信息,可以从中获取一些经验信息。"
889
838
  elif self.files:
890
839
  if not self.model.upload_files(self.files):
891
- PrettyOutput.print(
892
- "文件上传失败,将忽略文件列表", OutputType.WARNING
893
- )
840
+ PrettyOutput.print("文件上传失败,将忽略文件列表", OutputType.WARNING)
894
841
  else:
895
842
  self.prompt = f"{self.prompt}\n\n上传的文件包含历史对话信息,可以从中获取一些经验信息。"
896
843
  else:
@@ -181,6 +181,36 @@
181
181
  "description": "是否打印提示",
182
182
  "default": false
183
183
  },
184
+ "JARVIS_RAG": {
185
+ "type": "object",
186
+ "description": "RAG框架的配置",
187
+ "properties": {
188
+ "embedding_mode": {
189
+ "type": "string",
190
+ "enum": [
191
+ "performance",
192
+ "accuracy"
193
+ ],
194
+ "default": "performance",
195
+ "description": "嵌入模型的模式, 'performance'表示性能优先, 'accuracy'表示准确度优先"
196
+ },
197
+ "embedding_cache_path": {
198
+ "type": "string",
199
+ "default": ".jarvis/rag/embeddings",
200
+ "description": "嵌入向量缓存的路径, 相对于当前工作目录"
201
+ },
202
+ "vector_db_path": {
203
+ "type": "string",
204
+ "default": ".jarvis/rag/vectordb",
205
+ "description": "向量数据库的持久化存储路径, 相对于当前工作目录"
206
+ }
207
+ },
208
+ "default": {
209
+ "embedding_mode": "performance",
210
+ "embedding_cache_path": ".jarvis/rag/embeddings",
211
+ "vector_db_path": ".jarvis/rag/vectordb"
212
+ }
213
+ },
184
214
  "JARVIS_REPLACE_MAP": {
185
215
  "type": "object",
186
216
  "description": "自定义替换映射表配置",
@@ -38,7 +38,9 @@ class YuanbaoPlatform(BasePlatform):
38
38
  self.agent_id = "naQivTmsDa"
39
39
 
40
40
  if not self.cookies:
41
- PrettyOutput.print("YUANBAO_COOKIES 未设置", OutputType.WARNING)
41
+ raise ValueError(
42
+ "YUANBAO_COOKIES environment variable not set. Please provide your cookies to use the Yuanbao platform."
43
+ )
42
44
 
43
45
  self.system_message = "" # 系统消息,用于初始化对话
44
46
  self.first_chat = True # 标识是否为第一次对话
@@ -0,0 +1,11 @@
1
+ """
2
+ Jarvis RAG Framework
3
+
4
+ A flexible RAG pipeline with pluggable remote LLMs and local, cache-enabled embedding models.
5
+ """
6
+
7
+ from .rag_pipeline import JarvisRAGPipeline
8
+ from .llm_interface import LLMInterface
9
+ from .embedding_manager import EmbeddingManager
10
+
11
+ __all__ = ["JarvisRAGPipeline", "LLMInterface", "EmbeddingManager"]
@@ -0,0 +1,87 @@
1
+ import hashlib
2
+ from typing import List, Optional, Any
3
+
4
+ from diskcache import Cache
5
+
6
+
7
+ class EmbeddingCache:
8
+ """
9
+ A disk-based cache for storing and retrieving text embeddings.
10
+
11
+ This class uses diskcache to create a persistent, local cache. It generates
12
+ a key for each text content based on its SHA256 hash, making lookups
13
+ deterministic and efficient.
14
+ """
15
+
16
+ def __init__(self, cache_dir: str, salt: str = ""):
17
+ """
18
+ Initializes the EmbeddingCache.
19
+
20
+ Args:
21
+ cache_dir (str): The directory where the cache will be stored.
22
+ salt (str): A salt to be added to the hash. This is crucial for
23
+ ensuring that embeddings generated by different models
24
+ do not collide. For example, use the model name as a salt.
25
+ """
26
+ self.cache = Cache(cache_dir)
27
+ self.salt = salt
28
+
29
+ def _get_key(self, text: str) -> str:
30
+ """Generates a unique cache key for a given text and salt."""
31
+ hash_object = hashlib.sha256((self.salt + text).encode("utf-8"))
32
+ return hash_object.hexdigest()
33
+
34
+ def get(self, text: str) -> Optional[Any]:
35
+ """
36
+ Retrieves an embedding from the cache.
37
+
38
+ Args:
39
+ text (str): The text to look up.
40
+
41
+ Returns:
42
+ The cached embedding, or None if it's not in the cache.
43
+ """
44
+ key = self._get_key(text)
45
+ return self.cache.get(key)
46
+
47
+ def set(self, text: str, embedding: Any) -> None:
48
+ """
49
+ Stores an embedding in the cache.
50
+
51
+ Args:
52
+ text (str): The text corresponding to the embedding.
53
+ embedding (Any): The embedding vector to store.
54
+ """
55
+ key = self._get_key(text)
56
+ self.cache.set(key, embedding)
57
+
58
+ def get_batch(self, texts: List[str]) -> List[Optional[Any]]:
59
+ """
60
+ Retrieves a batch of embeddings from the cache.
61
+
62
+ Args:
63
+ texts (List[str]): A list of texts to look up.
64
+
65
+ Returns:
66
+ A list containing cached embeddings or None for cache misses.
67
+ """
68
+ return [self.get(text) for text in texts]
69
+
70
+ def set_batch(self, texts: List[str], embeddings: List[Any]) -> None:
71
+ """
72
+ Stores a batch of embeddings in the cache.
73
+
74
+ Args:
75
+ texts (List[str]): The list of texts.
76
+ embeddings (List[Any]): The list of corresponding embeddings.
77
+ """
78
+ if len(texts) != len(embeddings):
79
+ raise ValueError("Length of texts and embeddings must be the same.")
80
+
81
+ with self.cache.transact():
82
+ for text, embedding in zip(texts, embeddings):
83
+ self.set(text, embedding)
84
+
85
+ def close(self):
86
+ """Closes the cache connection."""
87
+ self.cache.close()