Prefect Logo
Marvin AI

The AI Engineering Framework

Build natural language interfaces that are reliable, scalable, and easy to trust.

Structure Text

🧩 AI Models

A drop-in replacement for Pydantic models that can parse natural language.

alt
1from marvin import ai_model
2from pydantic import BaseModel, Field
3
4
5@ai_model
6class Location(BaseModel):
7    city: str
8    state: str= Field(..., description="Two-letter abbreviation")
9
10
11Location("The Big Apple")
12# Location(city="New York", state="NY")
label text

🏷️ AI Classifiers

Turn standard enums into powerful classifiers without training data or examples.

alt
1from marvin import ai_classifier
2from enum import Enum
3
4
5@ai_classifier
6class Sentiment(Enum):
7    POSITIVE = 1
8    NEUTRAL = 0
9    NEGATIVE = -1
10
11
12Sentiment("That sounds great!") 
13# Sentiment.POSITIVE
transform text

🪄 AI Functions

Apply complex business logic and transformations with AI.

alt
1from marvin import ai_fn
2
3
4@ai_fn
5def recipe(ingredients: list[str], style: str) -> str:
6    """
7    Generate a recipe in the provided `style` that uses 
8    all of the `ingredients`. Provide amounts and instructions.
9    """
10
11
12recipe(["lemon", "chicken", "olives", "coucous"], style="North Italy, spicy")
13
14
15# North Italian Spicy Chicken with Lemon, Olives, and Couscous Recipe
16# 
17# Ingredients:
18# - 1 large chicken
19# - 2 lemons
20# ...
work with agents

🤝 AI Applications

Interactive AI assistants that can use tools and manage states

alt
1import random
2from marvin import AIApplication
3from marvin.tools import tool
4
5
6@tool
7def roll_dice(n_dice: int = 1) -> list[int]:
8    return [random.randint(1, 6) for _ in range(n_dice)]
9
10
11chatbot = AIApplication(
12    description="A chatbot that rolls for every action.", 
13    tools=[roll_dice]
14)
15
16
17chatbot("Hi!")