fructose  by bananaml

Python package for strongly-typed LLM function calls

created 1 year ago
745 stars

Top 47.6% on sourcepulse

GitHubView on GitHub
Project Summary

Fructose provides a Pythonic interface for interacting with Large Language Models (LLMs) by treating LLM calls as strongly-typed functions. It targets developers seeking to integrate LLMs into applications with predictable data structures and robust error handling, simplifying complex LLM interactions through type annotations and decorators.

How It Works

Fructose uses a Python decorator (@ai) that introspects type-annotated functions. When a decorated function is called, Fructose constructs a prompt based on the function's signature, docstring, and type hints, then sends it to an LLM (defaulting to OpenAI). The LLM's response is parsed and validated against the function's return type, supporting primitive, compound, and dataclass types. This approach ensures type safety and reduces boilerplate code for LLM integration.

Quick Start & Requirements

Highlighted Details

  • Supports complex data types like dataclasses and nested structures for LLM input/output.
  • Enables LLMs to call local Python functions (including other @ai decorated functions) via the uses argument.
  • Offers customization through prompt templates (Jinja), flavors (e.g., chain_of_thought), and custom OpenAI clients for proxying or alternative API endpoints.

Maintenance & Community

The project is currently paused due to maintenance being directed elsewhere. The authors suggest alternatives like Instructor or Marvin and welcome forks or new maintainers.

Licensing & Compatibility

The README does not explicitly state a license. Compatibility with commercial or closed-source projects is not specified.

Limitations & Caveats

Fructose is in v0, indicating an unstable API that may break between versions. LLM generation non-determinism can also lead to call failures. The project is under a maintenance pause, and official support for alternative LLM providers or APIs is not guaranteed.

Health Check
Last commit

1 year ago

Responsiveness

1 day

Pull Requests (30d)
0
Issues (30d)
0
Star History
7 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.