jarvis-ai-assistant 0.1.0__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.

Potentially problematic release.


This version of jarvis-ai-assistant might be problematic. Click here for more details.

Files changed (35) hide show
  1. jarvis/.jarvis +1 -0
  2. jarvis/__init__.py +3 -0
  3. jarvis/__pycache__/agent.cpython-313.pyc +0 -0
  4. jarvis/__pycache__/models.cpython-313.pyc +0 -0
  5. jarvis/__pycache__/tools.cpython-313.pyc +0 -0
  6. jarvis/__pycache__/utils.cpython-313.pyc +0 -0
  7. jarvis/agent.py +100 -0
  8. jarvis/main.py +161 -0
  9. jarvis/models.py +112 -0
  10. jarvis/tools/__init__.py +22 -0
  11. jarvis/tools/__pycache__/__init__.cpython-313.pyc +0 -0
  12. jarvis/tools/__pycache__/base.cpython-313.pyc +0 -0
  13. jarvis/tools/__pycache__/file_ops.cpython-313.pyc +0 -0
  14. jarvis/tools/__pycache__/python_script.cpython-313.pyc +0 -0
  15. jarvis/tools/__pycache__/rag.cpython-313.pyc +0 -0
  16. jarvis/tools/__pycache__/search.cpython-313.pyc +0 -0
  17. jarvis/tools/__pycache__/shell.cpython-313.pyc +0 -0
  18. jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc +0 -0
  19. jarvis/tools/__pycache__/user_interaction.cpython-313.pyc +0 -0
  20. jarvis/tools/__pycache__/webpage.cpython-313.pyc +0 -0
  21. jarvis/tools/base.py +155 -0
  22. jarvis/tools/file_ops.py +106 -0
  23. jarvis/tools/python_script.py +150 -0
  24. jarvis/tools/rag.py +154 -0
  25. jarvis/tools/search.py +48 -0
  26. jarvis/tools/shell.py +67 -0
  27. jarvis/tools/user_confirmation.py +58 -0
  28. jarvis/tools/user_interaction.py +86 -0
  29. jarvis/tools/webpage.py +90 -0
  30. jarvis/utils.py +105 -0
  31. jarvis_ai_assistant-0.1.0.dist-info/METADATA +125 -0
  32. jarvis_ai_assistant-0.1.0.dist-info/RECORD +35 -0
  33. jarvis_ai_assistant-0.1.0.dist-info/WHEEL +5 -0
  34. jarvis_ai_assistant-0.1.0.dist-info/entry_points.txt +2 -0
  35. jarvis_ai_assistant-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,90 @@
