forked from TransformerOptimus/SuperAGI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Restructing tools adding FunctionTool and BaseTool
- Loading branch information
TransformerOptimus
committed
May 18, 2023
1 parent
6c2a856
commit 72f9c8e
Showing
8 changed files
with
141 additions
and
51 deletions.
There are no files selected for viewing
This file contains 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 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 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
Empty file.
This file contains 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,13 @@ | ||
from superagi.tools.base_tool import BaseTool | ||
|
||
|
||
class JiraTool(BaseTool): | ||
def __init__(self): | ||
super().__init__("Jira", "Helps to create Jira tickets", self.create_jira_ticket) | ||
|
||
def execute(self): | ||
print("Jira tool") | ||
|
||
def create_jira_ticket(self, name: str): | ||
print("hello ramram", name) | ||
return |
Empty file.
This file contains 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,43 @@ | ||
import os | ||
from typing import Type | ||
|
||
from pydantic import BaseModel, Field | ||
|
||
from superagi.tools.base_tool import BaseTool | ||
|
||
import tweepy | ||
|
||
class SentTweetSchema(BaseModel): | ||
tweet_text: str = Field( | ||
..., | ||
description="Text post you want to write on twitter.", | ||
) | ||
|
||
|
||
class SendTweetTool(BaseTool): | ||
name = "SendTweet" | ||
description = ( | ||
"A wrapper around Twitter. " | ||
"Useful to send/write tweet on twitter " | ||
"Input should be a search query." | ||
) | ||
args_schema: Type[SentTweetSchema] = SentTweetSchema | ||
|
||
def execute(self, tweet_text: str): | ||
consumer_key = os.environ.get("TW_CONSUMER_KEY") | ||
consumer_secret = os.environ.get("TW_CONSUMER_SECRET") | ||
access_token = os.environ.get("TW_ACCESS_TOKEN") | ||
access_token_secret = os.environ.get("TW_ACCESS_TOKEN_SECRET") | ||
bearer_token = os.environ.get("TW_BEARER_SECRET") | ||
auth = tweepy.OAuthHandler(consumer_key, consumer_secret) | ||
auth.set_access_token(access_token, access_token_secret) | ||
|
||
try: | ||
api = tweepy.API(auth) | ||
api.update_status(tweet_text) | ||
# response = client.create_tweet(text=tweet_text, user_auth=False) | ||
# print(response) | ||
return "Tweet sent successfully!" | ||
except tweepy.TweepyException as e: | ||
print(e) | ||
return f"Error sending tweet: {e}" |
This file contains 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