Skip to content

Commit

Permalink
fixes to multion example (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
aksh-at authored Jan 18, 2024
1 parent 10d9ab2 commit fd23a81
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions 10_integrations/multion_news_agent.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
# ---
# lambda-test: false
# ---
# # Twitter News Agent
# # MultiOn: Twitter News Agent

# In this example, we use Modal to deploy a cron job that periodically checks for cool AI news everyday and tweets it on Twitter using the MultiOn Agent API.
# In this example, we use Modal to deploy a cron job that periodically checks for AI news everyday and tweets it on Twitter using the MultiOn Agent API.

# ## Import and define the stub
#
# Let's start off with imports, and defining a Modal stub.

import os
from datetime import datetime, timedelta

import modal

stub = modal.Stub("ai-news-tweet-agent")
stub = modal.Stub("multion-news-tweet-agent")

# ## Searching for AI News
#
Expand All @@ -24,16 +23,21 @@

multion_image = modal.Image.debian_slim().pip_install("multion")

# We can now define our main entrypoint, that uses [MultiOn](https://www.multion.ai/) to scrape AI news everyday and post it on our twitter account. We specify a [schedule](/docs/guide/cron) in the function decorator, which
# We can now define our main entrypoint, that uses [MultiOn](https://www.multion.ai/) to scrape AI news everyday and post it on our twitter account. We specify a [schedule](/docs/guide/cron) in the function decorator, which
# means that our function will run automatically at the given interval.

# ## Setup MultiOn
# MultiOn is a next-gen Web Action Agent that can take actions on behalf of the user. You can watch it in action here: [Youtube demo](https://www.youtube.com/watch?v=Rm67ry6bogw)
# ## Set up MultiOn
#
# [MultiOn](https://multion.ai/) is a next-gen Web Action Agent that can take actions on behalf of the user. You can watch it in action here: [Youtube demo](https://www.youtube.com/watch?v=Rm67ry6bogw).
#
# The MultiOn API enables building the next level of web automation & custom AI agents capable of performing complex actions on the internet with just a few lines of code.

#
# To get started, first create an account with [MultiOn](https://app.www.multion.ai/), install the [MultiOn chrome extension](https://chrome.google.com/webstore/detail/ddmjhdbknfidiopmbaceghhhbgbpenmm) and login to your Twitter account in your browser.

@stub.function(image=multion_image, secret=modal.Secret.from_name("MULTION_API_KEY"))

@stub.function(
image=multion_image, secret=modal.Secret.from_name("MULTION_API_KEY")
)
def news_tweet_agent():
# Import MultiOn
import multion
Expand All @@ -57,20 +61,19 @@ def news_tweet_agent():

# ## Test running
#
# We can now test run our scheduled function as follows: `modal run news_tweet.py::stub.news_tweet_agent`
# We can now test run our scheduled function as follows: `modal run multion_news_agent.py.py::stub.news_tweet_agent`

# ## Defining the schedule and deploying
#
# Let's define a function that will be called by Modal every day
# Let's define a function that will be called by Modal every day.


# runs at 9 am (UTC) every day
@stub.function(schedule=modal.Cron("0 9 * * *"))
def run_daily():
news_tweet_agent.remote()


# In order to deploy this as a persistent cron job, you can run `modal deploy news_tweet.py`,
# In order to deploy this as a persistent cron job, you can run `modal deploy multion_news_agent.py`.

# Once the job is deployed, visit the [apps page](/apps) page to see
# its execution history, logs and other stats.

0 comments on commit fd23a81

Please sign in to comment.