jarvis-ai-assistant 0.1.100__py3-none-any.whl → 0.1.102__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.
- jarvis/__init__.py +1 -1
- jarvis/agent.py +3 -24
- jarvis/jarvis_code_agent/main.py +1 -3
- jarvis/jarvis_coder/patch_handler.py +5 -5
- jarvis/jarvis_github/main.py +232 -0
- jarvis/models/ai8.py +2 -3
- jarvis/models/oyi.py +1 -3
- jarvis/tools/registry.py +48 -40
- jarvis/utils.py +9 -124
- {jarvis_ai_assistant-0.1.100.dist-info → jarvis_ai_assistant-0.1.102.dist-info}/METADATA +1 -47
- {jarvis_ai_assistant-0.1.100.dist-info → jarvis_ai_assistant-0.1.102.dist-info}/RECORD +16 -21
- {jarvis_ai_assistant-0.1.100.dist-info → jarvis_ai_assistant-0.1.102.dist-info}/entry_points.txt +0 -3
- jarvis/jarvis_codebase/main.py +0 -875
- jarvis/jarvis_coder/main.py +0 -241
- jarvis/jarvis_coder/plan_generator.py +0 -145
- jarvis/jarvis_rag/__init__.py +0 -0
- jarvis/jarvis_rag/main.py +0 -822
- jarvis/tools/rag.py +0 -138
- /jarvis/{jarvis_codebase → jarvis_github}/__init__.py +0 -0
- {jarvis_ai_assistant-0.1.100.dist-info → jarvis_ai_assistant-0.1.102.dist-info}/LICENSE +0 -0
- {jarvis_ai_assistant-0.1.100.dist-info → jarvis_ai_assistant-0.1.102.dist-info}/WHEEL +0 -0
- {jarvis_ai_assistant-0.1.100.dist-info → jarvis_ai_assistant-0.1.102.dist-info}/top_level.txt +0 -0
jarvis/tools/rag.py
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
from typing import Dict, Any
|
|
2
|
-
import os
|
|
3
|
-
from jarvis.utils import OutputType, PrettyOutput
|
|
4
|
-
from jarvis.jarvis_rag.main import RAGTool as RAGCore
|
|
5
|
-
|
|
6
|
-
class RAGTool:
|
|
7
|
-
name = "rag"
|
|
8
|
-
description = "Ask questions based on a document directory, supporting multiple document formats (txt, pdf, docx, etc.)"
|
|
9
|
-
parameters = {
|
|
10
|
-
"type": "object",
|
|
11
|
-
"properties": {
|
|
12
|
-
"dir": {
|
|
13
|
-
"type": "string",
|
|
14
|
-
"description": "Document directory path, supports both relative and absolute paths"
|
|
15
|
-
},
|
|
16
|
-
"question": {
|
|
17
|
-
"type": "string",
|
|
18
|
-
"description": "The question to ask"
|
|
19
|
-
},
|
|
20
|
-
"rebuild_index": {
|
|
21
|
-
"type": "boolean",
|
|
22
|
-
"description": "Whether to rebuild the index",
|
|
23
|
-
"default": False
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
"required": ["dir", "question"]
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
def __init__(self):
|
|
30
|
-
"""Initialize RAG tool"""
|
|
31
|
-
self.rag_instances = {} # Cache RAG instances for different directories
|
|
32
|
-
|
|
33
|
-
def _get_rag_instance(self, dir_path: str) -> RAGCore:
|
|
34
|
-
"""Get or create RAG instance
|
|
35
|
-
|
|
36
|
-
Args:
|
|
37
|
-
dir_path: The absolute path of the document directory
|
|
38
|
-
|
|
39
|
-
Returns:
|
|
40
|
-
RAGCore: RAG instance
|
|
41
|
-
"""
|
|
42
|
-
if dir_path not in self.rag_instances:
|
|
43
|
-
self.rag_instances[dir_path] = RAGCore(dir_path)
|
|
44
|
-
return self.rag_instances[dir_path]
|
|
45
|
-
|
|
46
|
-
def execute(self, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
47
|
-
"""Execute document question and answer
|
|
48
|
-
|
|
49
|
-
Args:
|
|
50
|
-
args: A dictionary containing parameters
|
|
51
|
-
- dir: The document directory path
|
|
52
|
-
- question: The question to ask
|
|
53
|
-
- rebuild_index: Whether to rebuild the index
|
|
54
|
-
|
|
55
|
-
Returns:
|
|
56
|
-
Dict[str, Any]: The execution result
|
|
57
|
-
"""
|
|
58
|
-
try:
|
|
59
|
-
# Get parameters
|
|
60
|
-
dir_path = os.path.expanduser(args["dir"]) # Expand ~ paths
|
|
61
|
-
dir_path = os.path.abspath(dir_path) # Convert to absolute path
|
|
62
|
-
question = args["question"]
|
|
63
|
-
rebuild_index = args.get("rebuild_index", False)
|
|
64
|
-
|
|
65
|
-
# Check if the directory exists
|
|
66
|
-
if not os.path.exists(dir_path):
|
|
67
|
-
return {
|
|
68
|
-
"success": False,
|
|
69
|
-
"stdout": "",
|
|
70
|
-
"stderr": f"Directory does not exist: {dir_path}"
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
# Check if it is a directory
|
|
74
|
-
if not os.path.isdir(dir_path):
|
|
75
|
-
return {
|
|
76
|
-
"success": False,
|
|
77
|
-
"stdout": "",
|
|
78
|
-
"stderr": f"The path is not a directory: {dir_path}"
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
# Get RAG instance
|
|
82
|
-
rag = self._get_rag_instance(dir_path)
|
|
83
|
-
|
|
84
|
-
# If you need to rebuild the index or the index does not exist
|
|
85
|
-
if rebuild_index or not rag.is_index_built():
|
|
86
|
-
PrettyOutput.print("Building document index...", OutputType.INFO)
|
|
87
|
-
rag.build_index(dir_path)
|
|
88
|
-
|
|
89
|
-
# Execute question and answer
|
|
90
|
-
PrettyOutput.print(f"Question: {question}", OutputType.INFO)
|
|
91
|
-
response = rag.ask(question)
|
|
92
|
-
|
|
93
|
-
if response is None:
|
|
94
|
-
return {
|
|
95
|
-
"success": False,
|
|
96
|
-
"stdout": "",
|
|
97
|
-
"stderr": "Failed to get answer, possibly no relevant documents found"
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
"success": True,
|
|
102
|
-
"stdout": response,
|
|
103
|
-
"stderr": ""
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
except Exception as e:
|
|
107
|
-
PrettyOutput.print(f"Document question and answer failed: {str(e)}", OutputType.ERROR)
|
|
108
|
-
return {
|
|
109
|
-
"success": False,
|
|
110
|
-
"stdout": "",
|
|
111
|
-
"stderr": f"Execution failed: {str(e)}"
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
def main():
|
|
115
|
-
"""Run the tool directly from the command line"""
|
|
116
|
-
import argparse
|
|
117
|
-
|
|
118
|
-
parser = argparse.ArgumentParser(description='Document question and answer tool')
|
|
119
|
-
parser.add_argument('--dir', required=True, help='Document directory path')
|
|
120
|
-
parser.add_argument('--question', required=True, help='The question to ask')
|
|
121
|
-
parser.add_argument('--rebuild', action='store_true', help='Rebuild index')
|
|
122
|
-
args = parser.parse_args()
|
|
123
|
-
|
|
124
|
-
tool = RAGTool()
|
|
125
|
-
result = tool.execute({
|
|
126
|
-
"dir": args.dir,
|
|
127
|
-
"question": args.question,
|
|
128
|
-
"rebuild_index": args.rebuild
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
if result["success"]:
|
|
132
|
-
PrettyOutput.print("\nAnswer:", OutputType.INFO)
|
|
133
|
-
PrettyOutput.print(result["stdout"], OutputType.INFO)
|
|
134
|
-
else:
|
|
135
|
-
PrettyOutput.print(result["stderr"], OutputType.ERROR)
|
|
136
|
-
|
|
137
|
-
if __name__ == "__main__":
|
|
138
|
-
main()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{jarvis_ai_assistant-0.1.100.dist-info → jarvis_ai_assistant-0.1.102.dist-info}/top_level.txt
RENAMED
|
File without changes
|