diff --git a/chatmastermind/ais/openai.py b/chatmastermind/ais/openai.py index e3ce5a6..7e28032 100644 --- a/chatmastermind/ais/openai.py +++ b/chatmastermind/ais/openai.py @@ -68,6 +68,7 @@ class OpenAI(AI): self.ID = config.ID self.name = config.name self.config = config + openai.api_key = self.config.api_key def request(self, question: Message, @@ -80,7 +81,6 @@ class OpenAI(AI): nr. of messages in the 'AIResponse'. """ self.encoding = tiktoken.encoding_for_model(self.config.model) - openai.api_key = self.config.api_key oai_chat, prompt_tokens = self.openai_chat(chat, self.config.system, question) tokens: Tokens = Tokens(prompt_tokens, 0, prompt_tokens) response = openai.ChatCompletion.create(