llama-index tools python_file integration
Project description
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
Here's an example usage of the PythonFileToolSpec.
from llama_index.tools.python_file import PythonFileToolSpec
from llama_index.agent.openai 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.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for llama_index_tools_python_file-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ad4f65dd256bb35f599b8f5b849bf5d7cf30fc0d1a905f754165dac8ab3fa8e |
|
MD5 | e9b784659febc47b15218247ecfb936b |
|
BLAKE2b-256 | 3693808d400f885e0537b9562745b87e31a72707d1ae4c8202c3441ddb747fd3 |
Hashes for llama_index_tools_python_file-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2326234cdca653c449bc4ebcd86e46465004f0832436df681f631cf1a3710a4 |
|
MD5 | d6ec3bf146e3e2e1827dc397a64e5250 |
|
BLAKE2b-256 | 30e7886f5a7f93b1fc8d12c5dbbf66f79988ac67db006cb36555950fbe750b21 |