Add options to allow response to external messages

This commit is contained in:
adamoutler 2023-03-05 22:12:53 +00:00
parent 086f3b6ede
commit f142ad562e
3 changed files with 62 additions and 55 deletions

0
README.md Normal file → Executable file
View File

View File

@ -76,11 +76,18 @@ def get_prompt(command) -> dict:
Returns:
A dictionary containing the data to send to OpenAI.
"""
replyTo=command['message']['data']['replyTo']
replyText=command['message']['data']['replyText']
inputText=command['message']['data']['inputText']
my_prompt = random.choice(settings.PROMPTS)
my_prompt = my_prompt.replace(
"USERNAME", command['message']['data']['username'])
if replyTo:
my_prompt=replyTo +"said \""+replyText+".\"\n In response, "+my_prompt
if inputText:
my_prompt="With the following in mind: "+ command['message']['data']['username'] +" doesn't care about \""+inputText+"\".\n\n"+my_prompt
print("Prompt selected: "+my_prompt)
the_data = DATA
the_data["prompt"] = my_prompt
return the_data

View File

@ -26,9 +26,9 @@ SERVERPORT: int = 8087
""" The prompts used for OpenAI. When the server receives a request, it will
randomly select one of these prompts to use."""
PROMPTS = [
# "Say \"USERNAME does not give a fuck\" as a haiku and mention that it is a haiku.",
"Say \"USERNAME does not give a fuck\" in a Dr Suess poem.",
"Tell me a funny, impossible, story about USERNAME. Make USERNAME seem relatable at the end. Make up an outrageous situation where the moral of the story is: \"USERNAME does not give a fuck\" to this very day."
"Say \"USERNAME does not give a fuck\" using 4 separate Haikus, and be sure to mention they are haikus before or after.",
"Say \"USERNAME does not give a fuck\" within a 10 line Dr Suess poem." #,
"Tell me a funny, impossible, story about USERNAME. Make USERNAME seem relatable at the end. Make up an outrageous situation where the moral of the story is: \"USERNAME does not give a fuck\" to this very day.",
"Say \"USERNAME is completely apethetic and does not give a fuck\" in a verbose manner, using your most colorful words and one metaphor."
]
@ -39,7 +39,7 @@ OPEN_AI_MAX_TOKENS = 500
OPEN_AI_COMPLETION_MODEL = "text-davinci-003"
""" The temperature to use for OpenAI. 0-2, 0 is basicall repeating the prompt, 2 is more random. """
TEMPERATURE = 0.7
TEMPERATURE = 0.8
""" The hash key for the server. Leave this blank if you don't want to use it. """
HASHKEY = bytes(os.getenv('HASHKEY') or "",UTF8) # shared secret for hmac of message