Merge pull request #58 from Hikari-Haru/autocomplete
Autocomplete and changed the way opener files are loaded to use a folder instead
commit
3775432aae
@ -0,0 +1,37 @@
|
||||
from pathlib import Path
|
||||
import os
|
||||
import re
|
||||
|
||||
import discord
|
||||
from models.usage_service_model import UsageService
|
||||
from models.openai_model import Model
|
||||
|
||||
usage_service = UsageService(Path(os.environ.get("DATA_DIR", os.getcwd())))
|
||||
model = Model(usage_service)
|
||||
|
||||
|
||||
class Settings_autocompleter:
|
||||
async def get_settings(ctx: discord.AutocompleteContext):
|
||||
SETTINGS = [re.sub("^_","",key) for key in model.__dict__.keys() if key not in model._hidden_attributes]
|
||||
return [parameter for parameter in SETTINGS if parameter.startswith(ctx.value.lower())][:25]
|
||||
async def get_value(ctx: discord.AutocompleteContext): # Behaves a bit weird if you go back and edit the parameter without typing in a new command
|
||||
values = {
|
||||
'mode' : ['temperature', 'top_p'],
|
||||
'model' : ["text-davinci-003", "text-curie-001"],
|
||||
'low_usage_mode' : ["True", "False"],
|
||||
'image_size' : ["256x256", "512x512", "1024x1024"],
|
||||
'summarize_conversastion' : ["True", "False"],
|
||||
'welcome_message_enabled' : ["True", "False"]
|
||||
}
|
||||
if ctx.options["parameter"] in values.keys():
|
||||
return[value for value in values[ctx.options["parameter"]]]
|
||||
else:
|
||||
await ctx.interaction.response.defer() # defer so the autocomplete in int values doesn't error but rather just says not found
|
||||
return []
|
||||
|
||||
class File_autocompleter:
|
||||
async def get_openers(ctx: discord.AutocompleteContext):
|
||||
try:
|
||||
return [file for file in os.listdir('openers') if file.startswith(ctx.value.lower())][:25] # returns the 25 first files from your current input
|
||||
except:
|
||||
return ["No 'openers' folder"]
|
@ -0,0 +1 @@
|
||||
I want you to act as an English translator, spelling corrector and improver. I will speak to you in any language and you will detect the language, translate it and answer in the corrected and improved version of my text, in English. I want you to replace my simplified A0-level words and sentences with more beautiful and elegant, upper level English words and sentences. Keep the meaning same, but make them more literary. I want you to only reply the correction, the improvements and nothing else, do not write explanations.
|
@ -0,0 +1 @@
|
||||
I want you to act as a javascript console. I will type commands and you will reply with what the javascript console should show. I want you to only reply with the terminal output inside one unique code block, and nothing else. do not write explanations. do not type commands unless I instruct you to do so. when i need to tell you something in english, i will do so by putting text inside curly brackets {like this}.
|
Loading…
Reference in new issue