Metadata-Version: 2.1
Name: llama-index-tools-python-file
Version: 0.1.3
Summary: llama-index tools python_file integration
License: MIT
Author: Your Name
Author-email: you@example.com
Maintainer: ajhofmann
Requires-Python: >=3.8.1,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: llama-index-core (>=0.10.1,<0.11.0)
Description-Content-Type: text/markdown

# Python File Tool

This tool loads a python file and extracts function names, arguments and descriptions automatically. This tool is particular useful for automatically creating custom Tool Specs when you already have well documented python functions.

## Usage

This tool has more extensive example usage documented in a Jupyter notebook [here](https://github.com/emptycrown/llama-hub/tree/main/llama_hub/tools/notebooks/create_a_tool.ipynb)

Here's an example usage of the PythonFileToolSpec.

```python
from llama_index.tools.python_file import PythonFileToolSpec
from llama_index.agent import OpenAIAgent

pyfile = PythonFileToolSpec("./numpy_linalg.py")

agent = OpenAIAgent.from_tools(tool_spec.to_tool_list())

agent.chat(
    """Load the eig, transpose and solve functions from the python file,
and then write a function definition using only builtin python types (List, float, Tuple)
with a short 5-10 line doc string tool prompts for the functions that only has a small description and arguments
"""
)
```

`function_definitions`: Get all of the function definitions from the Python file
`get_function`: Get a specific function definition from the Python file
`get_functions`: Get a list of functions from the python file

This loader is designed to be used as a way to load data as a Tool in a Agent. See [here](https://github.com/emptycrown/llama-hub/tree/main) for examples.

