llama-index-tools-python-file 0.3.0__tar.gz → 0.4.0__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.
@@ -0,0 +1,153 @@
1
+ llama_index/_static
2
+ .DS_Store
3
+ # Byte-compiled / optimized / DLL files
4
+ __pycache__/
5
+ *.py[cod]
6
+ *$py.class
7
+
8
+ # C extensions
9
+ *.so
10
+
11
+ # Distribution / packaging
12
+ .Python
13
+ bin/
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ etc/
21
+ include/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ share/
27
+ var/
28
+ wheels/
29
+ pip-wheel-metadata/
30
+ share/python-wheels/
31
+ *.egg-info/
32
+ .installed.cfg
33
+ *.egg
34
+ MANIFEST
35
+
36
+ # PyInstaller
37
+ # Usually these files are written by a python script from a template
38
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
39
+ *.manifest
40
+ *.spec
41
+
42
+ # Installer logs
43
+ pip-log.txt
44
+ pip-delete-this-directory.txt
45
+
46
+ # Unit test / coverage reports
47
+ htmlcov/
48
+ .tox/
49
+ .nox/
50
+ .coverage
51
+ .coverage.*
52
+ .cache
53
+ nosetests.xml
54
+ coverage.xml
55
+ *.cover
56
+ *.py,cover
57
+ .hypothesis/
58
+ .pytest_cache/
59
+ .ruff_cache
60
+
61
+ # Translations
62
+ *.mo
63
+ *.pot
64
+
65
+ # Django stuff:
66
+ *.log
67
+ local_settings.py
68
+ db.sqlite3
69
+ db.sqlite3-journal
70
+
71
+ # Flask stuff:
72
+ instance/
73
+ .webassets-cache
74
+
75
+ # Scrapy stuff:
76
+ .scrapy
77
+
78
+ # Sphinx documentation
79
+ docs/_build/
80
+
81
+ # PyBuilder
82
+ target/
83
+
84
+ # Jupyter Notebook
85
+ .ipynb_checkpoints
86
+ notebooks/
87
+
88
+ # IPython
89
+ profile_default/
90
+ ipython_config.py
91
+
92
+ # pyenv
93
+ .python-version
94
+
95
+ # pipenv
96
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
97
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
98
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
99
+ # install all needed dependencies.
100
+ #Pipfile.lock
101
+
102
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow
103
+ __pypackages__/
104
+
105
+ # Celery stuff
106
+ celerybeat-schedule
107
+ celerybeat.pid
108
+
109
+ # SageMath parsed files
110
+ *.sage.py
111
+
112
+ # Environments
113
+ .env
114
+ .venv
115
+ env/
116
+ venv/
117
+ ENV/
118
+ env.bak/
119
+ venv.bak/
120
+ pyvenv.cfg
121
+
122
+ # Spyder project settings
123
+ .spyderproject
124
+ .spyproject
125
+
126
+ # Rope project settings
127
+ .ropeproject
128
+
129
+ # mkdocs documentation
130
+ /site
131
+
132
+ # mypy
133
+ .mypy_cache/
134
+ .dmypy.json
135
+ dmypy.json
136
+
137
+ # Pyre type checker
138
+ .pyre/
139
+
140
+ # Jetbrains
141
+ .idea
142
+ modules/
143
+ *.swp
144
+
145
+ # VsCode
146
+ .vscode
147
+
148
+ # pipenv
149
+ Pipfile
150
+ Pipfile.lock
151
+
152
+ # pyright
153
+ pyrightconfig.json
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) Jerry Liu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -1,19 +1,13 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: llama-index-tools-python-file
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: llama-index tools python_file integration
5
- License: MIT
6
- Author: Your Name
7
- Author-email: you@example.com
5
+ Author-email: Your Name <you@example.com>
8
6
  Maintainer: ajhofmann
9
- Requires-Python: >=3.9,<4.0
10
- Classifier: License :: OSI Approved :: MIT License
11
- Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.9
13
- Classifier: Programming Language :: Python :: 3.10
14
- Classifier: Programming Language :: Python :: 3.11
15
- Classifier: Programming Language :: Python :: 3.12
16
- Requires-Dist: llama-index-core (>=0.12.0,<0.13.0)
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: <4.0,>=3.9
10
+ Requires-Dist: llama-index-core<0.14,>=0.13.0
17
11
  Description-Content-Type: text/markdown
