Skip to content

Commit

Permalink
chore: Remove deprecated GPTGenerator and GPTChatGenerator (#7125)
Browse files Browse the repository at this point in the history
* remove deprecated GPTGenerator and GPTChatGenerator

* remove unused import
  • Loading branch information
julian-risch authored Feb 26, 2024
1 parent ba49905 commit 22e9def
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 66 deletions.
10 changes: 2 additions & 8 deletions haystack/components/generators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
from haystack.components.generators.hugging_face_local import HuggingFaceLocalGenerator
from haystack.components.generators.hugging_face_tgi import HuggingFaceTGIGenerator
from haystack.components.generators.openai import OpenAIGenerator, GPTGenerator
from haystack.components.generators.openai import OpenAIGenerator
from haystack.components.generators.azure import AzureOpenAIGenerator

__all__ = [
"HuggingFaceLocalGenerator",
"HuggingFaceTGIGenerator",
"OpenAIGenerator",
"GPTGenerator",
"AzureOpenAIGenerator",
]
__all__ = ["HuggingFaceLocalGenerator", "HuggingFaceTGIGenerator", "OpenAIGenerator", "AzureOpenAIGenerator"]
3 changes: 1 addition & 2 deletions haystack/components/generators/chat/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from haystack.components.generators.chat.hugging_face_local import HuggingFaceLocalChatGenerator
from haystack.components.generators.chat.hugging_face_tgi import HuggingFaceTGIChatGenerator
from haystack.components.generators.chat.openai import OpenAIChatGenerator, GPTChatGenerator
from haystack.components.generators.chat.openai import OpenAIChatGenerator
from haystack.components.generators.chat.azure import AzureOpenAIChatGenerator


__all__ = [
"HuggingFaceLocalChatGenerator",
"HuggingFaceTGIChatGenerator",
"OpenAIChatGenerator",
"GPTChatGenerator",
"AzureOpenAIChatGenerator",
]
27 changes: 0 additions & 27 deletions haystack/components/generators/chat/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import dataclasses
import json
import logging
import warnings
from typing import Optional, List, Callable, Dict, Any, Union

from openai import OpenAI, Stream # type: ignore
Expand Down Expand Up @@ -331,29 +330,3 @@ def _check_finish_reason(self, message: ChatMessage) -> None:
logger.warning(
"The completion for index %s has been truncated due to the content filter.", message.meta["index"]
)


class GPTChatGenerator(OpenAIChatGenerator):
def __init__(
self,
api_key: Secret = Secret.from_env_var("OPENAI_API_KEY"),
model: str = "gpt-3.5-turbo",
streaming_callback: Optional[Callable[[StreamingChunk], None]] = None,
api_base_url: Optional[str] = None,
organization: Optional[str] = None,
generation_kwargs: Optional[Dict[str, Any]] = None,
):
warnings.warn(
"GPTChatGenerator is deprecated and will be removed in the next beta release. "
"Please use OpenAIChatGenerator instead.",
UserWarning,
stacklevel=2,
)
super().__init__(
api_key=api_key,
model=model,
streaming_callback=streaming_callback,
api_base_url=api_base_url,
organization=organization,
generation_kwargs=generation_kwargs,
)
29 changes: 0 additions & 29 deletions haystack/components/generators/openai.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import dataclasses
import logging
import warnings
from typing import Optional, List, Callable, Dict, Any, Union

from openai import OpenAI, Stream
Expand Down Expand Up @@ -277,31 +276,3 @@ def _check_finish_reason(self, message: ChatMessage) -> None:
logger.warning(
"The completion for index %s has been truncated due to the content filter.", message.meta["index"]
)


class GPTGenerator(OpenAIGenerator):
def __init__(
self,
api_key: Secret = Secret.from_env_var("OPENAI_API_KEY"),
model: str = "gpt-3.5-turbo",
streaming_callback: Optional[Callable[[StreamingChunk], None]] = None,
api_base_url: Optional[str] = None,
organization: Optional[str] = None,
system_prompt: Optional[str] = None,
generation_kwargs: Optional[Dict[str, Any]] = None,
):
warnings.warn(
"GPTGenerator is deprecated and will be removed in the next beta release. "
"Please use OpenAIGenerator instead.",
UserWarning,
stacklevel=2,
)
super().__init__(
api_key=api_key,
model=model,
streaming_callback=streaming_callback,
api_base_url=api_base_url,
organization=organization,
system_prompt=system_prompt,
generation_kwargs=generation_kwargs,
)
4 changes: 4 additions & 0 deletions releasenotes/notes/remove-gptgenerator-8eced280d3b720d3.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
upgrade:
- |
Removed the deprecated GPTGenerator and GPTChatGenerator components. Use OpenAIGenerator and OpenAIChatGeneratornotes instead.

0 comments on commit 22e9def

Please sign in to comment.