Skip to main content

LLM function calling on steroids using Abstract Syntax Trees.

Project description

🌲 treelang

PyPI - Version PyPI Downloads License: MIT

Abstract Syntax Trees (ASTs) for advanced function calling with Large Language Models (LLMs), i.e. function-calling on steroids!

Why treelang

  • Complex worflows: Primarily treelang was created as a practical way to support arbitrarily complex function composition and conditionals, where the answer to a question may involve multiple steps each with its own multiple dependencies.

  • Cost-Saving and Green: With treelang you avoid the typical function-calling loop whereby the LLM outputs a function call, your program evaluates it and returns the result back to the LLM for this cycle to repeat until the final result is computed. treelang generates the AST for the full solution using a single call to the underlying LLM!

  • Security: treelang deals with ASTs which means it never needs to know the result from any node in the tree, which may be sensitive (e.g. "my patients email addresses"). The developer can focus on the reliability and security of the underlying tools that will be used to evaluate the AST.

  • Portability: treelang "packages" solutions into ASTs which means that solutions can be easily reused, shared, cached and interpreted.

  • Automated solutions generator: coming soon...

Features

  • Abstract Syntax Tree Representation: treelang speaks Trees.
  • MCP Client: treelang is an MCP client out of the box but any other method of tool provision can be used via the ToolProvider abstraction.
  • LLM Integration: Use LLMs (e.g., OpenAI models) to generate ASTs.
  • Tool Selection: Dynamically select tools (functions) available in the system.
  • Asynchronous Execution: Fully asynchronous design for efficient computation.
  • Higher Order Functions: Support for functional patterns using lambda, map, filter and reduce nodes.
  • Tool generation from Trees: Convert treelang ASTs into Tools that can be added dynamically to MCP servers.

Installation

 pip install treelang

Resources

  • Cookbooks: Play with the Jupiter Notebooks in the cookbook directory to learn more about treelang.

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

treelang-0.7.6.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

treelang-0.7.6-py3-none-any.whl (17.3 kB view details)

Uploaded Python 3

File details

Details for the file treelang-0.7.6.tar.gz.

File metadata

  • Download URL: treelang-0.7.6.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.8 Linux/6.6.6-76060606-generic

File hashes

Hashes for treelang-0.7.6.tar.gz
Algorithm Hash digest
SHA256 d6fdc54fa5e3bdb3d215f0781f18938966cc6f2899e6debd8007d2348bf3cec8
MD5 58472c16e9f936d38922f2af7385b5e7
BLAKE2b-256 7d676d18e116852848d3fecc11eb677a955484532b3e9ef8e6add7a4996667ae

See more details on using hashes here.

File details

Details for the file treelang-0.7.6-py3-none-any.whl.

File metadata

  • Download URL: treelang-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 17.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.12.8 Linux/6.6.6-76060606-generic

File hashes

Hashes for treelang-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 9f138e1cfe3a2e8c0616b266077af523fbb0d392f49b20111c25f5258f03de0d
MD5 c3cf79a28a17c0669ef330d7f15350b4
BLAKE2b-256 cf3591ae56d72163289d13cbd9c34ef1c1321003ed2264bebe0e116051b763a9

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