Skip to content

Instantly share code, notes, and snippets.

@jlowin
Created March 30, 2023 02:34
Show Gist options
  • Save jlowin/ae22fb7ac1788f066f809d2b8f5731ff to your computer and use it in GitHub Desktop.
Save jlowin/ae22fb7ac1788f066f809d2b8f5731ff to your computer and use it in GitHub Desktop.
from marvin import ai_fn
@ai_fn
def generate_people(n: int) -> list[dict]:
"""Generates a list of n people with random names and ages."""
generate_people(n=2) # [{'name': 'Olivia', 'age': 30}, {'name': 'Ethan', 'age': 22}]
@ai_fn
def tweet_sentiment(tweets: list[str]) -> list[int]:
"""Returns sentiment of a tweet on a scale of 1 (negative) to 5 (positive)."""
tweets = [
'I love this product!',
"It might be a good day.",
"I wish I had a better job.",
"LLM tools rock",
"Things are looking up."
]
tweet_sentiment(tweets=tweets) # [5, 4, 2, 4, 4]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment