-
Notifications
You must be signed in to change notification settings - Fork 7.1k
feat: add docs for ApifyActorsTool #2254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d50f70b
add docs for ApifyActorsTool
MQ37 cd91a75
improve readme, add link to template
MQ37 2218c88
format
MQ37 29f7f13
improve tool docs
MQ37 bcb947c
improve readme
MQ37 a9b98b7
Merge branch 'main' into feat/apify_actors_tool
MQ37 72a1b18
Update apifyactorstool.mdx (#1)
jancurn 4ce1987
dans suggestions
MQ37 97c81cd
custom apify icon
MQ37 e220e4e
update descripton
MQ37 c2adc7e
Merge branch 'main' into feat/apify_actors_tool
MQ37 adc105a
Update apifyactorstool.mdx
MQ37 d614f0a
Merge branch 'main' into feat/apify_actors_tool
bhancockio File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| --- | ||
| title: Apify Actors | ||
| description: "`ApifyActorsTool` lets you call Apify Actors to provide your CrewAI workflows with web scraping, crawling, data extraction, and web automation capabilities." | ||
| # hack to use custom Apify icon | ||
| icon: "); -webkit-mask-image: url('https://upload.wikimedia.org/wikipedia/commons/a/ae/Apify.svg');/*" | ||
| --- | ||
|
|
||
| # `ApifyActorsTool` | ||
|
|
||
| Integrate [Apify Actors](https://apify.com/actors) into your CrewAI workflows. | ||
|
|
||
| ## Description | ||
|
|
||
| The `ApifyActorsTool` connects [Apify Actors](https://apify.com/actors), cloud-based programs for web scraping and automation, to your CrewAI workflows. | ||
| Use any of the 4,000+ Actors on [Apify Store](https://apify.com/store) for use cases such as extracting data from social media, search engines, online maps, e-commerce sites, travel portals, or general websites. | ||
|
|
||
| For details, see the [Apify CrewAI integration](https://docs.apify.com/platform/integrations/crewai) in Apify documentation. | ||
|
|
||
| ## Steps to get started | ||
|
|
||
| <Steps> | ||
| <Step title="Install dependencies"> | ||
| Install `crewai[tools]` and `langchain-apify` using pip: `pip install 'crewai[tools]' langchain-apify`. | ||
| </Step> | ||
| <Step title="Obtain an Apify API token"> | ||
| Sign up to [Apify Console](https://console.apify.com/) and get your [Apify API token](https://console.apify.com/settings/integrations).. | ||
| </Step> | ||
| <Step title="Configure environment"> | ||
| Set your Apify API token as the `APIFY_API_TOKEN` environment variable to enable the tool's functionality. | ||
| </Step> | ||
| </Steps> | ||
|
|
||
| ## Usage example | ||
|
|
||
| Use the `ApifyActorsTool` manually to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) to perform a web search: | ||
|
|
||
| ```python | ||
| from crewai_tools import ApifyActorsTool | ||
|
|
||
| # Initialize the tool with an Apify Actor | ||
| tool = ApifyActorsTool(actor_name="apify/rag-web-browser") | ||
|
|
||
| # Run the tool with input parameters | ||
| results = tool.run(run_input={"query": "What is CrewAI?", "maxResults": 5}) | ||
|
|
||
| # Process the results | ||
| for result in results: | ||
| print(f"URL: {result['metadata']['url']}") | ||
| print(f"Content: {result.get('markdown', 'N/A')[:100]}...") | ||
| ``` | ||
|
|
||
| ### Expected output | ||
|
|
||
| Here is the output from running the code above: | ||
|
|
||
| ```text | ||
| URL: https://www.example.com/crewai-intro | ||
| Content: CrewAI is a framework for building AI-powered workflows... | ||
| URL: https://docs.crewai.com/ | ||
| Content: Official documentation for CrewAI... | ||
| ``` | ||
|
|
||
| The `ApifyActorsTool` automatically fetches the Actor definition and input schema from Apify using the provided `actor_name` and then constructs the tool description and argument schema. This means you need to specify only a valid `actor_name`, and the tool handles the rest when used with agents—no need to specify the `run_input`. Here's how it works: | ||
|
|
||
| ```python | ||
| from crewai import Agent | ||
| from crewai_tools import ApifyActorsTool | ||
|
|
||
| rag_browser = ApifyActorsTool(actor_name="apify/rag-web-browser") | ||
|
|
||
| agent = Agent( | ||
| role="Research Analyst", | ||
| goal="Find and summarize information about specific topics", | ||
| backstory="You are an experienced researcher with attention to detail", | ||
| tools=[rag_browser], | ||
| ) | ||
| ``` | ||
|
|
||
| You can run other Actors from [Apify Store](https://apify.com/store) simply by changing the `actor_name` and, when using it manually, adjusting the `run_input` based on the Actor input schema. | ||
|
|
||
| For an example of usage with agents, see the [CrewAI Actor template](https://apify.com/templates/python-crewai). | ||
|
|
||
| ## Configuration | ||
|
|
||
| The `ApifyActorsTool` requires these inputs to work: | ||
|
|
||
| - **`actor_name`** | ||
| The ID of the Apify Actor to run, e.g., `"apify/rag-web-browser"`. Browse all Actors on [Apify Store](https://apify.com/store). | ||
| - **`run_input`** | ||
| A dictionary of input parameters for the Actor when running the tool manually. | ||
| - For example, for the `apify/rag-web-browser` Actor: `{"query": "search term", "maxResults": 5}` | ||
| - See the Actor's [input schema](https://apify.com/apify/rag-web-browser/input-schema) for the list of input parameters. | ||
|
|
||
| ## Resources | ||
|
|
||
| - **[Apify](https://apify.com/)**: Explore the Apify platform. | ||
| - **[How to build an AI agent on Apify](https://blog.apify.com/how-to-build-an-ai-agent/)** - A complete step-by-step guide to creating, publishing, and monetizing AI agents on the Apify platform. | ||
| - **[RAG Web Browser Actor](https://apify.com/apify/rag-web-browser)**: A popular Actor for web search for LLMs. | ||
| - **[CrewAI Integration Guide](https://docs.apify.com/platform/integrations/crewai)**: Follow the official guide for integrating Apify and CrewAI. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.