import pydantic
import marvin
marvin.classify(
"Marvin is so easy to use!",
labels=["positive", "negative"],
)
class Location(pydantic.BaseModel):
city: str
state: str
marvin.extract("I moved from NY to CHI", target=Location)
marvin.extract(
"I paid $10 for 3 tacos and got a dollar and 25 cents back.",
target=float,
instructions="Only extract money"
)
@marvin.fn
def sentiment(text: str) -> float:
"""
Returns a sentiment score for `text`
between -1 (negative) and 1 (positive).
"""
sentiment("I love working with Marvin!") # 0.8
sentiment("These examples could use some work...") # -0.2
marvin.paint("a simple cup of coffee, still warm")
marvin.classify(
marvin.Image.from_path("docs/images/coffee.png"),
labels=["drink", "food"],
)