18
12
 
19
13
  # Python File Tool
@@ -28,17 +22,23 @@ Here's an example usage of the PythonFileToolSpec.
28
22
 
29
23
  ```python
30
24
  from llama_index.tools.python_file import PythonFileToolSpec
31
- from llama_index.agent.openai import OpenAIAgent
25
+ from llama_index.core.agent.workflow import FunctionAgent
26
+ from llama_index.llms.openai import OpenAI
32
27
 
33
28
  pyfile = PythonFileToolSpec("./numpy_linalg.py")
34
29
 
35
- agent = OpenAIAgent.from_tools(tool_spec.to_tool_list())
30
+ agent = FunctionAgent(
31
+ tools=pyfile.to_tool_list(),
32
+ llm=OpenAI(model="gpt-4.1"),
33
+ )
36
34
 
37
- agent.chat(
38
- """Load the eig, transpose and solve functions from the python file,
35
+ print(
36
+ await agent.run(
37
+ """Load the eig, transpose and solve functions from the python file,
39
38
  and then write a function definition using only builtin python types (List, float, Tuple)
40
39
  with a short 5-10 line doc string tool prompts for the functions that only has a small description and arguments
41
40
  """
41
+ )
42
42
  )
43
43
  ```
44
44
 
@@ -47,4 +47,3 @@ with a short 5-10 line doc string tool prompts for the functions that only has a
47
47
  `get_functions`: Get a list of functions from the python file
48
48
 
49
49
  This loader is designed to be used as a way to load data as a Tool in a Agent.
50
-
@@ -10,17 +10,23 @@ Here's an example usage of the PythonFileToolSpec.
10
10
 
11
11
  ```python
12
12
  from llama_index.tools.python_file import PythonFileToolSpec
13
- from llama_index.agent.openai import OpenAIAgent
13
+ from llama_index.core.agent.workflow import FunctionAgent
14
+ from llama_index.llms.openai import OpenAI
14
15
 
15
16
  pyfile = PythonFileToolSpec("./numpy_linalg.py")
16
17
 
17
- agent = OpenAIAgent.from_tools(tool_spec.to_tool_list())
18
+ agent = FunctionAgent(
19
+ tools=pyfile.to_tool_list(),
20
+ llm=OpenAI(model="gpt-4.1"),
21
+ )
18
22
 
19
- agent.chat(
20
- """Load the eig, transpose and solve functions from the python file,
23
+ print(
24
+ await agent.run(
25
+ """Load the eig, transpose and solve functions from the python file,
21
26
  and then write a function definition using only builtin python types (List, float, Tuple)
22
27
  with a short 5-10 line doc string tool prompts for the functions that only has a small description and arguments
23
28
  """
29
+ )
24
30
  )
25
31
  ```
26
32
 
@@ -17,6 +17,7 @@ class PythonFileToolSpec(BaseToolSpec):
17
17
 
18
18
  Args:
19
19
  external (Optional[bool]): Defaults to true. If false, this function will also return functions that start with _
20
+
20
21
  """
21
22
  functions = ""
22
23
  for node in ast.walk(self.tree):
@@ -35,6 +36,7 @@ arguments: {ast.dump(node.args)}
35
36
 
36
37
  Args:
37
38
  name (str): The name of the function to retrieve
39
+
38
40
  """
39
41
  for node in ast.walk(self.tree):
40
42
  if isinstance(node, ast.FunctionDef):
@@ -52,6 +54,7 @@ docstring: {ast.get_docstring(node)}
52
54
 
53
55
  Args:
54
56
  name (List[str]): The names of the functions to retrieve