1
+ from typing import Dict, Any
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+ from ..utils import PrettyOutput, OutputType
5
+
6
+ class WebpageTool:
7
+ name = "read_webpage"
8
+ description = "Read webpage content, supporting extraction of main text, title, and other information"
9
+ parameters = {
10
+ "type": "object",
11
+ "properties": {
12
+ "url": {
13
+ "type": "string",
14
+ "description": "URL of the webpage to read"
15
+ },
16
+ "extract_type": {
17
+ "type": "string",
18
+ "description": "Type of content to extract: 'text', 'title', or 'all'",
19
+ "enum": ["text", "title", "all"],
20
+ "default": "all"
21
+ }
22
+ },
23
+ "required": ["url"]
24
+ }
25
+
26
+ def execute(self, args: Dict) -> Dict[str, Any]:
27
+ """读取网页内容"""
28
+ try:
29
+ url = args["url"]
30
+ extract_type = args.get("extract_type", "all")
31
+
32
+ # 设置请求头
33
+ headers = {
34
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
35
+ }
36
+
37
+ # 发送请求
38
+ PrettyOutput.print(f"正在读取网页: {url}", OutputType.INFO)
39
+ response = requests.get(url, headers=headers, timeout=10)
40
+ response.raise_for_status()
41
+
42
+ # 使用正确的编码
43
+ response.encoding = response.apparent_encoding
44
+
45
+ # 解析HTML
46
+ soup = BeautifulSoup(response.text, 'html.parser')
47
+
48
+ # 移除script和style标签
49
+ for script in soup(["script", "style"]):
50
+ script.decompose()
51
+
52
+ result = {}
53
+
54
+ # 提取标题
55
+ if extract_type in ["title", "all"]:
56
+ title = soup.title.string if soup.title else ""
57
+ result["title"] = title.strip() if title else "无标题"
58
+
59
+ # 提取正文
60
+ if extract_type in ["text", "all"]:
61
+ text = soup.get_text(separator='\n', strip=True)
62
+ lines = [line.strip() for line in text.splitlines() if line.strip()]
63
+ result["text"] = "\n".join(lines)
64
+
65
+ # 构建输出
66
+ output = []
67
+ if "title" in result:
68
+ output.append(f"标题: {result['title']}")
69
+ output.append("")
70
+
71
+ if "text" in result:
72
+ output.append("正文内容:")
73
+ output.append(result["text"])
74
+
75
+ return {
76
+ "success": True,
77
+ "stdout": "\n".join(output),
78
+ "stderr": ""
79
+ }
80
+
81
+ except requests.RequestException as e:
82
+ return {
83
+ "success": False,
84
+ "error": f"网页请求失败: {str(e)}"
85
+ }
86
+ except Exception as e:
87
+ return {
88
+ "success": False,
89
+ "error": f"解析网页失败: {str(e)}"
90
+ }
jarvis/utils.py ADDED
@@ -0,0 +1,105 @@
1
+ import sys
2
+ import time
3
+ import threading
4
+ from typing import Optional
5
+ from enum import Enum
6
+ from datetime import datetime
7
+ import colorama
8
+ from colorama import Fore, Style
9
+
10
+ # 初始化colorama
11
+ colorama.init()
12
+
13
+ class Spinner:
14
+ """加载动画类"""
15
+ def __init__(self, message: str = "思考中"):
16
+ self.spinner_chars = "⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏"
17
+ self.message = message
18
+ self.running = False
19
+ self.spinner_thread = None
20
+
21
+ def _spin(self):
22
+ i = 0
23
+ while self.running:
24
+ sys.stdout.write(f"\r{Fore.BLUE}{self.spinner_chars[i]} {self.message}...{Style.RESET_ALL}")
25
+ sys.stdout.flush()
26
+ time.sleep(0.1)
27
+ i = (i + 1) % len(self.spinner_chars)
28
+ sys.stdout.write("\r" + " " * (len(self.message) + 10) + "\r")
29
+ sys.stdout.flush()
30
+
31
+ def start(self):
32
+ self.running = True
33
+ self.spinner_thread = threading.Thread(target=self._spin)
34
+ self.spinner_thread.start()
35
+
36
+ def stop(self):
37
+ self.running = False
38
+ if self.spinner_thread:
39
+ self.spinner_thread.join()
40
+
41
+ class OutputType(Enum):
42
+ SYSTEM = "system"
43
+ CODE = "code"
44
+ RESULT = "result"
45
+ ERROR = "error"
46
+ INFO = "info"
47
+
48
+ class PrettyOutput:
49
+ """美化输出类"""
50
+ @staticmethod
51
+ def format(text: str, output_type: OutputType, timestamp: bool = True) -> str:
52
+ # 颜色映射
53
+ colors = {
54
+ OutputType.SYSTEM: Fore.CYAN,
55
+ OutputType.CODE: Fore.GREEN,
56
+ OutputType.RESULT: Fore.BLUE,
57
+ OutputType.ERROR: Fore.RED,
58
+ OutputType.INFO: Fore.YELLOW
59
+ }
60
+
61
+ # 图标映射
62
+ icons = {
63
+ OutputType.SYSTEM: "🤖",
64
+ OutputType.CODE: "📝",
65
+ OutputType.RESULT: "✨",
66
+ OutputType.ERROR: "❌",
67
+ OutputType.INFO: "ℹ️"
68
+ }
69
+
70
+ color = colors.get(output_type, "")
71
+ icon = icons.get(output_type, "")
72
+
73
+ # 添加时间戳
74
+ time_str = f"[{datetime.now().strftime('%H:%M:%S')}] " if timestamp else ""
75
+
76
+ # 格式化输出
77
+ formatted_text = f"{color}{time_str}{icon} {text}{Style.RESET_ALL}"
78
+
79
+ return formatted_text
80
+
81
+ @staticmethod
82
+ def print(text: str, output_type: OutputType, timestamp: bool = True):
83
+ print(PrettyOutput.format(text, output_type, timestamp))
84
+
85
+ def get_multiline_input(tip: str) -> str:
86
+ """获取多行输入"""
87
+ PrettyOutput.print(tip + "\n", OutputType.INFO)
88
+ lines = []
89
+
90
+ while True:
91
+ try:
92
+ line = input("... " if lines else ">>> ").strip()
93
+ # 检查是否结束输入
94
+ if not line:
95
+ if not lines: # 如果是第一行就输入空行或finish
96
+ return ""
97
+ break
98
+
99
+ lines.append(line)
100
+
101
+ except KeyboardInterrupt:
102
+ PrettyOutput.print("\n输入已取消", OutputType.ERROR)
103
+ return ""
104
+
105
+ return "\n".join(lines).strip()
@@ -0,0 +1,125 @@
1
+ Metadata-Version: 2.1
2
+ Name: jarvis-ai-assistant
3
+ Version: 0.1.0
4
+ Summary: Jarvis: An AI assistant that uses tools to interact with the system
5
+ Home-page: https://github.com/skyfireitdiy/Jarvis
6
+ Author: skyfire
7
+ Author-email: Your Name <your.email@example.com>
8
+ Project-URL: Homepage, https://github.com/skyfireitdiy/Jarvis
9
+ Keywords: jarvis,ai,assistant,tools,automation
10
+ Classifier: License :: OSI Approved :: MIT License
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Requires-Python: >=3.8
18
+ Description-Content-Type: text/markdown
19
+ Requires-Dist: requests>=2.25.1
20
+ Requires-Dist: beautifulsoup4>=4.9.3
21
+ Requires-Dist: duckduckgo-search>=3.0.0
22
+ Requires-Dist: pyyaml>=5.1
23
+ Requires-Dist: ollama>=0.1.6
24
+ Requires-Dist: sentence-transformers>=2.5.1
25
+ Requires-Dist: chromadb>=0.4.24
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest; extra == "dev"
28
+ Requires-Dist: black; extra == "dev"
29
+ Requires-Dist: isort; extra == "dev"
30
+ Requires-Dist: mypy; extra == "dev"
31
+
32
+ <div align="center">
33
+
34
+ # 🤖 Jarvis AI Assistant
35
+
36
+ <p align="center">
37
+ <img src="docs/images/jarvis-logo.png" alt="Jarvis Logo" width="200"/>
38
+ </p>
39
+
40
+ [![PyPI version](https://badge.fury.io/py/jarvis-ai.svg)](https://badge.fury.io/py/jarvis-ai)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
42
+ [![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/)
43
+
44
+ *Your intelligent assistant for development and system interaction*
45
+
46
+ [Installation](#installation) •
47
+ [Features](#features) •
48
+ [Usage](#usage) •
49
+ [Tools](#tools) •
50
+ [Documentation](https://jarvis-ai.readthedocs.io/)
51
+
52
+ </div>
53
+
54
+ ---
55
+
56
+ ## 🌟 Features
57
+
58
+ 🤖 **Multiple AI Models**
59
+ - Ollama integration (llama3.2, qwen2.5:14b)
60
+ - DuckDuckGo AI search capabilities
61
+
62
+ 🛠️ **Rich Tool Integration**
63
+ - RAG (Retrieval-Augmented Generation)
64
+ - File operations & Shell commands
65
+ - Web search & content extraction
66
+ - Python code execution with dependency management
67
+
68
+ 🔄 **Interactive Experience**
69
+ - Natural language understanding
70
+ - Context-aware responses
71
+ - User-friendly interface
72
+
73
+ ## 🚀 Installation
74
+
75
+ ```bash
76
+ pip install jarvis-ai-assistant
77
+ ```
78
+
79
+ ## 💡 Usage
80
+
81
+ ```bash
82
+ # Quick Start
83
+ jarvis
84
+
85
+ # Using Specific Model
86
+ jarvis --platform ollama --model qwen2.5:14b
87
+
88
+ # Custom Ollama API
89
+ jarvis --platform ollama --model llama3.2 --api-base http://localhost:11434
90
+ ```
91
+
92
+ ## 🧰 Tools
93
+
94
+ | Tool | Description | Example |
95
+ |------|-------------|---------|
96
+ | 🔍 Search | Web search using DuckDuckGo | Search latest tech news |
97
+ | 📚 RAG | Document querying with embeddings | Query your documentation |
98
+ | 🐍 Python | Execute Python code | Run data analysis |
99
+ | 🖥️ Shell | Execute system commands | Manage files and processes |
100
+ | 📂 Files | Read/write operations | Handle configuration files |
101
+ | 🌐 Web | Extract webpage content | Gather information |
102
+ | 👤 User | Interactive input/confirmation | Get user preferences |
103
+
104
+
105
+ ## 🤝 Contributing
106
+
107
+ Contributions are welcome! Please feel free to submit a Pull Request.
108
+
109
+ 1. Fork the repository
110
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
111
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
112
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
113
+ 5. Open a Pull Request
114
+
115
+ ## 📄 License
116
+
117
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
118
+
119
+ ---
120
+
121
+ <div align="center">
122
+
123
+ Made with ❤️ by [Your Name]
124
+
125
+ </div>
@@ -0,0 +1,35 @@
1
+ jarvis/.jarvis,sha256=S4ZMmLqlVLHAPmnwHFQ3vYt0gnDFp-KQRH4okBh8Hpw,209
2
+ jarvis/__init__.py,sha256=01cN4ZP2Yp7XKuyO8I-3HXUXEK_bGvuxNDlGslRbbFs,49
3
+ jarvis/agent.py,sha256=hEatrIothG6C_RuOsygZz4ez1aF1EycnUPwY2Krwiwk,4092
4
+ jarvis/main.py,sha256=wAeeGoRq8fFiTWUCQ31MYVeU9o6SZ48ORUow0jlMJJE,5259
5
+ jarvis/models.py,sha256=ZQAyc39e_UsNmHkME6ATp6053safQ7Gog-oWwETsrMM,4415
6
+ jarvis/utils.py,sha256=-fOPAgiKVPC6DevHM7A7IJvvIzvvFlGM0pHBKyBXDcA,3044
7
+ jarvis/__pycache__/agent.cpython-313.pyc,sha256=I1JYUKC-zedURwuxQQjd9saj_yQKUhpdbb1KNWlY6Ss,4940
8
+ jarvis/__pycache__/models.cpython-313.pyc,sha256=fot2VOV0lgODg4b_WuD-kkq-g7uZGLuZlYXiljlW13U,6350
9
+ jarvis/__pycache__/tools.cpython-313.pyc,sha256=lAD4LrnnWzNZQmHXGfZ_2l7oskOpr2_2OC-gdFhxQY8,33933
10
+ jarvis/__pycache__/utils.cpython-313.pyc,sha256=o8Fubq8Dcrvv3ATzQ9BnZoZjQmU3_FNPrfTt0ANdKdI,5804
11
+ jarvis/tools/__init__.py,sha256=FNF5X32UzKvlT08-hPz7-7vcIyqqMngQYj36LXyNbV0,553
12
+ jarvis/tools/base.py,sha256=OoLmfcg6P5deCzskGnP_6-CdbHV1ThoecpYbf0ip-oY,5074
13
+ jarvis/tools/file_ops.py,sha256=05Vc4u-NGMjLD15WI52eL_nt_RyYt-Z_cXJnnBepf-c,3781
14
+ jarvis/tools/python_script.py,sha256=_eK8LqNs-Mz50zdcgwbjdd8-qAeOl6kJ_qRDvWawGMw,5006
15
+ jarvis/tools/rag.py,sha256=eBrn1fdqy-nd2nR0b4oH1EQpthTYVen-sYDhC5Ypl38,5647
16
+ jarvis/tools/search.py,sha256=dyJmeP_s2tWv5KQejOl-TuVF12B6SXViiXEyTemD1Wo,1412
17
+ jarvis/tools/shell.py,sha256=uGqwUGmqFg1cJkyTg7zyPk3jRwEr-woKTmqcTKdbbg8,1979
18
+ jarvis/tools/user_confirmation.py,sha256=p0JverifHJfnALeIhtKtaVBBVEGkgSpUzT-PSycG4NY,1850
19
+ jarvis/tools/user_interaction.py,sha256=xOaoYsCKTa9-K3mg5tsu1zegn1HKcO40k2aJ3VygZqM,3073
20
+ jarvis/tools/webpage.py,sha256=UTEomu5j7jbOw8c5az2jsjv5E7LeokWKj1QahvZO7xc,3077
21
+ jarvis/tools/__pycache__/__init__.cpython-313.pyc,sha256=wktmOMuGMwQjQ--eRzooUNsL5YjY0bS_CbcSFUWze54,674
22
+ jarvis/tools/__pycache__/base.cpython-313.pyc,sha256=9gpGOdHaHuk5m9lFrZ_hVUZ1RQSOOwvKOy9MIJFaqzk,7327
23
+ jarvis/tools/__pycache__/file_ops.cpython-313.pyc,sha256=bawv11xhWSj5wCtW0QeJLI-InhUBUXaSkogq6rZzvTQ,3636
24
+ jarvis/tools/__pycache__/python_script.cpython-313.pyc,sha256=8JpryqTovEiTvBlWAK1KjZmPvHUuPc9GT9rTXBEQoJc,6693
25
+ jarvis/tools/__pycache__/rag.cpython-313.pyc,sha256=JH6-PSZRMKAvTZqCwlRXJGClxYXNMs-vetU0q7hBLz0,6064
26
+ jarvis/tools/__pycache__/search.cpython-313.pyc,sha256=VX9zztOwIsPCkYwev0A0XJGyu4Tr0PQcQkbbqx8vfB0,1870
27
+ jarvis/tools/__pycache__/shell.cpython-313.pyc,sha256=Xtqt-LzMRfsCXeCE7QxFY8TR8XEeQG_jic73YLkhXQw,2302
28
+ jarvis/tools/__pycache__/user_confirmation.cpython-313.pyc,sha256=wK3Ev10lHSUSRvoYmi7A0GzxYkzU-C4Wfhs5qW_HBqs,2271
29
+ jarvis/tools/__pycache__/user_interaction.cpython-313.pyc,sha256=RuVZ-pmiPBDywY3efgXSfohMAciC1avMGPmBK5qlnew,3305
30
+ jarvis/tools/__pycache__/webpage.cpython-313.pyc,sha256=VcpkaV8IyOOtebedXjn8ybjr8AglU-3-Cs80yzE4FYo,3628
31
+ jarvis_ai_assistant-0.1.0.dist-info/METADATA,sha256=EbX9DRefJ8ugI5t5qQH1HeHfT4c21YyMYez0OI_Rye8,3675
32
+ jarvis_ai_assistant-0.1.0.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
33
+ jarvis_ai_assistant-0.1.0.dist-info/entry_points.txt,sha256=iKu7OMfew9dtfGhW71gIMTg4wvafuPqKb4wyQOnMAGU,44
34
+ jarvis_ai_assistant-0.1.0.dist-info/top_level.txt,sha256=1BOxyWfzOP_ZXj8rVTDnNCJ92bBGB0rwq8N1PCpoMIs,7
35
+ jarvis_ai_assistant-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.7.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ jarvis = jarvis.main:main
@@ -0,0 +1 @@
1
+ jarvis