Skip to main content

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 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 defintion 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 specfic function definiton 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 for examples.

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

llama_index_tools_python_file-0.1.0.tar.gz (2.5 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page