Kaveen Kumarasinghe 2 years ago
commit 39e8a61dc7

@ -0,0 +1,34 @@
name: Publish to PyPI
on:
release:
types: [published]
permissions:
contents: read
jobs:
main:
name: sdist + pure wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up latest Python
uses: actions/setup-python@v4
with:
python-version: "*"
- name: Install latest pip, build, twine
run: |
python -m pip install --upgrade --disable-pip-version-check pip
python -m pip install --upgrade build twine
- name: Build wheel and source distributions
run: python -m build
- name: Upload to PyPI via Twine
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload --verbose -u '__token__' dist/*

@ -65,19 +65,21 @@ class DrawDallEService(commands.Cog, name="DrawDallEService"):
if not response_message: # Original generation case if not response_message: # Original generation case
# Start an interaction with the user, we also want to send data embed=embed, file=file, view=SaveView(image_urls, self, self.converser_cog) # Start an interaction with the user, we also want to send data embed=embed, file=file, view=SaveView(image_urls, self, self.converser_cog)
result_message = await ctx.channel.send( result_message = (
embed=embed, await ctx.channel.send(
file=file, embed=embed,
) if not from_context else await ctx.respond(embed=embed, file=file) file=file,
)
if not from_context
else await ctx.respond(embed=embed, file=file)
)
await result_message.edit( await result_message.edit(
view=SaveView(image_urls, self, self.converser_cog, result_message) view=SaveView(image_urls, self, self.converser_cog, result_message)
) )
self.converser_cog.users_to_interactions[user_id] = [] self.converser_cog.users_to_interactions[user_id] = []
self.converser_cog.users_to_interactions[user_id].append( self.converser_cog.users_to_interactions[user_id].append(result_message.id)
result_message.id
)
# Get the actual result message object # Get the actual result message object
if from_context: if from_context:
@ -128,8 +130,10 @@ class DrawDallEService(commands.Cog, name="DrawDallEService"):
result_message.id result_message.id
) )
@discord.slash_command(name="draw", description="Draw an image from a prompt", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
@discord.option(name = "prompt", description = "The prompt to draw from", required = True) name="draw", description="Draw an image from a prompt", guild_ids=ALLOWED_GUILDS
)
@discord.option(name="prompt", description="The prompt to draw from", required=True)
async def draw(self, ctx: discord.ApplicationContext, prompt: str): async def draw(self, ctx: discord.ApplicationContext, prompt: str):
await ctx.defer() await ctx.defer()
@ -151,7 +155,11 @@ class DrawDallEService(commands.Cog, name="DrawDallEService"):
await ctx.respond("Something went wrong. Please try again later.") await ctx.respond("Something went wrong. Please try again later.")
await ctx.send_followup(e) await ctx.send_followup(e)
@discord.slash_command(name="local-size", description="Get the size of the dall-e images folder that we have on the current system", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
name="local-size",
description="Get the size of the dall-e images folder that we have on the current system",
guild_ids=ALLOWED_GUILDS,
)
@discord.guild_only() @discord.guild_only()
async def local_size(self, ctx: discord.ApplicationContext): async def local_size(self, ctx: discord.ApplicationContext):
await ctx.defer() await ctx.defer()
@ -171,7 +179,11 @@ class DrawDallEService(commands.Cog, name="DrawDallEService"):
total_size = total_size / 1000000 total_size = total_size / 1000000
await ctx.respond(f"The size of the local images folder is {total_size} MB.") await ctx.respond(f"The size of the local images folder is {total_size} MB.")
@discord.slash_command(name="clear-local", description="Clear the local dalleimages folder on system.", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
name="clear-local",
description="Clear the local dalleimages folder on system.",
guild_ids=ALLOWED_GUILDS,
)
@discord.guild_only() @discord.guild_only()
async def clear_local(self, ctx): async def clear_local(self, ctx):
await ctx.defer() await ctx.defer()

@ -89,7 +89,6 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
return False return False
return True return True
@commands.Cog.listener() @commands.Cog.listener()
async def on_member_remove(self, member): async def on_member_remove(self, member):
pass pass
@ -101,9 +100,14 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
) )
print(f"The debug channel was acquired") print(f"The debug channel was acquired")
@discord.slash_command(
@discord.slash_command(name="set-usage", description="Set the current OpenAI usage (in dollars)") name="set-usage", description="Set the current OpenAI usage (in dollars)"
@discord.option(name="usage_amount", description="The current usage amount in dollars and cents (e.g 10.24)", type=float) )
@discord.option(
name="usage_amount",
description="The current usage amount in dollars and cents (e.g 10.24)",
type=float,
)
async def set_usage(self, ctx, usage_amount: float): async def set_usage(self, ctx, usage_amount: float):
await ctx.defer() await ctx.defer()
@ -119,7 +123,10 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
await ctx.respond("The usage value must be a valid float.") await ctx.respond("The usage value must be a valid float.")
return return
@discord.slash_command(name="delete-conversation-threads", description="Delete all conversation threads across the bot servers.") @discord.slash_command(
name="delete-conversation-threads",
description="Delete all conversation threads across the bot servers.",
)
async def delete_all_conversation_threads(self, ctx): async def delete_all_conversation_threads(self, ctx):
await ctx.defer() await ctx.defer()
# If the user has ADMIN_ROLES # If the user has ADMIN_ROLES
@ -184,10 +191,14 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
name="/chat-gpt", value="Start a conversation with GPT3", inline=False name="/chat-gpt", value="Start a conversation with GPT3", inline=False
) )
embed.add_field( embed.add_field(
name="/end-chat", value="End a conversation with GPT3. You can also type `end` in the conversation.", inline=False name="/end-chat",
value="End a conversation with GPT3. You can also type `end` in the conversation.",
inline=False,
) )
embed.add_field( embed.add_field(
name="/settings", value="Print the current settings of the model", inline=False name="/settings",
value="Print the current settings of the model",
inline=False,
) )
embed.add_field( embed.add_field(
name="/settings <model parameter> <value>", name="/settings <model parameter> <value>",
@ -410,7 +421,9 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
) )
self.conversating_users[after.author.id].count += 1 self.conversating_users[after.author.id].count += 1
await self.encapsulated_send(after.author.id, edited_content,ctx, response_message) await self.encapsulated_send(
after.author.id, edited_content, ctx, response_message
)
self.redo_users[after.author.id].prompt = after.content self.redo_users[after.author.id].prompt = after.content
@ -423,7 +436,9 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
content = message.content.strip() content = message.content.strip()
conversing = self.check_conversing(message.author.id, message.channel.id, content) conversing = self.check_conversing(
message.author.id, message.channel.id, content
)
# If the user is conversing and they want to end it, end it immediately before we continue any further. # If the user is conversing and they want to end it, end it immediately before we continue any further.
if conversing and message.content.lower() in self.END_PROMPTS: if conversing and message.content.lower() in self.END_PROMPTS:
@ -433,7 +448,7 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
# GPT3 command # GPT3 command
if conversing: if conversing:
# Extract all the text after the !g and use it as the prompt. # Extract all the text after the !g and use it as the prompt.
prompt = content # dead store but its okay :3 prompt = content # dead store but its okay :3
await self.check_conversation_limit(message) await self.check_conversation_limit(message)
@ -480,7 +495,7 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
prompt prompt
if message.author.id not in self.conversating_users if message.author.id not in self.conversating_users
else "".join(self.conversating_users[message.author.id].history), else "".join(self.conversating_users[message.author.id].history),
message message,
) )
# ctx can be of type AppContext(interaction) or Message # ctx can be of type AppContext(interaction) or Message
@ -492,7 +507,10 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
tokens = self.usage_service.count_tokens(new_prompt) tokens = self.usage_service.count_tokens(new_prompt)
# Check if the prompt is about to go past the token limit # Check if the prompt is about to go past the token limit
if user_id in self.conversating_users and tokens > self.model.summarize_threshold: if (
user_id in self.conversating_users
and tokens > self.model.summarize_threshold
):
# We don't need to worry about the differences between interactions and messages in this block, # We don't need to worry about the differences between interactions and messages in this block,
# because if we are in this block, we can only be using a message object for ctx # because if we are in this block, we can only be using a message object for ctx
@ -506,14 +524,13 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
# Check again if the prompt is about to go past the token limit # Check again if the prompt is about to go past the token limit
new_prompt = ( new_prompt = (
"".join(self.conversating_users[user_id].history) "".join(self.conversating_users[user_id].history) + "\nGPTie: "
+ "\nGPTie: "
) )
tokens = self.usage_service.count_tokens(new_prompt) tokens = self.usage_service.count_tokens(new_prompt)
if ( if (
tokens > self.model.summarize_threshold - 150 tokens > self.model.summarize_threshold - 150
): # 150 is a buffer for the second stage ): # 150 is a buffer for the second stage
await ctx.reply( await ctx.reply(
"I tried to summarize our current conversation so we could keep chatting, " "I tried to summarize our current conversation so we could keep chatting, "
@ -524,9 +541,7 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
await self.end_conversation(ctx) await self.end_conversation(ctx)
return return
else: else:
await ctx.reply( await ctx.reply("The conversation context limit has been reached.")
"The conversation context limit has been reached."
)
await self.end_conversation(ctx) await self.end_conversation(ctx)
return return
@ -541,8 +556,9 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
# If GPT3 tries to ping somebody, don't let it happen # If GPT3 tries to ping somebody, don't let it happen
if re.search(r"<@!?\d+>|<@&\d+>|<#\d+>", str(response_text)): if re.search(r"<@!?\d+>|<@&\d+>|<#\d+>", str(response_text)):
message = "I'm sorry, I can't mention users, roles, or channels." message = "I'm sorry, I can't mention users, roles, or channels."
await ctx.send_followup(message) if from_context else await ctx.reply(message) await ctx.send_followup(message) if from_context else await ctx.reply(
message
)
# If the user is conversing, add the GPT response to their conversation history. # If the user is conversing, add the GPT response to their conversation history.
if user_id in self.conversating_users: if user_id in self.conversating_users:
@ -553,44 +569,43 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
# If we don't have a response message, we are not doing a redo, send as a new message(s) # If we don't have a response message, we are not doing a redo, send as a new message(s)
if not response_message: if not response_message:
if len(response_text) > self.TEXT_CUTOFF: if len(response_text) > self.TEXT_CUTOFF:
await self.paginate_and_send( await self.paginate_and_send(response_text, ctx)
response_text, ctx
)
else: else:
response_message = \ response_message = (
await ctx.respond( await ctx.respond(
response_text, response_text,
view=RedoView(self, user_id), view=RedoView(self, user_id),
) if from_context \ )
else \ if from_context
await ctx.reply( else await ctx.reply(
response_text, response_text,
view=RedoView(self, user_id), view=RedoView(self, user_id),
)
) )
# Get the actual message object of response_message in case it's an WebhookMessage # Get the actual message object of response_message in case it's an WebhookMessage
actual_response_message = response_message if not from_context else await ctx.fetch_message(response_message.id) actual_response_message = (
response_message
if not from_context
else await ctx.fetch_message(response_message.id)
)
self.redo_users[user_id] = RedoUser( self.redo_users[user_id] = RedoUser(
prompt, ctx, ctx, actual_response_message prompt, ctx, ctx, actual_response_message
) )
self.redo_users[user_id].add_interaction( self.redo_users[user_id].add_interaction(actual_response_message.id)
actual_response_message.id
)
# We are doing a redo, edit the message. # We are doing a redo, edit the message.
else: else:
await response_message.edit( await response_message.edit(content=response_text)
content=response_text
)
await self.send_debug_message(self.generate_debug_message(prompt, response), self.debug_channel) await self.send_debug_message(
self.generate_debug_message(prompt, response), self.debug_channel
)
if user_id in self.awaiting_responses: if user_id in self.awaiting_responses:
self.awaiting_responses.remove(user_id) self.awaiting_responses.remove(user_id)
# Error catching for OpenAI model value errors # Error catching for OpenAI model value errors
except ValueError as e: except ValueError as e:
if from_context: if from_context:
@ -608,10 +623,12 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
await self.end_conversation(ctx) await self.end_conversation(ctx)
return return
@discord.slash_command(
name="g", description="Ask GPT3 something!", guild_ids=ALLOWED_GUILDS
@discord.slash_command(name="g", description="Ask GPT3 something!", guild_ids=ALLOWED_GUILDS) )
@discord.option(name="prompt", description="The prompt to send to GPT3", required=True) @discord.option(
name="prompt", description="The prompt to send to GPT3", required=True
)
@discord.guild_only() @discord.guild_only()
async def g(self, ctx: discord.ApplicationContext, prompt: str): async def g(self, ctx: discord.ApplicationContext, prompt: str):
await ctx.defer() await ctx.defer()
@ -627,14 +644,18 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
# If conversing, the prompt to send is the history, otherwise, it's just the prompt # If conversing, the prompt to send is the history, otherwise, it's just the prompt
await self.encapsulated_send( await self.encapsulated_send(
user.id, user.id,
prompt prompt
if user.id not in self.conversating_users if user.id not in self.conversating_users
else "".join(self.conversating_users[user.id].history), else "".join(self.conversating_users[user.id].history),
ctx, ctx,
) )
@discord.slash_command(name="chat-gpt", description="Have a conversation with GPT3", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
name="chat-gpt",
description="Have a conversation with GPT3",
guild_ids=ALLOWED_GUILDS,
)
@discord.guild_only() @discord.guild_only()
async def chat_gpt(self, ctx: discord.ApplicationContext): async def chat_gpt(self, ctx: discord.ApplicationContext):
await ctx.defer() await ctx.defer()
@ -654,13 +675,9 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
self.conversating_users[user.id] = User(user.id) self.conversating_users[user.id] = User(user.id)
# Append the starter text for gpt3 to the user's history so it gets concatenated with the prompt later # Append the starter text for gpt3 to the user's history so it gets concatenated with the prompt later
self.conversating_users[user.id].history.append( self.conversating_users[user.id].history.append(self.CONVERSATION_STARTER_TEXT)
self.CONVERSATION_STARTER_TEXT
)
message_thread = await ctx.respond( message_thread = await ctx.respond(user.name + "'s conversation with GPT3")
user.name + "'s conversation with GPT3"
)
# Get the actual message object for the message_thread # Get the actual message object for the message_thread
message_thread_real = await ctx.fetch_message(message_thread.id) message_thread_real = await ctx.fetch_message(message_thread.id)
thread = await message_thread_real.create_thread( thread = await message_thread_real.create_thread(
@ -675,37 +692,66 @@ class GPT3ComCon(commands.Cog, name="GPT3ComCon"):
) )
self.conversation_threads[user.id] = thread.id self.conversation_threads[user.id] = thread.id
@discord.slash_command(name="end-chat", description="End a conversation with GPT3", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
name="end-chat",
description="End a conversation with GPT3",
guild_ids=ALLOWED_GUILDS,
)
@discord.guild_only() @discord.guild_only()
async def end_chat(self, ctx: discord.ApplicationContext): async def end_chat(self, ctx: discord.ApplicationContext):
await ctx.defer() await ctx.defer()
await ctx.respond("This has not been implemented yet. Please type `end` in your conversation thread to end the chat.") await ctx.respond(
"This has not been implemented yet. Please type `end` in your conversation thread to end the chat."
)
@discord.slash_command(name="help", description="Get help for GPT3Discord", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
name="help", description="Get help for GPT3Discord", guild_ids=ALLOWED_GUILDS
)
@discord.guild_only() @discord.guild_only()
async def help(self, ctx: discord.ApplicationContext): async def help(self, ctx: discord.ApplicationContext):
await ctx.defer() await ctx.defer()
await self.send_help_text(ctx) await self.send_help_text(ctx)
@discord.slash_command(name="usage", description="Get usage statistics for GPT3Discord", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
name="usage",
description="Get usage statistics for GPT3Discord",
guild_ids=ALLOWED_GUILDS,
)
@discord.guild_only() @discord.guild_only()
async def usage(self, ctx: discord.ApplicationContext): async def usage(self, ctx: discord.ApplicationContext):
await ctx.defer() await ctx.defer()
await self.send_usage_text(ctx) await self.send_usage_text(ctx)
@discord.slash_command(name="settings", description="Get settings for GPT3Discord", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
@discord.option(name="parameter", description="The setting to change", required=False) name="settings",
@discord.option(name="value", description="The value to set the setting to", required=False) description="Get settings for GPT3Discord",
guild_ids=ALLOWED_GUILDS,
)
@discord.option(
name="parameter", description="The setting to change", required=False
)
@discord.option(
name="value", description="The value to set the setting to", required=False
)
@discord.guild_only() @discord.guild_only()
async def settings(self, ctx: discord.ApplicationContext, parameter: str = None, value: str = None): async def settings(
self, ctx: discord.ApplicationContext, parameter: str = None, value: str = None
):
await ctx.defer() await ctx.defer()
if parameter is None and value is None: if parameter is None and value is None:
await self.send_settings_text(ctx) await self.send_settings_text(ctx)
return return
# If only one of the options are set, then this is invalid. # If only one of the options are set, then this is invalid.
if parameter is None and value is not None or parameter is not None and value is None: if (
await ctx.respond("Invalid settings command. Please use `/settings <parameter> <value>` to change a setting") parameter is None
and value is not None
or parameter is not None
and value is None
):
await ctx.respond(
"Invalid settings command. Please use `/settings <parameter> <value>` to change a setting"
)
return return
# Otherwise, process the settings change # Otherwise, process the settings change

@ -9,6 +9,7 @@ from models.user_model import RedoUser
ALLOWED_GUILDS = EnvService.get_allowed_guilds() ALLOWED_GUILDS = EnvService.get_allowed_guilds()
class ImgPromptOptimizer(commands.Cog, name="ImgPromptOptimizer"): class ImgPromptOptimizer(commands.Cog, name="ImgPromptOptimizer"):
_OPTIMIZER_PRETEXT = "Optimize the following text for DALL-E image generation to have the most detailed and realistic image possible. Prompt:" _OPTIMIZER_PRETEXT = "Optimize the following text for DALL-E image generation to have the most detailed and realistic image possible. Prompt:"
@ -45,8 +46,14 @@ class ImgPromptOptimizer(commands.Cog, name="ImgPromptOptimizer"):
traceback.print_exc() traceback.print_exc()
self.OPTIMIZER_PRETEXT = self._OPTIMIZER_PRETEXT self.OPTIMIZER_PRETEXT = self._OPTIMIZER_PRETEXT
@discord.slash_command(name="imgoptimize", description="Optimize a text prompt for DALL-E/MJ/SD image generation.", guild_ids=ALLOWED_GUILDS) @discord.slash_command(
@discord.option(name="prompt", description="The text prompt to optimize.", required=True) name="imgoptimize",
description="Optimize a text prompt for DALL-E/MJ/SD image generation.",
guild_ids=ALLOWED_GUILDS,
)
@discord.option(
name="prompt", description="The text prompt to optimize.", required=True
)
@discord.guild_only() @discord.guild_only()
async def imgoptimize(self, ctx: discord.ApplicationContext, prompt: str): async def imgoptimize(self, ctx: discord.ApplicationContext, prompt: str):
await ctx.defer() await ctx.defer()
@ -74,7 +81,7 @@ class ImgPromptOptimizer(commands.Cog, name="ImgPromptOptimizer"):
temp_override=0.9, temp_override=0.9,
presence_penalty_override=0.5, presence_penalty_override=0.5,
best_of_override=1, best_of_override=1,
max_tokens_override=80 max_tokens_override=80,
) )
# THIS USES MORE TOKENS THAN A NORMAL REQUEST! This will use roughly 4000 tokens, and will repeat the query # THIS USES MORE TOKENS THAN A NORMAL REQUEST! This will use roughly 4000 tokens, and will repeat the query
@ -84,7 +91,9 @@ class ImgPromptOptimizer(commands.Cog, name="ImgPromptOptimizer"):
response_text = response["choices"][0]["text"] response_text = response["choices"][0]["text"]
if re.search(r"<@!?\d+>|<@&\d+>|<#\d+>", response_text): if re.search(r"<@!?\d+>|<@&\d+>|<#\d+>", response_text):
await ctx.respond("I'm sorry, I can't mention users, roles, or channels.") await ctx.respond(
"I'm sorry, I can't mention users, roles, or channels."
)
return return
response_message = await ctx.respond( response_message = await ctx.respond(
@ -101,9 +110,7 @@ class ImgPromptOptimizer(commands.Cog, name="ImgPromptOptimizer"):
self.converser_cog.redo_users[user.id] = RedoUser( self.converser_cog.redo_users[user.id] = RedoUser(
final_prompt, ctx, ctx, response_message final_prompt, ctx, ctx, response_message
) )
self.converser_cog.redo_users[user.id].add_interaction( self.converser_cog.redo_users[user.id].add_interaction(response_message.id)
response_message.id
)
await response_message.edit( await response_message.edit(
view=OptimizeView( view=OptimizeView(
self.converser_cog, self.image_service_cog, self.deletion_queue self.converser_cog, self.image_service_cog, self.deletion_queue
@ -176,7 +183,12 @@ class DrawButton(discord.ui.Button["OptimizeView"]):
# Call the image service cog to draw the image # Call the image service cog to draw the image
await self.image_service_cog.encapsulated_send( await self.image_service_cog.encapsulated_send(
user_id, prompt, None, msg, True, True, user_id,
prompt,
None,
msg,
True,
True,
) )

@ -1,7 +1,9 @@
from dotenv import load_dotenv from dotenv import load_dotenv
load_dotenv() load_dotenv()
import os import os
class EnvService: class EnvService:
# To be expanded upon later! # To be expanded upon later!
def __init__(self): def __init__(self):
@ -18,11 +20,15 @@ class EnvService:
allowed_guilds = None allowed_guilds = None
if allowed_guilds is None: if allowed_guilds is None:
raise ValueError("ALLOWED_GUILDS is not defined properly in the environment file!" raise ValueError(
"Please copy your server's guild ID and put it into ALLOWED_GUILDS in the .env file." "ALLOWED_GUILDS is not defined properly in the environment file!"
"For example a line should look like: `ALLOWED_GUILDS=\"971268468148166697\"`") "Please copy your server's guild ID and put it into ALLOWED_GUILDS in the .env file."
'For example a line should look like: `ALLOWED_GUILDS="971268468148166697"`'
)
allowed_guilds = allowed_guilds.split(",") if "," in allowed_guilds else [allowed_guilds] allowed_guilds = (
allowed_guilds.split(",") if "," in allowed_guilds else [allowed_guilds]
)
allowed_guilds = [int(guild) for guild in allowed_guilds] allowed_guilds = [int(guild) for guild in allowed_guilds]
return allowed_guilds return allowed_guilds
@ -37,9 +43,13 @@ class EnvService:
allowed_roles = None allowed_roles = None
if allowed_roles is None: if allowed_roles is None:
raise ValueError("ALLOWED_ROLES is not defined properly in the environment file!" raise ValueError(
"Please copy your server's role and put it into ALLOWED_ROLES in the .env file." "ALLOWED_ROLES is not defined properly in the environment file!"
"For example a line should look like: `ALLOWED_ROLES=\"Admin\"`") "Please copy your server's role and put it into ALLOWED_ROLES in the .env file."
'For example a line should look like: `ALLOWED_ROLES="Admin"`'
)
allowed_roles = allowed_roles.split(",") if "," in allowed_roles else [allowed_roles] allowed_roles = (
allowed_roles.split(",") if "," in allowed_roles else [allowed_roles]
)
return allowed_roles return allowed_roles

@ -69,7 +69,7 @@ class Model:
"custom_web_root", "custom_web_root",
"_hidden_attributes", "_hidden_attributes",
"model_max_tokens", "model_max_tokens",
"openai_key" "openai_key",
] ]
self.openai_key = os.getenv("OPENAI_TOKEN") self.openai_key = os.getenv("OPENAI_TOKEN")

Loading…
Cancel
Save