From 13bad2bb691bc74fdb7e8092820e9a18a57da34b Mon Sep 17 00:00:00 2001 From: MQ Date: Thu, 27 Feb 2025 21:08:05 +0100 Subject: [PATCH 01/14] initial implementation --- src/crewai_tools/__init__.py | 1 + src/crewai_tools/tools/__init__.py | 1 + src/crewai_tools/tools/apify_actors/README.md | 51 +++++++++++++++++ .../tools/apify_actors/apify_actors.py | 57 +++++++++++++++++++ 4 files changed, 110 insertions(+) create mode 100644 src/crewai_tools/tools/apify_actors/README.md create mode 100644 src/crewai_tools/tools/apify_actors/apify_actors.py diff --git a/src/crewai_tools/__init__.py b/src/crewai_tools/__init__.py index 4d2ea7e16..6cd3125ff 100644 --- a/src/crewai_tools/__init__.py +++ b/src/crewai_tools/__init__.py @@ -1,5 +1,6 @@ from .tools import ( AIMindTool, + ApifyActorsTool, BraveSearchTool, BrowserbaseLoadTool, CodeDocsSearchTool, diff --git a/src/crewai_tools/tools/__init__.py b/src/crewai_tools/tools/__init__.py index 4a9786fe6..34b200c7a 100644 --- a/src/crewai_tools/tools/__init__.py +++ b/src/crewai_tools/tools/__init__.py @@ -1,4 +1,5 @@ from .ai_mind_tool.ai_mind_tool import AIMindTool +from .apify_actors.apify_actors import ApifyActorsTool from .brave_search_tool.brave_search_tool import BraveSearchTool from .browserbase_load_tool.browserbase_load_tool import BrowserbaseLoadTool from .code_docs_search_tool.code_docs_search_tool import CodeDocsSearchTool diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md new file mode 100644 index 000000000..8172fadc5 --- /dev/null +++ b/src/crewai_tools/tools/apify_actors/README.md @@ -0,0 +1,51 @@ +# ApifyActorsTool + +## Description +The `ApifyActorsTool` is a powerful utility that enables seamless integration of [Apify Actors](https://apify.com/) into your CrewAI workflows. Apify Actors are cloud-based web scraping and automation programs that allow you to extract data, crawl websites, and automate tasks without managing infrastructure. This tool provides an efficient way to run Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) directly within your agents, making it ideal for tasks requiring real-time web data extraction or automation. For more Actors, visit the [Apify Store](https://apify.com/store). + +For more details on using Apify with CrewAI, visit the [Apify CrewAI integration documentation](https://docs.apify.com/platform/integrations/crewai). + +## Installation +To use the `ApifyActorsTool`, you'll need to install the `crewai[tools]` package along with the `langchain-apify` package. Additionally, you must have an Apify API token, which you can obtain by following the instructions in the [Apify API documentation](https://docs.apify.com/platform/integrations/api). Set your API token as an environment variable (`APIFY_API_TOKEN`) to authenticate requests. + +Install the required packages using pip: + +```shell +pip install 'crewai[tools]' langchain-apify +``` + +Set your Apify API token in your environment: + +```shell +export APIFY_API_TOKEN='Your Apify API token' +``` + +## Example +The `ApifyActorsTool` is straightforward to integrate into your CrewAI projects. Below is an example of how to initialize and use the tool to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) to search the web: + +```python +from crewai_tools import ApifyActorsTool + +# Initialize the tool with the desired Apify Actor +tool = ApifyActorsTool(actor_name="apify/rag-web-browser") + +# Run the tool with a specific input, e.g., a search query +results = tool.run(run_input={"query": "What is CrewAI?", "maxResults": 5}) +print(results) +``` + +## Arguments +The `ApifyActorsTool` requires a few key arguments to function correctly: + +- `actor_name`: A mandatory argument specifying the ID of the Apify Actor to run (e.g., `"apify/rag-web-browser"`). You can explore available Actors in the [Apify Actors documentation](https://docs.apify.com/platform/actors). +- `run_input`: A dictionary containing the input parameters for the Actor, such as `query` or `maxResults`. The specific inputs depend on the Actor being used. Refer to the Actor's detail page for input schema; for example, [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser/input-schema) + +The tool dynamically adapts to the chosen Actor, offering flexibility and ease of use for a wide range of automation and scraping tasks. + +## Resources +- [Apify Platform](https://apify.com/) - Learn more about Apify and its ecosystem. +- [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) - A popular Actor for web searching and data retrieval. +- [Apify Actors Documentation](https://docs.apify.com/platform/actors) - Detailed guide to Apify Actors and their capabilities. +- [CrewAI Integration Guide](https://docs.apify.com/platform/integrations/crewai) - Official documentation for integrating Apify with CrewAI. + +The `ApifyActorsTool` empowers your CrewAI agents with robust web scraping and automation capabilities, streamlining complex workflows with minimal setup. diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors/apify_actors.py new file mode 100644 index 000000000..75e0bd7b3 --- /dev/null +++ b/src/crewai_tools/tools/apify_actors/apify_actors.py @@ -0,0 +1,57 @@ +from crewai.tools import BaseTool +from pydantic import Field +from typing import Any + +try: + from langchain_apify import ApifyActorsTool as _ApifyActorsTool +except ImportError: + raise ImportError( + "Could not import langchain_apify python package. " + "Please install it with `pip install langchain-apify` or `uv add langchain-apify`." + ) + + +class ApifyActorsTool(BaseTool): + """Tool that runs Apify Actors. + + To use, you should have the environment variable `APIFY_API_TOKEN` set + with your API key. + + For details, see https://docs.apify.com/platform/integrations/crewai + + Example: + .. code-block:: python + from crewai.tools import ApifyActorsTool + + tool = ApifyActorsTool(actor_id="apify/rag-web-browser") + + results = tool.run({"query": "what is Apify?", "maxResults": 5}) + print(results) + """ + actor_tool: _ApifyActorsTool | None = Field( + default=None, description="Apify Actor Tool" + ) + + def __init__( + self, + actor_name: str, + *args: Any, + **kwargs: Any + ) -> None: + actor_tool = _ApifyActorsTool(actor_name) + + kwargs.update( + { + "name": actor_tool.name, + "description": actor_tool.description, + "args_schema": actor_tool.args_schema, + } + ) + super().__init__(*args, **kwargs) + self.actor_tool = actor_tool + + def _run(self, run_input: dict) -> list[dict]: + if self.actor_tool is None: + msg = "ApifyActorsToolCrewAI is not initialized" + raise ValueError(msg) + return self.actor_tool._run(run_input) From 3fcc7b42cb41006deda1e829cdfab0c81134f2c6 Mon Sep 17 00:00:00 2001 From: MQ Date: Thu, 27 Feb 2025 21:12:38 +0100 Subject: [PATCH 02/14] fix docstring --- src/crewai_tools/tools/apify_actors/apify_actors.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors/apify_actors.py index 75e0bd7b3..af1e6d863 100644 --- a/src/crewai_tools/tools/apify_actors/apify_actors.py +++ b/src/crewai_tools/tools/apify_actors/apify_actors.py @@ -21,7 +21,7 @@ class ApifyActorsTool(BaseTool): Example: .. code-block:: python - from crewai.tools import ApifyActorsTool + from crewai_tools import ApifyActorsTool tool = ApifyActorsTool(actor_id="apify/rag-web-browser") From 5bcb598f75ffcdccc65df091bd3d1fc80b82ffd6 Mon Sep 17 00:00:00 2001 From: MQ Date: Thu, 27 Feb 2025 21:14:42 +0100 Subject: [PATCH 03/14] fix readme --- src/crewai_tools/tools/apify_actors/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md index 8172fadc5..03e279d01 100644 --- a/src/crewai_tools/tools/apify_actors/README.md +++ b/src/crewai_tools/tools/apify_actors/README.md @@ -1,7 +1,7 @@ # ApifyActorsTool ## Description -The `ApifyActorsTool` is a powerful utility that enables seamless integration of [Apify Actors](https://apify.com/) into your CrewAI workflows. Apify Actors are cloud-based web scraping and automation programs that allow you to extract data, crawl websites, and automate tasks without managing infrastructure. This tool provides an efficient way to run Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) directly within your agents, making it ideal for tasks requiring real-time web data extraction or automation. For more Actors, visit the [Apify Store](https://apify.com/store). +The `ApifyActorsTool` is a powerful utility that enables seamless integration of [Apify](https://apify.com/) into your CrewAI workflows. Apify Actors are cloud-based web scraping and automation programs that allow you to extract data, crawl websites, and automate tasks without managing infrastructure. This tool provides an efficient way to run Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) directly within your agents, making it ideal for tasks requiring real-time web data extraction or automation. For more Actors, visit the [Apify Store](https://apify.com/store). For more details on using Apify with CrewAI, visit the [Apify CrewAI integration documentation](https://docs.apify.com/platform/integrations/crewai). @@ -37,8 +37,8 @@ print(results) ## Arguments The `ApifyActorsTool` requires a few key arguments to function correctly: -- `actor_name`: A mandatory argument specifying the ID of the Apify Actor to run (e.g., `"apify/rag-web-browser"`). You can explore available Actors in the [Apify Actors documentation](https://docs.apify.com/platform/actors). -- `run_input`: A dictionary containing the input parameters for the Actor, such as `query` or `maxResults`. The specific inputs depend on the Actor being used. Refer to the Actor's detail page for input schema; for example, [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser/input-schema) +- `actor_name`: A mandatory argument specifying the ID of the Apify Actor to run (e.g., `"apify/rag-web-browser"`). You can explore available Actors in the [Apify Store](https://apify.com/store). +- `run_input`: A dictionary containing the input parameters for the Actor, such as `query` or `maxResults`. The specific inputs depend on the Actor being used. Refer to the Actor's detail page for input schema; for example, [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser/input-schema). The tool dynamically adapts to the chosen Actor, offering flexibility and ease of use for a wide range of automation and scraping tasks. From 867305540c2860433b75df448bbea35de0d6130d Mon Sep 17 00:00:00 2001 From: MQ Date: Thu, 27 Feb 2025 21:27:05 +0100 Subject: [PATCH 04/14] improve --- .../tools/apify_actors/apify_actors.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors/apify_actors.py index af1e6d863..ec08a553d 100644 --- a/src/crewai_tools/tools/apify_actors/apify_actors.py +++ b/src/crewai_tools/tools/apify_actors/apify_actors.py @@ -1,6 +1,7 @@ from crewai.tools import BaseTool from pydantic import Field -from typing import Any +from typing import Any, Dict, List +import os try: from langchain_apify import ApifyActorsTool as _ApifyActorsTool @@ -38,6 +39,14 @@ class ApifyActorsTool(BaseTool): *args: Any, **kwargs: Any ) -> None: + if not os.environ.get("APIFY_API_TOKEN"): + msg = ( + "APIFY_API_TOKEN environment variable is not set. " + "Please set it to your API key, to learn how to get it, " + "see https://docs.apify.com/platform/integrations/api" + ) + raise ValueError(msg) + actor_tool = _ApifyActorsTool(actor_name) kwargs.update( @@ -50,7 +59,15 @@ class ApifyActorsTool(BaseTool): super().__init__(*args, **kwargs) self.actor_tool = actor_tool - def _run(self, run_input: dict) -> list[dict]: + def _run(self, run_input: Dict[str, Any]) -> List[Dict[str, Any]]: + """Run the Actor tool with the given input. + + Returns: + List[Dict[str, Any]]: Results from the actor execution. + + Raises: + ValueError: If 'actor_tool' is not initialized. + """ if self.actor_tool is None: msg = "ApifyActorsToolCrewAI is not initialized" raise ValueError(msg) From 35aff6e84edac4c87d68784e5cfa0b8d030d363d Mon Sep 17 00:00:00 2001 From: MQ Date: Fri, 28 Feb 2025 10:10:56 +0100 Subject: [PATCH 05/14] improve code, lazy import, improve readme --- src/crewai_tools/tools/apify_actors/README.md | 6 ++- .../tools/apify_actors/apify_actors.py | 54 ++++++++++++------- 2 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md index 03e279d01..a29e3ae97 100644 --- a/src/crewai_tools/tools/apify_actors/README.md +++ b/src/crewai_tools/tools/apify_actors/README.md @@ -1,7 +1,7 @@ # ApifyActorsTool ## Description -The `ApifyActorsTool` is a powerful utility that enables seamless integration of [Apify](https://apify.com/) into your CrewAI workflows. Apify Actors are cloud-based web scraping and automation programs that allow you to extract data, crawl websites, and automate tasks without managing infrastructure. This tool provides an efficient way to run Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) directly within your agents, making it ideal for tasks requiring real-time web data extraction or automation. For more Actors, visit the [Apify Store](https://apify.com/store). +The `ApifyActorsTool` is a powerful utility that enables seamless integration of [Apify Actors](https://apify.com/) into your CrewAI workflows. Apify Actors are cloud-based web scraping and automation programs that allow you to extract data, crawl websites, and automate tasks without managing infrastructure. This tool provides an efficient way to run Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) directly within your agents, making it ideal for tasks requiring real-time web data extraction or automation. For more Actors, visit the [Apify Store](https://apify.com/store). For more details on using Apify with CrewAI, visit the [Apify CrewAI integration documentation](https://docs.apify.com/platform/integrations/crewai). @@ -31,7 +31,9 @@ tool = ApifyActorsTool(actor_name="apify/rag-web-browser") # Run the tool with a specific input, e.g., a search query results = tool.run(run_input={"query": "What is CrewAI?", "maxResults": 5}) -print(results) +for result in results: + print(result['metadata']['url']) + print(result['markdown']) ``` ## Arguments diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors/apify_actors.py index ec08a553d..dc229214d 100644 --- a/src/crewai_tools/tools/apify_actors/apify_actors.py +++ b/src/crewai_tools/tools/apify_actors/apify_actors.py @@ -1,16 +1,10 @@ from crewai.tools import BaseTool from pydantic import Field -from typing import Any, Dict, List +from typing import TYPE_CHECKING, Any, Dict, List import os -try: +if TYPE_CHECKING: from langchain_apify import ApifyActorsTool as _ApifyActorsTool -except ImportError: - raise ImportError( - "Could not import langchain_apify python package. " - "Please install it with `pip install langchain-apify` or `uv add langchain-apify`." - ) - class ApifyActorsTool(BaseTool): """Tool that runs Apify Actors. @@ -20,18 +14,30 @@ class ApifyActorsTool(BaseTool): For details, see https://docs.apify.com/platform/integrations/crewai + Args: + actor_name (str): The name of the Apify Actor to run. + *args: Variable length argument list passed to BaseTool. + **kwargs: Arbitrary keyword arguments passed to BaseTool. + + Returns: + List[Dict[str, Any]]: Results from the actor execution. + + Raises: + ValueError: If `APIFY_API_TOKEN` is not set or if the tool is not initialized. + ImportError: If `langchain_apify` package is not installed. + Example: .. code-block:: python from crewai_tools import ApifyActorsTool - tool = ApifyActorsTool(actor_id="apify/rag-web-browser") + tool = ApifyActorsTool(actor_name="apify/rag-web-browser") - results = tool.run({"query": "what is Apify?", "maxResults": 5}) - print(results) + results = tool.run(run_input={"query": "What is CrewAI?", "maxResults": 5}) + for result in results: + print(result['metadata']['url']) + print(result['markdown']) """ - actor_tool: _ApifyActorsTool | None = Field( - default=None, description="Apify Actor Tool" - ) + actor_tool: _ApifyActorsTool = Field(description="Apify Actor Tool") def __init__( self, @@ -47,6 +53,13 @@ class ApifyActorsTool(BaseTool): ) raise ValueError(msg) + try: + from langchain_apify import ApifyActorsTool as _ApifyActorsTool + except ImportError: + raise ImportError( + "Could not import langchain_apify python package. " + "Please install it with `pip install langchain-apify` or `uv add langchain-apify`." + ) actor_tool = _ApifyActorsTool(actor_name) kwargs.update( @@ -68,7 +81,12 @@ class ApifyActorsTool(BaseTool): Raises: ValueError: If 'actor_tool' is not initialized. """ - if self.actor_tool is None: - msg = "ApifyActorsToolCrewAI is not initialized" - raise ValueError(msg) - return self.actor_tool._run(run_input) + try: + return self.actor_tool._run(run_input) + except Exception as e: + msg = ( + f'Failed to run ApifyActorsTool {self.name}. ' + 'Please check your Apify account Actor run logs for more details.' + f'Error: {e}' + ) + raise RuntimeError(msg) from e From 884ea63b493ab34dc9b40c01b73e4aeee30c6d83 Mon Sep 17 00:00:00 2001 From: MQ Date: Fri, 28 Feb 2025 10:22:56 +0100 Subject: [PATCH 06/14] other improvements --- src/crewai_tools/tools/apify_actors/README.md | 94 +++++++++++++------ .../tools/apify_actors/apify_actors.py | 4 +- 2 files changed, 68 insertions(+), 30 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md index a29e3ae97..9917c8d81 100644 --- a/src/crewai_tools/tools/apify_actors/README.md +++ b/src/crewai_tools/tools/apify_actors/README.md @@ -1,53 +1,91 @@ # ApifyActorsTool +Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows with Ease. ## Description -The `ApifyActorsTool` is a powerful utility that enables seamless integration of [Apify Actors](https://apify.com/) into your CrewAI workflows. Apify Actors are cloud-based web scraping and automation programs that allow you to extract data, crawl websites, and automate tasks without managing infrastructure. This tool provides an efficient way to run Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) directly within your agents, making it ideal for tasks requiring real-time web data extraction or automation. For more Actors, visit the [Apify Store](https://apify.com/store). +The `ApifyActorsTool` seamlessly integrates [Apify Actors](https://apify.com/) - cloud-based web scraping and automation programs—into your CrewAI workflows. Whether you need to extract data, crawl websites, or automate tasks, this tool simplifies the process without requiring infrastructure management. -For more details on using Apify with CrewAI, visit the [Apify CrewAI integration documentation](https://docs.apify.com/platform/integrations/crewai). +Key features: +- **Run Actors Directly**: Execute Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) within CrewAI agents. +- **Real-Time Data**: Ideal for tasks requiring up-to-date web data or automation. +- **Explore More**: Discover additional Actors in the [Apify Store](https://apify.com/store). + +For detailed integration guidance, see the [Apify CrewAI documentation](https://docs.apify.com/platform/integrations/crewai). ## Installation -To use the `ApifyActorsTool`, you'll need to install the `crewai[tools]` package along with the `langchain-apify` package. Additionally, you must have an Apify API token, which you can obtain by following the instructions in the [Apify API documentation](https://docs.apify.com/platform/integrations/api). Set your API token as an environment variable (`APIFY_API_TOKEN`) to authenticate requests. +To use `ApifyActorsTool`, install the required packages and configure your Apify API token. You’ll need an API token from Apify - see the [Apify API documentation](https://docs.apify.com/platform/integrations/api) for instructions. -Install the required packages using pip: +### Steps +1. **Install Dependencies** + Use pip to install `crewai[tools]` and `langchain-apify`: + ```bash + pip install 'crewai[tools]' langchain-apify + ``` + Alternatively, with `uv`: + ```bash + uv pip install 'crewai[tools]' langchain-apify + ``` -```shell -pip install 'crewai[tools]' langchain-apify -``` +2. **Set Your API Token** + Export the token as an environment variable: + - On Linux/macOS: + ```bash + export APIFY_API_TOKEN='your-api-token-here' + ``` + - On Windows (Command Prompt): + ```cmd + set APIFY_API_TOKEN=your-api-token-here + ``` + - Or add it to your `.env` file and load it with a library like `python-dotenv`. -Set your Apify API token in your environment: +3. **Verify Installation** + Run `python -c "import langchain_apify; print('Setup complete')"` to ensure dependencies are installed. -```shell -export APIFY_API_TOKEN='Your Apify API token' -``` - -## Example -The `ApifyActorsTool` is straightforward to integrate into your CrewAI projects. Below is an example of how to initialize and use the tool to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) to search the web: +## Usage example +Here’s how to use `ApifyActorsTool` to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) for web searching within a CrewAI workflow: ```python from crewai_tools import ApifyActorsTool -# Initialize the tool with the desired Apify Actor +# Initialize the tool with an Apify Actor tool = ApifyActorsTool(actor_name="apify/rag-web-browser") -# Run the tool with a specific input, e.g., a search query +# 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(result['metadata']['url']) - print(result['markdown']) + print(f"URL: {result['metadata']['url']}") + print(f"Content: {result['markdown'][:100]}...") # Snippet of markdown content ``` -## Arguments -The `ApifyActorsTool` requires a few key arguments to function correctly: +### Expected output +``` +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... +``` -- `actor_name`: A mandatory argument specifying the ID of the Apify Actor to run (e.g., `"apify/rag-web-browser"`). You can explore available Actors in the [Apify Store](https://apify.com/store). -- `run_input`: A dictionary containing the input parameters for the Actor, such as `query` or `maxResults`. The specific inputs depend on the Actor being used. Refer to the Actor's detail page for input schema; for example, [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser/input-schema). +Try other Actors from the [Apify Store](https://apify.com/store) by changing `actor_name` and adjusting `run_input` per the Actor's input schema. -The tool dynamically adapts to the chosen Actor, offering flexibility and ease of use for a wide range of automation and scraping tasks. +## Configuration +The `ApifyActorsTool` requires specific inputs to operate: + +- **`actor_name` (str, required)** + The ID of the Apify Actor to run (e.g., `"apify/rag-web-browser"`). Find Actors in the [Apify Store](https://apify.com/store). +- **`run_input` (dict, required at runtime)** + A dictionary of input parameters for the Actor. Examples: + - For `apify/rag-web-browser`: `{"query": "search term", "maxResults": 5}` + - Check each Actor’s [input schema](https://apify.com/apify/rag-web-browser/input-schema) for details. + +The tool adapts dynamically to the chosen Actor. ## Resources -- [Apify Platform](https://apify.com/) - Learn more about Apify and its ecosystem. -- [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) - A popular Actor for web searching and data retrieval. -- [Apify Actors Documentation](https://docs.apify.com/platform/actors) - Detailed guide to Apify Actors and their capabilities. -- [CrewAI Integration Guide](https://docs.apify.com/platform/integrations/crewai) - Official documentation for integrating Apify with CrewAI. +- **[Apify Platform](https://apify.com/)**: Explore the Apify ecosystem. +- **[RAG Web Browser Actor](https://apify.com/apify/rag-web-browser)**: Try this popular Actor for web data retrieval. +- **[Apify Actors Documentation](https://docs.apify.com/platform/actors)**: Learn how to use and create Actors. +- **[CrewAI Integration Guide](https://docs.apify.com/platform/integrations/crewai)**: Official guide for Apify and CrewAI. -The `ApifyActorsTool` empowers your CrewAI agents with robust web scraping and automation capabilities, streamlining complex workflows with minimal setup. +--- + +Streamline your CrewAI workflows with `ApifyActorsTool` - combine the power of Apify’s web scraping and automation with agent-based intelligence. diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors/apify_actors.py index dc229214d..bb3e39ea1 100644 --- a/src/crewai_tools/tools/apify_actors/apify_actors.py +++ b/src/crewai_tools/tools/apify_actors/apify_actors.py @@ -20,7 +20,7 @@ class ApifyActorsTool(BaseTool): **kwargs: Arbitrary keyword arguments passed to BaseTool. Returns: - List[Dict[str, Any]]: Results from the actor execution. + List[Dict[str, Any]]: Results from the Actor execution. Raises: ValueError: If `APIFY_API_TOKEN` is not set or if the tool is not initialized. @@ -76,7 +76,7 @@ class ApifyActorsTool(BaseTool): """Run the Actor tool with the given input. Returns: - List[Dict[str, Any]]: Results from the actor execution. + List[Dict[str, Any]]: Results from the Actor execution. Raises: ValueError: If 'actor_tool' is not initialized. From 975c71a920fe7708637b433ae70fe0f931f3d227 Mon Sep 17 00:00:00 2001 From: MQ Date: Fri, 28 Feb 2025 10:29:50 +0100 Subject: [PATCH 07/14] fix example --- src/crewai_tools/tools/apify_actors/README.md | 2 +- src/crewai_tools/tools/apify_actors/apify_actors.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md index 9917c8d81..288d54be0 100644 --- a/src/crewai_tools/tools/apify_actors/README.md +++ b/src/crewai_tools/tools/apify_actors/README.md @@ -55,7 +55,7 @@ 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['markdown'][:100]}...") # Snippet of markdown content + print(f"Content: {result.get('markdown', 'N/A')[:100]}...") # Snippet of markdown content ``` ### Expected output diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors/apify_actors.py index bb3e39ea1..b5da1b7b3 100644 --- a/src/crewai_tools/tools/apify_actors/apify_actors.py +++ b/src/crewai_tools/tools/apify_actors/apify_actors.py @@ -34,8 +34,8 @@ class ApifyActorsTool(BaseTool): results = tool.run(run_input={"query": "What is CrewAI?", "maxResults": 5}) for result in results: - print(result['metadata']['url']) - print(result['markdown']) + print(f"URL: {result['metadata']['url']}") + print(f"Content: {result.get('markdown', 'N/A')[:100]}...") """ actor_tool: _ApifyActorsTool = Field(description="Apify Actor Tool") From f329b0d9d2839e60dd24e46230cd8c9c1451716a Mon Sep 17 00:00:00 2001 From: MQ Date: Fri, 28 Feb 2025 12:35:23 +0100 Subject: [PATCH 08/14] improve readme, add link to template --- src/crewai_tools/tools/apify_actors/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md index 288d54be0..f443037a6 100644 --- a/src/crewai_tools/tools/apify_actors/README.md +++ b/src/crewai_tools/tools/apify_actors/README.md @@ -1,7 +1,9 @@ # ApifyActorsTool + Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows with Ease. ## Description + The `ApifyActorsTool` seamlessly integrates [Apify Actors](https://apify.com/) - cloud-based web scraping and automation programs—into your CrewAI workflows. Whether you need to extract data, crawl websites, or automate tasks, this tool simplifies the process without requiring infrastructure management. Key features: @@ -12,9 +14,11 @@ Key features: For detailed integration guidance, see the [Apify CrewAI documentation](https://docs.apify.com/platform/integrations/crewai). ## Installation + To use `ApifyActorsTool`, install the required packages and configure your Apify API token. You’ll need an API token from Apify - see the [Apify API documentation](https://docs.apify.com/platform/integrations/api) for instructions. ### Steps + 1. **Install Dependencies** Use pip to install `crewai[tools]` and `langchain-apify`: ```bash @@ -41,6 +45,7 @@ To use `ApifyActorsTool`, install the required packages and configure your Apify Run `python -c "import langchain_apify; print('Setup complete')"` to ensure dependencies are installed. ## Usage example + Here’s how to use `ApifyActorsTool` to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) for web searching within a CrewAI workflow: ```python @@ -59,6 +64,7 @@ for result in results: ``` ### Expected output + ``` URL: https://www.example.com/crewai-intro Content: CrewAI is a framework for building AI-powered workflows... @@ -66,9 +72,12 @@ URL: https://docs.crewai.com/ Content: Official documentation for CrewAI... ``` +For a more comprehensive example with tool-agent, see [CrewAI Apify Actor template](https://apify.com/templates/python-crewai). + Try other Actors from the [Apify Store](https://apify.com/store) by changing `actor_name` and adjusting `run_input` per the Actor's input schema. ## Configuration + The `ApifyActorsTool` requires specific inputs to operate: - **`actor_name` (str, required)** @@ -81,6 +90,7 @@ The `ApifyActorsTool` requires specific inputs to operate: The tool adapts dynamically to the chosen Actor. ## Resources + - **[Apify Platform](https://apify.com/)**: Explore the Apify ecosystem. - **[RAG Web Browser Actor](https://apify.com/apify/rag-web-browser)**: Try this popular Actor for web data retrieval. - **[Apify Actors Documentation](https://docs.apify.com/platform/actors)**: Learn how to use and create Actors. From 7148c52bf6b14069aeb6486dee35c975688e2815 Mon Sep 17 00:00:00 2001 From: MQ Date: Fri, 28 Feb 2025 12:43:52 +0100 Subject: [PATCH 09/14] format --- src/crewai_tools/tools/apify_actors/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md index f443037a6..9260215cd 100644 --- a/src/crewai_tools/tools/apify_actors/README.md +++ b/src/crewai_tools/tools/apify_actors/README.md @@ -1,6 +1,6 @@ # ApifyActorsTool -Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows with Ease. +Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows with ease. ## Description @@ -65,7 +65,7 @@ for result in results: ### Expected output -``` +```text URL: https://www.example.com/crewai-intro Content: CrewAI is a framework for building AI-powered workflows... URL: https://docs.crewai.com/ @@ -87,7 +87,7 @@ The `ApifyActorsTool` requires specific inputs to operate: - For `apify/rag-web-browser`: `{"query": "search term", "maxResults": 5}` - Check each Actor’s [input schema](https://apify.com/apify/rag-web-browser/input-schema) for details. -The tool adapts dynamically to the chosen Actor. +The tool adapts dynamically to the chosen [Actor](https://docs.apify.com/platform/actors). ## Resources From 3df25e65d54da49c53979fe8bb0ade8d9aced927 Mon Sep 17 00:00:00 2001 From: MQ Date: Fri, 28 Feb 2025 15:40:08 +0100 Subject: [PATCH 10/14] fix --- src/crewai_tools/tools/apify_actors/apify_actors.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors/apify_actors.py index b5da1b7b3..9fc2d965b 100644 --- a/src/crewai_tools/tools/apify_actors/apify_actors.py +++ b/src/crewai_tools/tools/apify_actors/apify_actors.py @@ -37,7 +37,7 @@ class ApifyActorsTool(BaseTool): print(f"URL: {result['metadata']['url']}") print(f"Content: {result.get('markdown', 'N/A')[:100]}...") """ - actor_tool: _ApifyActorsTool = Field(description="Apify Actor Tool") + actor_tool: '_ApifyActorsTool' = Field(description="Apify Actor Tool") def __init__( self, @@ -67,10 +67,10 @@ class ApifyActorsTool(BaseTool): "name": actor_tool.name, "description": actor_tool.description, "args_schema": actor_tool.args_schema, + "actor_tool": actor_tool, } ) super().__init__(*args, **kwargs) - self.actor_tool = actor_tool def _run(self, run_input: Dict[str, Any]) -> List[Dict[str, Any]]: """Run the Actor tool with the given input. From 9c7c7d3d75ea21632b6e7f786001bc58d9f576b6 Mon Sep 17 00:00:00 2001 From: MQ Date: Tue, 4 Mar 2025 11:10:41 +0100 Subject: [PATCH 11/14] apify_actors -> apify_actors_tool, refactor readme --- src/crewai_tools/tools/__init__.py | 2 +- src/crewai_tools/tools/apify_actors/README.md | 101 ------------------ .../tools/apify_actors_tool/README.md | 86 +++++++++++++++ .../apify_actors_tool.py} | 42 ++++---- 4 files changed, 108 insertions(+), 123 deletions(-) delete mode 100644 src/crewai_tools/tools/apify_actors/README.md create mode 100644 src/crewai_tools/tools/apify_actors_tool/README.md rename src/crewai_tools/tools/{apify_actors/apify_actors.py => apify_actors_tool/apify_actors_tool.py} (65%) diff --git a/src/crewai_tools/tools/__init__.py b/src/crewai_tools/tools/__init__.py index 34b200c7a..b1c3b6d68 100644 --- a/src/crewai_tools/tools/__init__.py +++ b/src/crewai_tools/tools/__init__.py @@ -1,5 +1,5 @@ from .ai_mind_tool.ai_mind_tool import AIMindTool -from .apify_actors.apify_actors import ApifyActorsTool +from .apify_actors_tool.apify_actors_tool import ApifyActorsTool from .brave_search_tool.brave_search_tool import BraveSearchTool from .browserbase_load_tool.browserbase_load_tool import BrowserbaseLoadTool from .code_docs_search_tool.code_docs_search_tool import CodeDocsSearchTool diff --git a/src/crewai_tools/tools/apify_actors/README.md b/src/crewai_tools/tools/apify_actors/README.md deleted file mode 100644 index 9260215cd..000000000 --- a/src/crewai_tools/tools/apify_actors/README.md +++ /dev/null @@ -1,101 +0,0 @@ -# ApifyActorsTool - -Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows with ease. - -## Description - -The `ApifyActorsTool` seamlessly integrates [Apify Actors](https://apify.com/) - cloud-based web scraping and automation programs—into your CrewAI workflows. Whether you need to extract data, crawl websites, or automate tasks, this tool simplifies the process without requiring infrastructure management. - -Key features: -- **Run Actors Directly**: Execute Actors like the [RAG Web Browser](https://apify.com/apify/rag-web-browser) within CrewAI agents. -- **Real-Time Data**: Ideal for tasks requiring up-to-date web data or automation. -- **Explore More**: Discover additional Actors in the [Apify Store](https://apify.com/store). - -For detailed integration guidance, see the [Apify CrewAI documentation](https://docs.apify.com/platform/integrations/crewai). - -## Installation - -To use `ApifyActorsTool`, install the required packages and configure your Apify API token. You’ll need an API token from Apify - see the [Apify API documentation](https://docs.apify.com/platform/integrations/api) for instructions. - -### Steps - -1. **Install Dependencies** - Use pip to install `crewai[tools]` and `langchain-apify`: - ```bash - pip install 'crewai[tools]' langchain-apify - ``` - Alternatively, with `uv`: - ```bash - uv pip install 'crewai[tools]' langchain-apify - ``` - -2. **Set Your API Token** - Export the token as an environment variable: - - On Linux/macOS: - ```bash - export APIFY_API_TOKEN='your-api-token-here' - ``` - - On Windows (Command Prompt): - ```cmd - set APIFY_API_TOKEN=your-api-token-here - ``` - - Or add it to your `.env` file and load it with a library like `python-dotenv`. - -3. **Verify Installation** - Run `python -c "import langchain_apify; print('Setup complete')"` to ensure dependencies are installed. - -## Usage example - -Here’s how to use `ApifyActorsTool` to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) for web searching within a CrewAI workflow: - -```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]}...") # Snippet of markdown content -``` - -### Expected output - -```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... -``` - -For a more comprehensive example with tool-agent, see [CrewAI Apify Actor template](https://apify.com/templates/python-crewai). - -Try other Actors from the [Apify Store](https://apify.com/store) by changing `actor_name` and adjusting `run_input` per the Actor's input schema. - -## Configuration - -The `ApifyActorsTool` requires specific inputs to operate: - -- **`actor_name` (str, required)** - The ID of the Apify Actor to run (e.g., `"apify/rag-web-browser"`). Find Actors in the [Apify Store](https://apify.com/store). -- **`run_input` (dict, required at runtime)** - A dictionary of input parameters for the Actor. Examples: - - For `apify/rag-web-browser`: `{"query": "search term", "maxResults": 5}` - - Check each Actor’s [input schema](https://apify.com/apify/rag-web-browser/input-schema) for details. - -The tool adapts dynamically to the chosen [Actor](https://docs.apify.com/platform/actors). - -## Resources - -- **[Apify Platform](https://apify.com/)**: Explore the Apify ecosystem. -- **[RAG Web Browser Actor](https://apify.com/apify/rag-web-browser)**: Try this popular Actor for web data retrieval. -- **[Apify Actors Documentation](https://docs.apify.com/platform/actors)**: Learn how to use and create Actors. -- **[CrewAI Integration Guide](https://docs.apify.com/platform/integrations/crewai)**: Official guide for Apify and CrewAI. - ---- - -Streamline your CrewAI workflows with `ApifyActorsTool` - combine the power of Apify’s web scraping and automation with agent-based intelligence. diff --git a/src/crewai_tools/tools/apify_actors_tool/README.md b/src/crewai_tools/tools/apify_actors_tool/README.md new file mode 100644 index 000000000..f075a896a --- /dev/null +++ b/src/crewai_tools/tools/apify_actors_tool/README.md @@ -0,0 +1,86 @@ +# ApifyActorsTool + +Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows. + +## Description + +ApifyActorsTool connects [Apify Actors](https://apify.com/), cloud-based programs for web scraping and automation, to your CrewAI workflows. You can extract data, crawl websites, and automate tasks, all without requiring infrastructure management. + +**Key features**: +- **Run Actors** directly, like the [RAG Web Browser](https://apify.com/apify/rag-web-browser), with CrewAI agents. +- **Access real-time data** for tasks that need fresh web content or automation. + +See the [Apify CrewAI documentation](https://docs.apify.com/platform/integrations/crewai) for a detailed integration guide. + +## Installation + +To use ApifyActorsTool, install the necessary packages and set up your Apify API token. Follow the [Apify API documentation](https://docs.apify.com/platform/integrations/api) for steps to obtain the token. + +### Steps + +1. **Install dependencies** + Use pip to install `crewai[tools]` and `langchain-apify`: + ```bash + pip install 'crewai[tools]' langchain-apify + ``` + Or, with `uv`: + ```bash + uv pip install 'crewai[tools]' langchain-apify + ``` + +2. **Set your API token** + Export the token as an environment variable: + ```bash + export APIFY_API_TOKEN='your-api-token-here' + ``` + +## Usage example + +Use ApifyActorsTool to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) and 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... +``` + +Experiment with other Actors from the [Apify Store](https://apify.com/store) by updating `actor_name` and `run_input` based on each Actor's input schema. + +For an example of usage with agents, see the [CrewAI Apify Actor template](https://apify.com/templates/python-crewai). + +## Configuration + +ApifyActorsTool requires these inputs to work: + +- **`actor_name`** + The ID of the Apify Actor to run, e.g., `"apify/rag-web-browser"`. Browse options in the [Apify Store](https://apify.com/store). +- **`run_input`** + A dictionary of input parameters for the Actor. Examples: + - For `apify/rag-web-browser`: `{"query": "search term", "maxResults": 5}` + - See each Actor's [input schema](https://apify.com/apify/rag-web-browser/input-schema) for details. + +## Resources + +- **[Apify Platform](https://apify.com/)**: Dive into the Apify ecosystem. +- **[RAG Web Browser Actor](https://apify.com/apify/rag-web-browser)**: Test this popular Actor for web data retrieval. +- **[CrewAI Integration Guide](https://docs.apify.com/platform/integrations/crewai)**: Follow the official guide for Apify and CrewAI. diff --git a/src/crewai_tools/tools/apify_actors/apify_actors.py b/src/crewai_tools/tools/apify_actors_tool/apify_actors_tool.py similarity index 65% rename from src/crewai_tools/tools/apify_actors/apify_actors.py rename to src/crewai_tools/tools/apify_actors_tool/apify_actors_tool.py index 9fc2d965b..37ae7312b 100644 --- a/src/crewai_tools/tools/apify_actors/apify_actors.py +++ b/src/crewai_tools/tools/apify_actors_tool/apify_actors_tool.py @@ -9,34 +9,34 @@ if TYPE_CHECKING: class ApifyActorsTool(BaseTool): """Tool that runs Apify Actors. - To use, you should have the environment variable `APIFY_API_TOKEN` set - with your API key. + To use, you should have the environment variable `APIFY_API_TOKEN` set + with your API key. - For details, see https://docs.apify.com/platform/integrations/crewai + For details, see https://docs.apify.com/platform/integrations/crewai - Args: - actor_name (str): The name of the Apify Actor to run. - *args: Variable length argument list passed to BaseTool. - **kwargs: Arbitrary keyword arguments passed to BaseTool. + Args: + actor_name (str): The name of the Apify Actor to run. + *args: Variable length argument list passed to BaseTool. + **kwargs: Arbitrary keyword arguments passed to BaseTool. - Returns: - List[Dict[str, Any]]: Results from the Actor execution. + Returns: + List[Dict[str, Any]]: Results from the Actor execution. - Raises: - ValueError: If `APIFY_API_TOKEN` is not set or if the tool is not initialized. - ImportError: If `langchain_apify` package is not installed. + Raises: + ValueError: If `APIFY_API_TOKEN` is not set or if the tool is not initialized. + ImportError: If `langchain_apify` package is not installed. - Example: - .. code-block:: python - from crewai_tools import ApifyActorsTool + Example: + .. code-block:: python + from crewai_tools import ApifyActorsTool - tool = ApifyActorsTool(actor_name="apify/rag-web-browser") + tool = ApifyActorsTool(actor_name="apify/rag-web-browser") - results = tool.run(run_input={"query": "What is CrewAI?", "maxResults": 5}) - for result in results: - print(f"URL: {result['metadata']['url']}") - print(f"Content: {result.get('markdown', 'N/A')[:100]}...") - """ + results = tool.run(run_input={"query": "What is CrewAI?", "maxResults": 5}) + for result in results: + print(f"URL: {result['metadata']['url']}") + print(f"Content: {result.get('markdown', 'N/A')[:100]}...") + """ actor_tool: '_ApifyActorsTool' = Field(description="Apify Actor Tool") def __init__( From 7718df5437458c655c00b64481de9c70acf06ac2 Mon Sep 17 00:00:00 2001 From: MQ Date: Tue, 4 Mar 2025 12:45:52 +0100 Subject: [PATCH 12/14] minor consistency improvements --- src/crewai_tools/tools/apify_actors_tool/README.md | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors_tool/README.md b/src/crewai_tools/tools/apify_actors_tool/README.md index f075a896a..aafd77c54 100644 --- a/src/crewai_tools/tools/apify_actors_tool/README.md +++ b/src/crewai_tools/tools/apify_actors_tool/README.md @@ -4,7 +4,7 @@ Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows. ## Description -ApifyActorsTool connects [Apify Actors](https://apify.com/), cloud-based programs for web scraping and automation, to your CrewAI workflows. You can extract data, crawl websites, and automate tasks, all without requiring infrastructure management. +The `ApifyActorsTool` connects [Apify Actors](https://apify.com/), cloud-based programs for web scraping and automation, to your CrewAI workflows. You can extract data, crawl websites, and automate tasks, all without requiring infrastructure management. **Key features**: - **Run Actors** directly, like the [RAG Web Browser](https://apify.com/apify/rag-web-browser), with CrewAI agents. @@ -14,19 +14,15 @@ See the [Apify CrewAI documentation](https://docs.apify.com/platform/integration ## Installation -To use ApifyActorsTool, install the necessary packages and set up your Apify API token. Follow the [Apify API documentation](https://docs.apify.com/platform/integrations/api) for steps to obtain the token. +To use `ApifyActorsTool`, install the necessary packages and set up your Apify API token. Follow the [Apify API documentation](https://docs.apify.com/platform/integrations/api) for steps to obtain the token. ### Steps 1. **Install dependencies** - Use pip to install `crewai[tools]` and `langchain-apify`: + Install `crewai[tools]` and `langchain-apify`: ```bash pip install 'crewai[tools]' langchain-apify ``` - Or, with `uv`: - ```bash - uv pip install 'crewai[tools]' langchain-apify - ``` 2. **Set your API token** Export the token as an environment variable: @@ -36,7 +32,7 @@ To use ApifyActorsTool, install the necessary packages and set up your Apify API ## Usage example -Use ApifyActorsTool to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) and perform a web search: +Use `ApifyActorsTool` to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) and perform a web search: ```python from crewai_tools import ApifyActorsTool @@ -70,7 +66,7 @@ For an example of usage with agents, see the [CrewAI Apify Actor template](https ## Configuration -ApifyActorsTool requires these inputs to work: +The `ApifyActorsTool` requires these inputs to work: - **`actor_name`** The ID of the Apify Actor to run, e.g., `"apify/rag-web-browser"`. Browse options in the [Apify Store](https://apify.com/store). From cad804e87bd2f7e915aefa9d0930da67fee7b1d4 Mon Sep 17 00:00:00 2001 From: MQ Date: Fri, 7 Mar 2025 11:00:54 +0100 Subject: [PATCH 13/14] update readme --- .../tools/apify_actors_tool/README.md | 47 ++++++++++++------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/src/crewai_tools/tools/apify_actors_tool/README.md b/src/crewai_tools/tools/apify_actors_tool/README.md index aafd77c54..7e465037c 100644 --- a/src/crewai_tools/tools/apify_actors_tool/README.md +++ b/src/crewai_tools/tools/apify_actors_tool/README.md @@ -1,16 +1,13 @@ # ApifyActorsTool -Integrate [Apify Actors](https://apify.com/) into your CrewAI workflows. +Integrate [Apify Actors](https://apify.com/actors) into your CrewAI workflows. ## Description -The `ApifyActorsTool` connects [Apify Actors](https://apify.com/), cloud-based programs for web scraping and automation, to your CrewAI workflows. You can extract data, crawl websites, and automate tasks, all without requiring infrastructure management. +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. -**Key features**: -- **Run Actors** directly, like the [RAG Web Browser](https://apify.com/apify/rag-web-browser), with CrewAI agents. -- **Access real-time data** for tasks that need fresh web content or automation. - -See the [Apify CrewAI documentation](https://docs.apify.com/platform/integrations/crewai) for a detailed integration guide. +For details, see the [Apify CrewAI integration](https://docs.apify.com/platform/integrations/crewai) in Apify documentation. ## Installation @@ -32,7 +29,7 @@ To use `ApifyActorsTool`, install the necessary packages and set up your Apify A ## Usage example -Use `ApifyActorsTool` to run the [RAG Web Browser Actor](https://apify.com/apify/rag-web-browser) and perform a web search: +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 @@ -60,23 +57,39 @@ URL: https://docs.crewai.com/ Content: Official documentation for CrewAI... ``` -Experiment with other Actors from the [Apify Store](https://apify.com/store) by updating `actor_name` and `run_input` based on each Actor's input schema. +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: -For an example of usage with agents, see the [CrewAI Apify Actor template](https://apify.com/templates/python-crewai). +```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 options in the [Apify Store](https://apify.com/store). + 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. Examples: - - For `apify/rag-web-browser`: `{"query": "search term", "maxResults": 5}` - - See each Actor's [input schema](https://apify.com/apify/rag-web-browser/input-schema) for details. + 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 Platform](https://apify.com/)**: Dive into the Apify ecosystem. -- **[RAG Web Browser Actor](https://apify.com/apify/rag-web-browser)**: Test this popular Actor for web data retrieval. -- **[CrewAI Integration Guide](https://docs.apify.com/platform/integrations/crewai)**: Follow the official guide for Apify and CrewAI. +- **[Apify](https://apify.com/)**: Explore 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. From 292adef7baac9b44d7cc6cb8b0f3b9ec2eb7310f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Kopeck=C3=BD?= Date: Tue, 11 Mar 2025 18:02:15 +0100 Subject: [PATCH 14/14] Update README.md --- src/crewai_tools/tools/apify_actors_tool/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/src/crewai_tools/tools/apify_actors_tool/README.md b/src/crewai_tools/tools/apify_actors_tool/README.md index 7e465037c..c00891deb 100644 --- a/src/crewai_tools/tools/apify_actors_tool/README.md +++ b/src/crewai_tools/tools/apify_actors_tool/README.md @@ -91,5 +91,6 @@ The `ApifyActorsTool` requires these inputs to work: ## 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.