Skip to content
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

Add tool for running Curl commands #182

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions crewai_tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@
XMLSearchTool,
YoutubeChannelSearchTool,
YoutubeVideoSearchTool,
CurlCommandoTool,
)
2 changes: 2 additions & 0 deletions crewai_tools/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@
YoutubeChannelSearchTool,
)
from .youtube_video_search_tool.youtube_video_search_tool import YoutubeVideoSearchTool
from .curl_commando_tool.curl_tool import CurlCommandoTool

22 changes: 22 additions & 0 deletions crewai_tools/tools/curl_commando_tool/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# CurlCommandoTool

## Description
This tool is designed to execute curl commands effortlessly. It’s simple, straightforward, and works like a charm! 🚀

## Installation
Install the crewai_tools package
```
pip install 'crewai[tools]'
```

## Example
```python
from crewai_tools import CurlCommandoTool

# Example : Execute any curl commando it finds during its execution
tool = CurlCommandoTool()

```

## Arguments
- `Execute a curl commando`: Mandatory. Full arguments and the full target url for a curl commando.
17 changes: 17 additions & 0 deletions crewai_tools/tools/curl_commando_tool/curl_tool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from crewai.tools import BaseTool
import subprocess


class CurlCommandoTool(BaseTool):
name: str = "Execute a curl commando"
description: str = "Mandatory full arguments and the full target url for a curl commando"

def _run(self, argument: str) -> str:
# Implementation goes here
base_cmd = ['curl', '--silent', '--show-error']
full_cmd = base_cmd + argument.split()
try:
result = subprocess.run(full_cmd, stdout=subprocess.PIPE)
return result.stdout.decode('utf-8')
except Exception as e:
return f"Error: Failed to execute the curl commando with the the content curl {argument}. {str(e)}"