Skip to content

Commit

Permalink
Merge pull request Significant-Gravitas#190 from sidewaysthought/master
Browse files Browse the repository at this point in the history
  • Loading branch information
ntindle authored Jun 29, 2023
2 parents b149905 + bfb5bfd commit 2855eb1
Show file tree
Hide file tree
Showing 4 changed files with 345 additions and 341 deletions.
12 changes: 6 additions & 6 deletions src/autogpt_plugins/random_values/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
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
- __uuids__: generates 1 or more UUIDs (128-bit label)
- __make_str__: generates 1 or more alphanumeric strings of at least 2 characters in length
- __pwds__: generates 1 or more passwords of 6 or more characters using letters, numbers and punctuation
- __lorem_ipsum__: generates 1 or more sentences of lorem ipsum text
- __rnd_num__: 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.
Set `ALLOWLISTED_PLUGINS=AutoGPTRandomValues,example-plugin1,example-plugin2,etc` in your AutoGPT `.env` file.
102 changes: 48 additions & 54 deletions src/autogpt_plugins/random_values/__init__.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
"""Random Values commands."""
from typing import Any, Dict, List, Optional, Tuple, TypedDict, TypeVar

from auto_gpt_plugin_template import AutoGPTPluginTemplate

from .random_values import (
_generate_password,
_generate_placeholder_text,
_generate_string,
_make_uuids,
_random_number,
)
try:
from .random_values import RandomValues
except ImportError:
from random_values import RandomValues

PromptGenerator = TypeVar("PromptGenerator")


class Message(TypedDict):
role: str
content: str
Expand All @@ -26,9 +20,10 @@ class AutoGPTRandomValues(AutoGPTPluginTemplate):

def __init__(self):
super().__init__()
self._name = "autogpt-random-values"
self._version = "0.1.0"
self._name = "AutoGPTRandomValues"
self._version = "0.1.2"
self._description = "Enable Auto-GPT with the power of random values."
self.plugin_class = RandomValues(self)

def can_handle_on_response(self) -> bool:
"""This method is called to check that the plugin can
Expand All @@ -39,7 +34,7 @@ def can_handle_on_response(self) -> bool:

def on_response(self, response: str, *args, **kwargs) -> str:
"""This method is called when a response is received from the model."""
pass
return response

def can_handle_post_prompt(self) -> bool:
"""This method is called to check that the plugin can
Expand Down Expand Up @@ -79,7 +74,7 @@ def post_planning(self, response: str) -> str:
Returns:
str: The resulting response.
"""
pass
return response

def can_handle_pre_instruction(self) -> bool:
"""This method is called to check that the plugin can
Expand All @@ -95,7 +90,7 @@ def pre_instruction(self, messages: List[str]) -> List[str]:
Returns:
List[str]: The resulting list of messages.
"""
pass
return messages

def can_handle_on_instruction(self) -> bool:
"""This method is called to check that the plugin can
Expand Down Expand Up @@ -127,7 +122,7 @@ def post_instruction(self, response: str) -> str:
Returns:
str: The resulting response.
"""
pass
return response

def can_handle_pre_command(self) -> bool:
"""This method is called to check that the plugin can
Expand All @@ -146,7 +141,7 @@ def pre_command(
Returns:
Tuple[str, Dict[str, Any]]: The command name and the arguments.
"""
pass
return command_name, arguments

def can_handle_post_command(self) -> bool:
"""This method is called to check that the plugin can
Expand All @@ -163,7 +158,7 @@ def post_command(self, command_name: str, response: str) -> str:
Returns:
str: The resulting response.
"""
pass
return response

def can_handle_chat_completion(
self,
Expand Down Expand Up @@ -199,7 +194,7 @@ def handle_chat_completion(
Returns:
str: The resulting response.
"""
return None
return ''

def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator:
"""This method is called just after the generate_prompt is called,
Expand All @@ -210,53 +205,52 @@ def post_prompt(self, prompt: PromptGenerator) -> PromptGenerator:
PromptGenerator: The prompt generator.
"""

prompt.add_command(
"random_number",
"Random Number",
{"min": "<integer>", "max": "<integer>", "count": "<integer>"},
_random_number,
prompt.add_command( # type: ignore
"rnd_num",
"Random Numbers",
{"min": "<int>", "max": "<int>", "cnt": "<int>"},
self.plugin_class.random_number,
)
prompt.add_command(
"make_uuids", "Make UUIDs", {"count": "<integer>"}, _make_uuids
prompt.add_command( # type: ignore
"uuids",
"Make UUIDs",
{"cnt": "<int>"},
self.plugin_class.make_uuids
)
prompt.add_command(
"generate_string",
"Generate String",
{"length": "<integer>", "count": "<integer>"},
_generate_string,
prompt.add_command( # type: ignore
"make_str",
"Generate Strings",
{"len": "<int>", "cnt": "<int>"},
self.plugin_class.generate_string,
)
prompt.add_command(
"generate_password",
"Generate Password",
{"length": "<integer>", "count": "<integer>"},
_generate_password,
prompt.add_command( # type: ignore
"pwds",
"Create Passwords",
{"len": "<int>", "cnt": "<int>"},
self.plugin_class.generate_password,
)
prompt.add_command(
"generate_placeholder_text",
"Generate Placeholder Text",
{"sentences": "<integer>"},
_generate_placeholder_text,
prompt.add_command( # type: ignore
"lorem_ipsum",
"Create Lorem Sentences",
{"cnt": "<int>"},
self.plugin_class.generate_placeholder_text,
)
return prompt

def can_handle_text_embedding(
self, text: str
) -> bool:

def can_handle_text_embedding(self, text: str) -> bool: # type: ignore
return False

def handle_text_embedding(
self, text: str
) -> list:
def handle_text_embedding(self, text: str) -> list: # type: ignore
pass

def can_handle_user_input(self, user_input: str) -> bool:
return False

def can_handle_user_input(self, user_input: str) -> bool:
return False

def user_input(self, user_input: str) -> str:
return user_input

def can_handle_report(self) -> bool:
return False

def report(self, message: str) -> None:
pass
pass
Loading

0 comments on commit 2855eb1

Please sign in to comment.