Magentic – Use LLMs as simple Python functions

Magentic is a Python library that allows for easy integration of Large Language Models (LLMs) into Python code. By using the @prompt decorator, functions can be created that return structured output from the LLM. These prompts can be mixed with regular Python code to create complex logic. Magentic is compact, atomic, transparent, and compatible. It supports type annotations, works with linters and IDEs, and can be used with decorators like @lru_cache. The library also supports streaming output from the LLM and can process text while it is being generated. Additionally, Magentic allows for the creation of structured outputs and supports asynchronous functions for concurrent querying of the LLM. Overall, Magentic provides a convenient way to leverage the power of LLMs in Python code.

https://github.com/jackmpcollins/magentic

To top