magentic  by jackmpcollins

SDK for integrating LLMs as Python functions using decorators

created 2 years ago
2,348 stars

Top 19.9% on sourcepulse

GitHubView on GitHub
Project Summary

Magentic is a Python library designed to seamlessly integrate Large Language Models (LLMs) as callable Python functions. It targets developers building agentic systems, offering structured outputs, streaming, and LLM-assisted retries for enhanced reliability.

How It Works

Magentic uses decorators like @prompt and @chatprompt to define LLM interactions. These decorators transform Python functions into LLM calls, automatically handling prompt templating, argument injection, and response parsing. It supports structured outputs via Pydantic models and integrates with various LLM providers (OpenAI, Anthropic, Ollama) through pluggable backends. The library also facilitates function calling and chaining, enabling complex agentic workflows.

Quick Start & Requirements

Highlighted Details

  • Supports structured outputs using Pydantic models and basic Python types.
  • Enables streaming of text and structured outputs for real-time processing.
  • Features LLM-assisted retries for improved adherence to complex output schemas.
  • Integrates with OpenTelemetry for observability.
  • Supports multiple LLM backends including OpenAI, Anthropic, Ollama, and LiteLLM.
  • Facilitates function calling and prompt chaining for complex agentic workflows.

Maintenance & Community

  • Actively maintained by jackmpcollins.
  • Community links are not explicitly mentioned in the README.

Licensing & Compatibility

  • The README does not specify a license.

Limitations & Caveats

  • The library's license is not specified, which may impact commercial use.
  • Type checkers might flag decorated functions due to their lack of implementation bodies, requiring specific configurations or # type: ignore comments.
Health Check
Last commit

1 month ago

Responsiveness

1 day

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

Explore Similar Projects

Feedback? Help us improve.