• Stars
    star
    5,146
  • Rank 8,067 (Top 0.2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 1 year ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

✨ Build AI interfaces that spark joy

Marvin

The AI engineering framework

Marvin is a lightweight AI engineering framework for building natural language interfaces that are reliable, scalable, and easy to trust.

Large Language Models (LLMs) are pretty cool, but let's face it, they can be a headache to integrate. So, we decided to take the fuss out of the process. Marvin is our answer to the challenge: a neat, flexible tool that works as hard as you do.

Sometimes the most challenging part of working with generative AI is remembering that it's not magic; it's software. It's new, it's nondeterministic, and it's incredibly powerful, but it's still software: parameterized API calls that can trigger dependent actions (and just might talk like a pirate). Marvin's goal is to bring the best practices of building dependable, observable software to the frontier of generative AI. As the team behind Prefect, which does something very similar for data engineers, we've poured years of open-source developer tool experience (and a few hard-won lessons!) into Marvin's design.

Developer Experience

Above all else, Marvin is focused on a rock-solid developer experience. It's ergonomic and opinionated at every layer, but also incrementally adoptable so you can use it as much or as little as you like. It’s a Swiss Army Knife, not a kitchen sink. It’s familiar. It feels like the library you’d write if you had the time: simple, accessible, portable LLM abstractions that you can quickly deploy in your application, whether you’re doing straightforward NLP or building a full-featured autonomous agent.

Marvin prioritizes a developer experience focused on speed and reliability. It's built with type-safety and observability as first-class citizens. Its abstractions are Pythonic, simple, and self-documenting. These core primitives let us build surprisingly complex agentic software without sacrificing control:

🧩 AI Models for structuring text into type-safe schemas

🏷️ AI Classifiers for bulletproof classification and routing

🪄 AI Functions for complex business logic and transformations

🤝 AI Applications for interactive use and persistent state

Ambient AI

With Marvin, we’re taking the first steps on a journey to deliver Ambient AI: omnipresent but unobtrusive autonomous routines that act as persistent translators for noisy, real-world data. Ambient AI makes unstructured data universally accessible to traditional software, allowing the entire software stack to embrace AI technology without interrupting the development workflow. Marvin brings simplicity and stability to AI engineering through abstractions that are reliable and easy to trust.

Marvin's 1.0 release reflects our confidence that its core abstractions are locked-in. And why wouldn't they be? They're the same interfaces you use every day: Python functions, classes, enums, and Pydantic models. Our next objectives are leveraging these primitives to build production deployment patterns and an observability platform.

To hit the ground running, please read Marvin's getting started docs.

Quick Install

Marvin can be installed with pip:

pip install marvin

For more information please see the installation docs.

Documentation

Marvin's docs are available at askmarvin.ai, including concepts, tutorials, and an API reference.

Community

The heart of our community beats in our Discord server. It's a space where you can ask questions, share ideas, or just chat with like-minded developers. Don't be shy, join us on Discord or Twitter!

Core AI Components

Marvin's high-level abstractions are familiar Python interfaces that make it easy to leverage AI in your application. These interfaces aim to be simple and self-documenting, adding a touch of AI magic to everyday objects.

🧩 AI Models

Marvin's most basic component is the AI Model, a drop-in replacement for Pydantic's BaseModel. AI Models can be instantiated from any string, making them ideal for structuring data, entity extraction, and synthetic data generation.

You can learn more about AI models here.

from marvin import ai_model
from pydantic import BaseModel, Field


@ai_model
class Location(BaseModel):
    city: str
    state: str = Field(..., description="The two-letter state abbreviation")


Location("The Big Apple")
# Location(city='New York', state='NY')

🏷️ AI Classifiers

AI Classifiers let you build multi-label classifiers with no code and no training data. Given user input, each classifier uses a clever logit bias trick to force an LLM to deductively choose the best option. It's bulletproof, cost-effective, and lets you build classifiers as quickly as you can write your classes.

You can learn more about AI Classifiers here.

from marvin import ai_classifier
from enum import Enum


@ai_classifier
class AppRoute(Enum):
    """Represents distinct routes command bar for a different application"""

    USER_PROFILE = "/user-profile"
    SEARCH = "/search"
    NOTIFICATIONS = "/notifications"
    SETTINGS = "/settings"
    HELP = "/help"
    CHAT = "/chat"
    DOCS = "/docs"
    PROJECTS = "/projects"
    WORKSPACES = "/workspaces"


AppRoute("update my name")
# AppRoute.USER_PROFILE

🪄 AI Functions

AI Functions look like regular functions, but have no source code. Instead, an AI uses their description and inputs to generate their outputs, making them ideal for NLP applications like sentiment analysis.

You can learn more about AI Functions here.

from marvin import ai_fn


@ai_fn
def sentiment(text: str) -> float:
    """
    Given `text`, returns a number between 1 (positive) and -1 (negative)
    indicating its sentiment score.
    """


sentiment("I love working with Marvin!") # 0.8
sentiment("These examples could use some work...") # -0.2

🤝 AI Applications

AI Applications permit interactive use cases and are designed to be invoked multiple times. They maintain three forms of state: the application's own state, the AI's plan, and a history of interactions. AI Applications can be used to implement many "classic" LLM use cases, such as chatbots, tool-using agents, developer assistants, and more. In addition, thanks to their persistent state and planning, they can implement applications that don't have a traditional chat UX, such as a ToDo app. Here's an example:

from datetime import datetime
from pydantic import BaseModel, Field
from marvin import AIApplication


# create models to represent the state of our ToDo app
class ToDo(BaseModel):
    title: str
    description: str = None
    due_date: datetime = None
    done: bool = False


class ToDoState(BaseModel):
    todos: list[ToDo] = []


# create the app with an initial state and description
todo_app = AIApplication(
    state=ToDoState(),
    description=(
        "A simple todo app. Users will provide instructions for creating and updating"
        " their todo lists."
    ),
)

# invoke the application by adding a todo
response = todo_app("I need to go to the store tomorrow at 5pm")


print(f"Response: {response.content}\n")
# Response: Got it! I've added a new task to your to-do list. You need to go to the store tomorrow at 5pm.


print(f"App state: {todo_app.state.json(indent=2)}")
# App state: {
#   "todos": [
#     {
#       "title": "Go to the store",
#       "description": "Buy groceries",
#       "due_date": "2023-07-12T17:00:00+00:00",
#       "done": false
#     }
#   ]
# }

Things Marvin can build in 5 minutes (seriously)

Scalable APIs, data pipelines, and agents

🏷️ Build bulletproof and lightning-fast classifiers

🧩 Extract structured data from unstructured text

🧪 Generate synthetic data for your applications

🫡 Solve complex deductive and inferential tasks at scale

🔎 Scrape web data without custom scrapers

Chatbots with access to tools, data, and the web

😍 Customize ChatGPT with system prompts and tools

🎓 Extract relevant insights from your data

🧑‍💻 Add a junior developer to your team

🗣️ Quickly add NLP to your app

Coming soon...

📱 AI applications with persistent state

🕵️ Autonomous agents with high-level planning

💬 Text-to-application: generate stateful applications by describing them

More Repositories

1

prefect

Prefect is a workflow orchestration framework for building resilient data pipelines in Python.
Python
16,121
star
2

ControlFlow

🦾 Take control of your AI agents
Python
676
star
3

prefect-recipes

Snippets and templates representing common Customer Success patterns
HCL
238
star
4

server

The Prefect API and backend
Python
211
star
5

ui

The home of the Prefect 1 UI
Vue
177
star
6

langchain-prefect

Tools for using Langchain with Prefect
Python
99
star
7

prefect-aws

Prefect integrations with AWS.
Python
84
star
8

prefect-helm

Helm charts for deploying Prefect Services
Smarty
80
star
9

prefect-dbt

Collection of Prefect integrations for working with dbt with your Prefect flows.
Python
70
star
10

prefect-collection-template

Template to quickly bootstrap a Prefect Collection
Python
65
star
11

prefect-dask

Prefect integrations with the Dask execution framework.
Python
54
star
12

prefect-kubernetes

Prefect integrations for interacting with Kubernetes.
Python
50
star
13

prefect-gcp

Prefect integrations with Google Cloud Platform.
Python
49
star
14

prefect-ray

Prefect integrations with Ray
Python
48
star
15

prefect-shell

Prefect tasks and subflows for interacting with shell commands.
Python
46
star
16

prefect-databricks

Prefect integrations for interacting with Databricks.
Python
39
star
17

prefect-azure

Prefect integrations with Microsoft Azure
Python
35
star
18

prefect-airbyte

Python
34
star
19

prefect-snowflake

Prefect integrations for orchestrating Snowflake.
Python
34
star
20

prefect-email

Prefect tasks and subflows for interacting with email
Python
33
star
21

prefect-openmetadata

Prefect integration with OpenMetadata
Python
31
star
22

prefect-openai

Prefect integrations for working with OpenAI.
Python
31
star
23

prefect-design

Vue
29
star
24

prefect-github

Prefect integrations for interacting with GitHub
Python
29
star
25

prefect-twitter

Prefect integrations for interacting with Twitter.
Python
26
star
26

prefect-docker

Prefect integrations for working with Docker
Python
26
star
27

prefect-postgres

Prefect integrations for interacting with postgres.
Python
24
star
28

prefect-great-expectations

Prefect integrations for interacting with Great Expectations
Python
24
star
29

prefect-twilio

Prefect tasks and subflows for interacting with Twilio.
Python
22
star
30

prefect-sendgrid

Prefect tasks and subflows for interacting with SendGrid.
Python
22
star
31

prefect-ui-library

Vue and Typescript library for Prefect 2 and Prefect Cloud 2
TypeScript
20
star
32

prefect-sqlalchemy

Prefect integrations with SQLAlchemy.
Python
20
star
33

prefect-slack

Prefect integrations with Slack
Python
18
star
34

prefect-jupyter

Prefect integrations interacting with Jupyter.
Python
16
star
35

prefect-background-task-examples

Examples of using Prefect for background tasks in web applications
Python
16
star
36

prefect-monte-carlo

A collection of Prefect tasks and flows to orchestrate Monte Carlo.
Python
14
star
37

miter-design

Miter Design component library made with ♡ by Prefect
SCSS
13
star
38

prefect-monday

Prefect integrations for interacting with monday.com
Python
13
star
39

prefect-binder-tutorial

Jupyter Notebook
12
star
40

marvin-recipes

applications of https://github.com/PrefectHQ/marvin
Python
12
star
41

prefect-gitlab

A Prefect collection for working with GitLab repositories.
Python
12
star
42

prefect-intel

Prefect / Intel collaboration
Python
12
star
43

prefect-hightouch

Prefect integrations for interacting with Hightouch.
Python
11
star
44

terraform-provider-prefect

Go
11
star
45

prefect-operator

A Kubernetes operator for managing Prefect servers and work pools
Go
9
star
46

actions-prefect-deploy

A GitHub Action for deploying a Prefect flow to Prefect Cloud
9
star
47

prefect-hex

Prefect integrations for interacting with Hex.
Python
9
star
48

memory-graphql

Frontend Developer Coding Challenge
JavaScript
9
star
49

vue-compositions

A collection of reusable vue compositions
TypeScript
8
star
50

graphs

Large scale graphs designed for Prefect
TypeScript
8
star
51

prefect-collection-registry

Source of truth for collection contents across the Prefect ecosystem
Python
8
star
52

prefect-bitbucket

Prefect integrations for working with Bitbucket repositories
Python
7
star
53

prefect-demos

Sales Engineering demo repository
Python
6
star
54

memory

Junior Frontend Developer Coding Challenge
JavaScript
5
star
55

sample_flows

Prefect's example Flows
Python
5
star
56

prefect-firebolt

Prefect integrations for working with Firebolt data warehouses.
Python
5
star
57

prefect-census

Prefect integrations for working with Census syncs
Python
5
star
58

prefect-duckdb

Python
4
star
59

premojis

Emojis for Prefect
4
star
60

vue-charts

Vue
4
star
61

prometheus-prefect-exporter

Prometheus Prefect Exporter
Python
3
star
62

legacy-api-docs

Legacy API documentation for https://github.com/PrefectHQ/prefect
HTML
3
star
63

hello-projects

A repository used for demo'ing Prefect projects
Python
2
star
64

prefect-demo-stocks

Python
2
star
65

docs

HTML
2
star
66

eslint-config

JavaScript
1
star
67

GitHub-Issue-Autoresponder

Python
1
star
68

test_flows

A repo of MRE and test work flows
Python
1
star
69

actions-prefect-auth

A GitHub Action for authenticating into Prefect Cloud
1
star
70

documentation

Documentation for Prefect.io v3
MDX
1
star
71

qa-wolf-flows

Flows used by QA Wolf for testing
Python
1
star