57
+
55
58
  """
56
59
  functions = ""
57
60
  for name in names:
@@ -0,0 +1,62 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [dependency-groups]
6
+ dev = [
7
+ "ipython==8.10.0",
8
+ "jupyter>=1.0.0,<2",
9
+ "mypy==0.991",
10
+ "pre-commit==3.2.0",
11
+ "pylint==2.15.10",
12
+ "pytest==7.2.1",
13
+ "pytest-mock==3.11.1",
14
+ "ruff==0.11.11",
15
+ "types-Deprecated>=0.1.0",
16
+ "types-PyYAML>=6.0.12.12,<7",
17
+ "types-protobuf>=4.24.0.4,<5",
18
+ "types-redis==4.5.5.0",
19
+ "types-requests==2.28.11.8",
20
+ "types-setuptools==67.1.0.0",
21
+ "black[jupyter]<=23.9.1,>=23.7.0",
22
+ "codespell[toml]>=v2.2.6",
23
+ "diff-cover>=9.2.0",
24
+ "pytest-cov>=6.1.1",
25
+ ]
26
+
27
+ [project]
28
+ name = "llama-index-tools-python-file"
29
+ version = "0.4.0"
30
+ description = "llama-index tools python_file integration"
31
+ authors = [{name = "Your Name", email = "you@example.com"}]
32
+ requires-python = ">=3.9,<4.0"
33
+ readme = "README.md"
34
+ license = "MIT"
35
+ maintainers = [{name = "ajhofmann"}]
36
+ dependencies = ["llama-index-core>=0.13.0,<0.14"]
37
+
38
+ [tool.codespell]
39
+ check-filenames = true
40
+ check-hidden = true
41
+ skip = "*.csv,*.html,*.json,*.jsonl,*.pdf,*.txt,*.ipynb"
42
+
43
+ [tool.hatch.build.targets.sdist]
44
+ include = ["llama_index/"]
45
+ exclude = ["**/BUILD"]
46
+
47
+ [tool.hatch.build.targets.wheel]
48
+ include = ["llama_index/"]
49
+ exclude = ["**/BUILD"]
50
+
51
+ [tool.llamahub]
52
+ contains_example = false
53
+ import_path = "llama_index.tools.python_file"
54
+
55
+ [tool.llamahub.class_authors]
56
+ PythonFileToolSpec = "ajhofmann"
57
+
58
+ [tool.mypy]
59
+ disallow_untyped_defs = true
60
+ exclude = ["_static", "build", "examples", "notebooks", "venv"]
61
+ ignore_missing_imports = true
62
+ python_version = "3.8"
@@ -1,63 +0,0 @@
1
- [build-system]
2
- build-backend = "poetry.core.masonry.api"
3
- requires = ["poetry-core"]
4
-
5
- [tool.codespell]
6
- check-filenames = true
7
- check-hidden = true
8
- skip = "*.csv,*.html,*.json,*.jsonl,*.pdf,*.txt,*.ipynb"
9
-
10
- [tool.llamahub]
11
- contains_example = false
12
- import_path = "llama_index.tools.python_file"
13
-
14
- [tool.llamahub.class_authors]
15
- PythonFileToolSpec = "ajhofmann"
16
-
17
- [tool.mypy]
18
- disallow_untyped_defs = true
19
- exclude = ["_static", "build", "examples", "notebooks", "venv"]
20
- ignore_missing_imports = true
21
- python_version = "3.8"
22
-
23
- [tool.poetry]
24
- authors = ["Your Name <you@example.com>"]
25
- description = "llama-index tools python_file integration"
26
- exclude = ["**/BUILD"]
27
- license = "MIT"
28
- maintainers = ["ajhofmann"]
29
- name = "llama-index-tools-python-file"
30
- readme = "README.md"
31
- version = "0.3.0"
32
-
33
- [tool.poetry.dependencies]
34
- python = ">=3.9,<4.0"
35
- llama-index-core = "^0.12.0"
36
-
37
- [tool.poetry.group.dev.dependencies]
38
- ipython = "8.10.0"
39
- jupyter = "^1.0.0"
40
- mypy = "0.991"
41
- pre-commit = "3.2.0"
42
- pylint = "2.15.10"
43
- pytest = "7.2.1"
44
- pytest-mock = "3.11.1"
45
- ruff = "0.0.292"
46
- tree-sitter-languages = "^1.8.0"
47
- types-Deprecated = ">=0.1.0"
48
- types-PyYAML = "^6.0.12.12"
49
- types-protobuf = "^4.24.0.4"
50
- types-redis = "4.5.5.0"
51
- types-requests = "2.28.11.8"
52
- types-setuptools = "67.1.0.0"
53
-
54
- [tool.poetry.group.dev.dependencies.black]
55
- extras = ["jupyter"]
56
- version = "<=23.9.1,>=23.7.0"
57
-
58
- [tool.poetry.group.dev.dependencies.codespell]
59
- extras = ["toml"]
60
- version = ">=v2.2.6"
61
-
62
- [[tool.poetry.packages]]
63
- include = "llama_index/"