From f64965bda0aa0bbc4b106fa989e0675c093fb7bc Mon Sep 17 00:00:00 2001 From: Colin Wilson Date: Thu, 17 Oct 2024 14:33:16 -0400 Subject: [PATCH] Fix OpenAI token key name Rename the OpenAI API key from `openapi_token` to `openai_token` in various files. * **cogs/chat.py** - Change the key name from `openapi_token` to `openai_token` when accessing the OpenAI API key from the `config` dictionary. * **cogs/aistuff.py** - Change the key name from `openapi_token` to `openai_token` when accessing the OpenAI API key from the `config` dictionary. - Update the content of a message in the `create_title` function. * **cogs/tldr.py** - Change the key name from `openapi_token` to `openai_token` when accessing the OpenAI API key from the `config` dictionary. * **noncommands/dadroid.py** - Change the key name from `openapi_token` to `openai_token` when accessing the OpenAI API key from the `config` dictionary. * **config template.yaml** - Change the key name from `openapi_token` to `openai_token`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/Nanosplitter/DadBot?shareId=XXXX-XXXX-XXXX-XXXX). --- cogs/aistuff.py | 6 +++--- cogs/chat.py | 4 ++-- cogs/tldr.py | 2 +- config template.yaml | 2 +- noncommands/dadroid.py | 2 +- noncommands/summarizer.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cogs/aistuff.py b/cogs/aistuff.py index 51a23ab..b91c1cd 100644 --- a/cogs/aistuff.py +++ b/cogs/aistuff.py @@ -22,8 +22,8 @@ class AiStuff(commands.Cog, name="aistuff"): def __init__(self, bot): self.bot = bot - openai.api_key = config["openapi_token"] - self.client = openai.OpenAI(api_key=config["openapi_token"]) + openai.api_key = config["openai_token"] + self.client = openai.OpenAI(api_key=config["openai_token"]) @nextcord.slash_command(name="dalle", description="Create a DALL-E 3 image.") async def dalle( @@ -384,7 +384,7 @@ async def newapod( messages=[ { "role": "system", - "content": "Your goal is to take this NASA APOD description and create a title. You should only respond with 1-5 words as a title to this. Do not respond with anything else. Just the title based on the content. Please also do not include quotes around the whole title.", + "content": "Your goal is to take this NASA APOD description and create a title. You should only respond with 1-5 words as a title to this. Do not respond with anything more than the title.", }, { "role": "user", diff --git a/cogs/chat.py b/cogs/chat.py index d8d58ac..ccc7c92 100644 --- a/cogs/chat.py +++ b/cogs/chat.py @@ -20,8 +20,8 @@ class Chat(commands.Cog, name="chat"): def __init__(self, bot): self.bot = bot - openai.api_key = config["openapi_token"] - self.client = openai.OpenAI(api_key=config["openapi_token"]) + openai.api_key = config["openai_token"] + self.client = openai.OpenAI(api_key=config["openai_token"]) @nextcord.slash_command(name="chat", description="Chat with Dad") async def chat( diff --git a/cogs/tldr.py b/cogs/tldr.py index b9306db..a7b34cf 100644 --- a/cogs/tldr.py +++ b/cogs/tldr.py @@ -18,7 +18,7 @@ class TLDR(commands.Cog, name="tldr"): def __init__(self, bot): self.bot = bot - self.client = openai.OpenAI(api_key=config["openapi_token"]) + self.client = openai.OpenAI(api_key=config["openai_token"]) @nextcord.slash_command( name="tldrchannel", diff --git a/config template.yaml b/config template.yaml index 49037be..3d7b147 100644 --- a/config template.yaml +++ b/config template.yaml @@ -17,4 +17,4 @@ info: 0x4299F5 maps_api_key: "MAPS_API_KEY" imgflip_pass: "IMGFLIP_PASSWORD" pipeline_token: "PIPELINE_TOKEN" -openapi_token: "OPENAPI_TOKEN" \ No newline at end of file +openai_token: "OPENAPI_TOKEN" diff --git a/noncommands/dadroid.py b/noncommands/dadroid.py index f98b479..14b88d5 100644 --- a/noncommands/dadroid.py +++ b/noncommands/dadroid.py @@ -80,7 +80,7 @@ def create_chat_completion( ) -> dict: """Creates a chat completion using OpenAI's API.""" - client = OpenAI(api_key=config["openapi_token"]) + client = OpenAI(api_key=config["openai_token"]) if beef: model = "gpt-4o-mini" diff --git a/noncommands/summarizer.py b/noncommands/summarizer.py index 67c3e8c..f9d8597 100644 --- a/noncommands/summarizer.py +++ b/noncommands/summarizer.py @@ -149,4 +149,4 @@ def getSummaryText(config, text): inline = False ) - return embed \ No newline at end of file + return embed