Skip to content

Commit c9902bd

Browse files
committed
Make OpenAI query clients to init openai_api_key
1 parent 6ac037f commit c9902bd

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

aishell/query_clients/gpt3_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
class GPT3Client(QueryClient):
1313

14+
def __init__(
15+
self,
16+
openai_api_key: str,
17+
):
18+
openai.api_key = openai_api_key
19+
1420
def query(self, prompt: str) -> str:
1521
prompt = self._construct_prompt(prompt)
1622
completion: Final[OpenAIResponseModel] = cast(

aishell/query_clients/official_chatgpt_client.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ class OfficialChatGPTClient(QueryClient):
1313

1414
def __init__(
1515
self,
16-
openai_api_key: Optional[str] = None,
16+
openai_api_key: str,
1717
):
18-
super().__init__()
1918
OPENAI_API_KEY: Optional[str] = os.environ.get('OPENAI_API_KEY', openai_api_key)
2019
if OPENAI_API_KEY is None:
2120
raise UnauthorizedAccessError('OPENAI_API_KEY should not be none')

0 commit comments

Comments
 (0)