mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 09:08:31 +00:00
add multion tool
This commit is contained in:
@@ -1,27 +1,28 @@
|
||||
from .tools.base_tool import BaseTool, Tool, tool
|
||||
from .tools import (
|
||||
BrowserbaseLoadTool,
|
||||
CodeDocsSearchTool,
|
||||
CSVSearchTool,
|
||||
DirectorySearchTool,
|
||||
DOCXSearchTool,
|
||||
DirectoryReadTool,
|
||||
EXASearchTool,
|
||||
FileReadTool,
|
||||
GithubSearchTool,
|
||||
SerperDevTool,
|
||||
TXTSearchTool,
|
||||
JSONSearchTool,
|
||||
MDXSearchTool,
|
||||
PDFSearchTool,
|
||||
PGSearchTool,
|
||||
RagTool,
|
||||
ScrapeElementFromWebsiteTool,
|
||||
ScrapeWebsiteTool,
|
||||
SeleniumScrapingTool,
|
||||
WebsiteSearchTool,
|
||||
XMLSearchTool,
|
||||
YoutubeChannelSearchTool,
|
||||
YoutubeVideoSearchTool,
|
||||
LlamaIndexTool
|
||||
)
|
||||
BrowserbaseLoadTool,
|
||||
CodeDocsSearchTool,
|
||||
CSVSearchTool,
|
||||
DirectoryReadTool,
|
||||
DirectorySearchTool,
|
||||
DOCXSearchTool,
|
||||
EXASearchTool,
|
||||
FileReadTool,
|
||||
GithubSearchTool,
|
||||
JSONSearchTool,
|
||||
LlamaIndexTool,
|
||||
MDXSearchTool,
|
||||
MultiOnTool,
|
||||
PDFSearchTool,
|
||||
PGSearchTool,
|
||||
RagTool,
|
||||
ScrapeElementFromWebsiteTool,
|
||||
ScrapeWebsiteTool,
|
||||
SeleniumScrapingTool,
|
||||
SerperDevTool,
|
||||
TXTSearchTool,
|
||||
WebsiteSearchTool,
|
||||
XMLSearchTool,
|
||||
YoutubeChannelSearchTool,
|
||||
YoutubeVideoSearchTool,
|
||||
)
|
||||
from .tools.base_tool import BaseTool, Tool, tool
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
from .browserbase_load_tool.browserbase_load_tool import BrowserbaseLoadTool
|
||||
from .code_docs_search_tool.code_docs_search_tool import CodeDocsSearchTool
|
||||
from .csv_search_tool.csv_search_tool import CSVSearchTool
|
||||
from .directory_search_tool.directory_search_tool import DirectorySearchTool
|
||||
from .directory_read_tool.directory_read_tool import DirectoryReadTool
|
||||
from .directory_search_tool.directory_search_tool import DirectorySearchTool
|
||||
from .docx_search_tool.docx_search_tool import DOCXSearchTool
|
||||
from .exa_tools.exa_search_tool import EXASearchTool
|
||||
from .file_read_tool.file_read_tool import FileReadTool
|
||||
from .github_search_tool.github_search_tool import GithubSearchTool
|
||||
from .serper_dev_tool.serper_dev_tool import SerperDevTool
|
||||
from .txt_search_tool.txt_search_tool import TXTSearchTool
|
||||
from .json_search_tool.json_search_tool import JSONSearchTool
|
||||
from .llamaindex_tool.llamaindex_tool import LlamaIndexTool
|
||||
from .mdx_seach_tool.mdx_search_tool import MDXSearchTool
|
||||
from .multion_tool.multion_tool import MultiOnTool
|
||||
from .pdf_search_tool.pdf_search_tool import PDFSearchTool
|
||||
from .pg_seach_tool.pg_search_tool import PGSearchTool
|
||||
from .rag.rag_tool import RagTool
|
||||
from .scrape_element_from_website.scrape_element_from_website import ScrapeElementFromWebsiteTool
|
||||
from .scrape_element_from_website.scrape_element_from_website import (
|
||||
ScrapeElementFromWebsiteTool,
|
||||
)
|
||||
from .scrape_website_tool.scrape_website_tool import ScrapeWebsiteTool
|
||||
from .selenium_scraping_tool.selenium_scraping_tool import SeleniumScrapingTool
|
||||
from .serper_dev_tool.serper_dev_tool import SerperDevTool
|
||||
from .txt_search_tool.txt_search_tool import TXTSearchTool
|
||||
from .website_search.website_search_tool import WebsiteSearchTool
|
||||
from .xml_search_tool.xml_search_tool import XMLSearchTool
|
||||
from .youtube_channel_search_tool.youtube_channel_search_tool import YoutubeChannelSearchTool
|
||||
from .youtube_channel_search_tool.youtube_channel_search_tool import (
|
||||
YoutubeChannelSearchTool,
|
||||
)
|
||||
from .youtube_video_search_tool.youtube_video_search_tool import YoutubeVideoSearchTool
|
||||
from .llamaindex_tool.llamaindex_tool import LlamaIndexTool
|
||||
|
||||
31
src/crewai_tools/tools/multion_tool/README.md
Normal file
31
src/crewai_tools/tools/multion_tool/README.md
Normal file
@@ -0,0 +1,31 @@
|
||||
# MultiOnTool Documentation
|
||||
|
||||
## Description
|
||||
The MultiOnTool, integrated within the crewai_tools package, empowers CrewAI agents with the capability to navigate and interact with the web through natural language instructions. Leveraging the Multion API, this tool facilitates seamless web browsing, making it an essential asset for projects requiring dynamic web data interaction.
|
||||
|
||||
## Installation
|
||||
Ensure the `crewai[tools]` package is installed in your environment to use the MultiOnTool. If it's not already installed, you can add it using the command below:
|
||||
|
||||
## Example
|
||||
The following example demonstrates how to initialize the tool and execute a search with a given query:
|
||||
|
||||
```python
|
||||
from crewai_tools import MultiOnTool
|
||||
|
||||
# Initialize the tool from a MultiOn Tool
|
||||
multion_tool = MultiOnTool(api_key= "YOUR_MULTION_API_KEY", local=False)
|
||||
|
||||
```
|
||||
|
||||
## Arguments
|
||||
|
||||
- `api_key`: Specifies Browserbase API key. Defaults is the `BROWSERBASE_API_KEY` environment variable.
|
||||
- `local`: Optional. Use the local flag to run the agent locally on your browser.
|
||||
|
||||
## Steps to Get Started
|
||||
To effectively use the `MultiOnTool`, follow these steps:
|
||||
|
||||
1. **Install CrewAI**: Confirm that the `crewai[tools]` package is installed in your Python environment.
|
||||
2. **Install and use MultiOn**: Follow MultiOn documentation (https://docs.multion.ai/).
|
||||
|
||||
|
||||
29
src/crewai_tools/tools/multion_tool/example.py
Normal file
29
src/crewai_tools/tools/multion_tool/example.py
Normal file
@@ -0,0 +1,29 @@
|
||||
import os
|
||||
|
||||
from crewai import Agent, Crew, Task
|
||||
from multion_tool import MultiOnTool
|
||||
|
||||
os.environ["OPENAI_API_KEY"] = "Your Key"
|
||||
|
||||
multion_browse_tool = MultiOnTool(api_key="Your Key")
|
||||
|
||||
# Create a new agent
|
||||
Browser = Agent(
|
||||
role="Browser Agent",
|
||||
goal="control web browsers using natural language ",
|
||||
backstory="An expert browsing agent.",
|
||||
tools=[multion_browse_tool],
|
||||
verbose=True,
|
||||
)
|
||||
|
||||
# Define tasks
|
||||
browse = Task(
|
||||
description="Summarize the top 3 trending AI News headlines",
|
||||
expected_output="A summary of the top 3 trending AI News headlines",
|
||||
agent=Browser,
|
||||
)
|
||||
|
||||
|
||||
crew = Crew(agents=[Browser], tasks=[browse])
|
||||
|
||||
crew.kickoff()
|
||||
56
src/crewai_tools/tools/multion_tool/multion_tool.py
Normal file
56
src/crewai_tools/tools/multion_tool/multion_tool.py
Normal file
@@ -0,0 +1,56 @@
|
||||
"""Multion tool spec."""
|
||||
|
||||
from typing import Any, Optional
|
||||
|
||||
from crewai_tools.tools.base_tool import BaseTool
|
||||
|
||||
|
||||
class MultiOnTool(BaseTool):
|
||||
"""Tool to wrap MultiOn Browse Capabilities."""
|
||||
|
||||
name: str = "Multion Browse Tool"
|
||||
description: str = """Multion gives the ability for LLMs to control web browsers using natural language instructions.
|
||||
If the status is 'CONTINUE', reissue the same instruction to continue execution
|
||||
"""
|
||||
multion: Optional[Any] = None
|
||||
session_id: Optional[str] = None
|
||||
local: bool = False
|
||||
|
||||
def __init__(self, api_key: Optional[str] = None, local: bool = False, **kwargs):
|
||||
super().__init__(**kwargs)
|
||||
try:
|
||||
from multion.client import MultiOn # type: ignore
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"`multion` package not found, please run `pip install multion`"
|
||||
)
|
||||
self.session_id = None
|
||||
self.local = local
|
||||
self.multion = MultiOn(api_key=api_key)
|
||||
|
||||
def _run(
|
||||
self,
|
||||
cmd: str,
|
||||
*args: Any,
|
||||
**kwargs: Any,
|
||||
) -> str:
|
||||
"""
|
||||
Run the Multion client with the given command.
|
||||
|
||||
Args:
|
||||
cmd (str): The detailed and specific natural language instructrion for web browsing
|
||||
|
||||
*args (Any): Additional arguments to pass to the Multion client
|
||||
**kwargs (Any): Additional keyword arguments to pass to the Multion client
|
||||
"""
|
||||
|
||||
browse = self.multion.browse(
|
||||
cmd=cmd,
|
||||
session_id=self.session_id,
|
||||
local=self.local,
|
||||
*args,
|
||||
**kwargs,
|
||||
)
|
||||
self.session_id = browse.session_id
|
||||
|
||||
return browse.message + "\n\n STATUS: " + browse.status
|
||||
Reference in New Issue
Block a user