mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
renamed to chatgpt
This commit is contained in:
parent
675aa089c9
commit
c887153292
3 changed files with 5 additions and 5 deletions
|
|
@ -6,10 +6,10 @@ from typing import Optional
|
|||
from openai import OpenAI
|
||||
from openai.types.chat import ChatCompletionMessageParam
|
||||
|
||||
from infrastructure.openai.exceptions import OpenAiClientError
|
||||
from infrastructure.chatgpt.exceptions import ChatGPTClientError
|
||||
|
||||
|
||||
class OpenAiChatClient:
|
||||
class ChatGPT:
|
||||
"""Thin wrapper over the OpenAI Chat Completions API.
|
||||
|
||||
Sends a single prompt and returns the assistant's reply as plain text.
|
||||
|
|
@ -24,7 +24,7 @@ class OpenAiChatClient:
|
|||
) -> None:
|
||||
key = api_key or os.environ.get("OPENAI_API_KEY")
|
||||
if not key:
|
||||
raise OpenAiClientError(
|
||||
raise ChatGPTClientError(
|
||||
"No OpenAI API key provided. "
|
||||
"Pass api_key or set the OPENAI_API_KEY environment variable."
|
||||
)
|
||||
|
|
@ -56,5 +56,5 @@ class OpenAiChatClient:
|
|||
)
|
||||
content = response.choices[0].message.content
|
||||
if content is None:
|
||||
raise OpenAiClientError("OpenAI returned an empty response.")
|
||||
raise ChatGPTClientError("ChatGPT returned an empty response.")
|
||||
return content
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
class OpenAiClientError(Exception):
|
||||
class ChatGPTClientError(Exception):
|
||||
"""Base for all OpenAI client errors."""
|
||||
Loading…
Add table
Reference in a new issue