This repository has been archived by the owner on Jun 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 564
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
643 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ build | |
twine | ||
tweepy==4.13.0 | ||
pandas | ||
python-lorem | ||
auto_gpt_plugin_template | ||
newsapi-python | ||
pytest |
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,17 @@ | ||
# Random Values Plugin | ||
|
||
The Random Values plugin will enable AutoGPT to generate various random assorted things like numbers and strings. | ||
|
||
## Key Features: | ||
- make_uuids generates 1 or more UUIDs (128-bit label) | ||
- generate_string generates 1 or more alphanumeric strings of at least 2 characters in length | ||
- generate_password generates 1 or more passwords of 6 or more characters using letters, numbers and punctuation | ||
- generate_placeholder_text generates 1 or more sentences of lorem ipsum text | ||
- random_number draws 1 or more random numbers between min and max | ||
|
||
## Installation: | ||
As part of the AutoGPT plugins package, follow the [installation instructions](https://github.com/Significant-Gravitas/Auto-GPT-Plugins) on the Auto-GPT-Plugins GitHub reporistory README page. | ||
|
||
## AutoGPT Configuration | ||
|
||
Set `ALLOWLISTED_PLUGINS=autogpt-random-values,example-plugin1,example-plugin2,etc` in your AutoGPT `.env` 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,240 @@ | ||
"""Random Values commands.""" | ||
from typing import Any, Dict, List, Optional, Tuple, TypedDict, TypeVar | ||
|
||
from auto_gpt_plugin_template import AutoGPTPluginTemplate | ||
from .random_values import _random_number | ||
from .random_values import _make_uuids | ||
from .random_values import _generate_string | ||
from .random_values import _generate_password | ||
from .random_values import _generate_placeholder_text | ||
|
||
PromptGenerator = TypeVar("PromptGenerator") | ||
|
||
|
||
class Message(TypedDict): | ||
role: str | ||
content: str | ||
|
||
|
||
class AutoGPTRandomValues(AutoGPTPluginTemplate): | ||
""" | ||
Random Values plugin for Auto-GPT. | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self._name = "autogpt-random-values" | ||
self._version = "0.1.0" | ||
self._description = "Enable Auto-GPT with the power of random values." | ||
|
||
def can_handle_on_response(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the on_response method. | ||
Returns: | ||
bool: True if the plugin can handle the on_response method.""" | ||
return False | ||
|
||
def on_response(self, response: str, *args, **kwargs) -> str: | ||
"""This method is called when a response is received from the model.""" | ||
pass | ||
|
||
def can_handle_post_prompt(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the post_prompt method. | ||
Returns: | ||
bool: True if the plugin can handle the post_prompt method.""" | ||
return True | ||
|
||
def can_handle_on_planning(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the on_planning method. | ||
Returns: | ||
bool: True if the plugin can handle the on_planning method.""" | ||
return False | ||
|
||
def on_planning( | ||
self, prompt: PromptGenerator, messages: List[str] | ||
) -> Optional[str]: | ||
"""This method is called before the planning chat completeion is done. | ||
Args: | ||
prompt (PromptGenerator): The prompt generator. | ||
messages (List[str]): The list of messages. | ||
""" | ||
pass | ||
|
||
def can_handle_post_planning(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the post_planning method. | ||
Returns: | ||
bool: True if the plugin can handle the post_planning method.""" | ||
return False | ||
|
||
def post_planning(self, response: str) -> str: | ||
"""This method is called after the planning chat completeion is done. | ||
Args: | ||
response (str): The response. | ||
Returns: | ||
str: The resulting response. | ||
""" | ||
pass | ||
|
||
def can_handle_pre_instruction(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the pre_instruction method. | ||
Returns: | ||
bool: True if the plugin can handle the pre_instruction method.""" | ||
return False | ||
|
||
def pre_instruction(self, messages: List[str]) -> List[str]: | ||
"""This method is called before the instruction chat is done. | ||
Args: | ||
messages (List[str]): The list of context messages. | ||
Returns: | ||
List[str]: The resulting list of messages. | ||
""" | ||
pass | ||
|
||
def can_handle_on_instruction(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the on_instruction method. | ||
Returns: | ||
bool: True if the plugin can handle the on_instruction method.""" | ||
return False | ||
|
||
def on_instruction(self, messages: List[str]) -> Optional[str]: | ||
"""This method is called when the instruction chat is done. | ||
Args: | ||
messages (List[str]): The list of context messages. | ||
Returns: | ||
Optional[str]: The resulting message. | ||
""" | ||
pass | ||
|
||
def can_handle_post_instruction(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the post_instruction method. | ||
Returns: | ||
bool: True if the plugin can handle the post_instruction method.""" | ||
return False | ||
|
||
def post_instruction(self, response: str) -> str: | ||
"""This method is called after the instruction chat is done. | ||
Args: | ||
response (str): The response. | ||
Returns: | ||
str: The resulting response. | ||
""" | ||
pass | ||
|
||
def can_handle_pre_command(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the pre_command method. | ||
Returns: | ||
bool: True if the plugin can handle the pre_command method.""" | ||
return False | ||
|
||
def pre_command( | ||
self, command_name: str, arguments: Dict[str, Any] | ||
) -> Tuple[str, Dict[str, Any]]: | ||
"""This method is called before the command is executed. | ||
Args: | ||
command_name (str): The command name. | ||
arguments (Dict[str, Any]): The arguments. | ||
Returns: | ||
Tuple[str, Dict[str, Any]]: The command name and the arguments. | ||
""" | ||
pass | ||
|
||
def can_handle_post_command(self) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the post_command method. | ||
Returns: | ||
bool: True if the plugin can handle the post_command method.""" | ||
return False | ||
|
||
def post_command(self, command_name: str, response: str) -> str: | ||
"""This method is called after the command is executed. | ||
Args: | ||
command_name (str): The command name. | ||
response (str): The response. | ||
Returns: | ||
str: The resulting response. | ||
""" | ||
pass | ||
|
||
def can_handle_chat_completion( | ||
self, | ||
messages: list[Dict[Any, Any]], | ||
model: str, | ||
temperature: float, | ||
max_tokens: int, | ||
) -> bool: | ||
"""This method is called to check that the plugin can | ||
handle the chat_completion method. | ||
Args: | ||
messages (Dict[Any, Any]): The messages. | ||
model (str): The model name. | ||
temperature (float): The temperature. | ||
max_tokens (int): The max tokens. | ||
Returns: | ||
bool: True if the plugin can handle the chat_completion method.""" | ||
return False | ||
|
||
def handle_chat_completion( | ||
self, | ||
messages: list[Dict[Any, Any]], | ||
model: str, | ||
temperature: float, | ||
max_tokens: int, | ||
) -> str: | ||
"""This method is called when the chat completion is done. | ||
Args: | ||
messages (Dict[Any, Any]): The messages. | ||
model (str): The model name. | ||
temperature (float): The temperature. | ||
max_tokens (int): The max tokens. | ||
Returns: | ||
str: The resulting response. | ||
""" | ||
return None | ||
|
||
def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator: | ||
"""This method is called just after the generate_prompt is called, | ||
but actually before the prompt is generated. | ||
Args: | ||
prompt (PromptGenerator): The prompt generator. | ||
Returns: | ||
PromptGenerator: The prompt generator. | ||
""" | ||
|
||
prompt.add_command( | ||
"random_number", | ||
"Random Number", | ||
{"min": "<integer>", "max": "<integer>", "count": "<integer>"}, | ||
_random_number | ||
) | ||
prompt.add_command( | ||
"make_uuids", | ||
"Make UUIDs", | ||
{"count": "<integer>"}, | ||
_make_uuids | ||
) | ||
prompt.add_command( | ||
"generate_string", | ||
"Generate String", | ||
{"length": "<integer>", "count": "<integer>"}, | ||
_generate_string | ||
) | ||
prompt.add_command( | ||
"generate_password", | ||
"Generate Password", | ||
{"length": "<integer>", "count": "<integer>"}, | ||
_generate_password | ||
) | ||
prompt.add_command( | ||
"generate_placeholder_text", | ||
"Generate Placeholder Text", | ||
{"sentences": "<integer>"}, | ||
_generate_placeholder_text | ||
) | ||
return prompt |
Oops, something went wrong.