You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

treelang

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

treelang

LLM function calling on steroids using Abstract Syntax Trees.

0.7.1
pipPyPI
Maintainers
1

🌲 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.

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts