LLM function calling on steroids using Abstract Syntax Trees.
Project description
🌲 treelang
Abstract Syntax Trees (ASTs) for advanced function calling with Large Language Models (LLMs), i.e. function-calling on steroids!
Why treelang
-
Complex worflows: Primarily
treelangwas 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
treelangyou 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.treelanggenerates the AST for the full solution using a single call to the underlying LLM! -
Security:
treelangdeals 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:
treelangspeaks Trees. - MCP Client:
treelangis an MCP client out of the box but any other method of tool provision can be used via theToolProviderabstraction. - 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
treelangASTs into Tools that can be added dynamically to MCP servers.
Installation
pip install treelang
Resources
- Cookbooks: Play with the Jupiter Notebooks in the
cookbookdirectory to learn more abouttreelang.
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file treelang-0.8.0.tar.gz.
File metadata
- Download URL: treelang-0.8.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.11 Linux/6.9.3-76060903-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc14415c46bda30233f2fe4508c1ddf036a1a99620e26cb5f68f5c3c6277b682
|
|
| MD5 |
b30cec6d0483ae832c93e1519c6f10cc
|
|
| BLAKE2b-256 |
b7bd11c6d3b67627d542be052828d2027d4e09c1f036f9473da355e1f846984e
|
File details
Details for the file treelang-0.8.0-py3-none-any.whl.
File metadata
- Download URL: treelang-0.8.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.11 Linux/6.9.3-76060903-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16f15ae2202b95df68808762cc5fbd1f37b8621da5bf9b7808cf6f0d17e3d4a6
|
|
| MD5 |
cc49837aa36a34719a217a6f39afaf29
|
|
| BLAKE2b-256 |
ca82ed3e9d216da688f39313a79f6e6b0d757e25d01d4d00bc92909fec7f31ac
|