Skip to content

Instantly share code, notes, and snippets.

@jlowin
Created March 31, 2023 18:27
Show Gist options
  • Save jlowin/2ba25c3c67c83e259e1bfa19fdac0102 to your computer and use it in GitHub Desktop.
Save jlowin/2ba25c3c67c83e259e1bfa19fdac0102 to your computer and use it in GitHub Desktop.
Scoring emails with Marvin
from marvin import ai_fn
import pydantic
class EmailDetails(pydantic.BaseModel):
is_positive: bool = pydantic.Field(
description="Whether the email has a positive tone"
)
action_items: list[str] = pydantic.Field(
"Follow-up questions, rewritten as single sentences that are understandable"
" without the rest of the email body"
)
@ai_fn
def process_email(email_body: str) -> EmailDetails:
"""
Scores email sentiment and gets any questions that need answering.
"""
process_email(
email_body="Love Marvin! What are you building next? Can I help?"
)
process_email(
email_body="Enough with the Hitchhiker's shtick. Can you tone it down? It's really annoying."
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment