Skip to main content

llama-index tools code_interpreter integration

Project description

Code Interpreter Tool

This tool can be used to run python scripts and capture the results of stdout and stderr

WARNING: This tool provides the Agent access to the subprocess.run command. Arbitrary code execution is possible on the machine running this tool. This tool is not recommended to be used in a production setting, and would require heavy sandboxing or virtual machines

Usage

Here's an example usage of the CodeInterpreterToolSpec.

from llama_index.tools.code_interpreter import CodeInterpreterToolSpec
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI

code_spec = CodeInterpreterToolSpec()

agent = FunctionAgent(
    tools=code_spec.to_tool_list(), llm=OpenAI(model="gpt-4.1")
)

# Prime the agent to use the tool
resp = await agent.run(
    "Can you help me write some python code to pass to the code_interpreter tool"
)
resp = await agent.run(
    "write a python function to calculate volume of a sphere with radius 4.3cm"
)

The tools available are:

code_interpreter: A tool to evaluate a python script

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

llama_index_tools_code_interpreter-0.4.1.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file llama_index_tools_code_interpreter-0.4.1.tar.gz.

File metadata

File hashes

Hashes for llama_index_tools_code_interpreter-0.4.1.tar.gz
Algorithm Hash digest
SHA256 b8b4edb6484763673864fbe1c140332778b4fcf790b9d7d7bd60173b170b6da0
MD5 5e244268f0d3089be89ba5c2a3580d96
BLAKE2b-256 ae9c510a0b6328099c5a118cc3c0325bb8779cbf30eec9480e3c31d8bb1fc1dc

See more details on using hashes here.

File details

Details for the file llama_index_tools_code_interpreter-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for llama_index_tools_code_interpreter-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0bb008bd7930d841402808860940ca7c45c7423f617a9d0959c1d1341e3e5ae9
MD5 3611e57a3929bbe70dacb7e633257002
BLAKE2b-256 04b19b8368a4d36158941dcfaca154e135efa935037163ce26280a2e03c613a3

See more details on using hashes here.

Supported by

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