Skip to content

Commit

Permalink
Merge pull request #770 from PrefectHQ/openai-client
Browse files Browse the repository at this point in the history
Fix issue with openai class moving
  • Loading branch information
zzstoatzz authored Jan 17, 2024
2 parents 53aa04a + 9983180 commit 473b7fe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/marvin/ai/audio.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from functools import partial, wraps
from typing import Any, Callable, Literal, Optional, TypeVar

from openai._base_client import HttpxBinaryResponseContent

import marvin
from marvin.client.openai import MarvinClient
from marvin.types import SpeechRequest
from marvin.types import HttpxBinaryResponseContent, SpeechRequest
from marvin.utilities.jinja import Environment
from marvin.utilities.logging import get_logger
from marvin.utilities.python import PythonFunction
Expand Down
2 changes: 1 addition & 1 deletion src/marvin/client/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
)
from marvin.types import (
ChatRequest,
HttpxBinaryResponseContent,
ImageRequest,
StreamingChatResponse,
VisionRequest,
)
from marvin.utilities.logging import get_logger

if TYPE_CHECKING:
from openai._base_client import HttpxBinaryResponseContent
from openai.types import ImagesResponse


Expand Down
9 changes: 9 additions & 0 deletions src/marvin/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@

T = TypeVar("T", bound=BaseModel)

# OpenAI client 1.8 moved the HttpxBinaryResponseContent class to a different
# module, presumably this will continue to change in the future
try:
# >= 1.8
from openai._legacy_response import HttpxBinaryResponseContent # noqa F401
except ImportError:
# < 1.8
from openai._base_client import HttpxBinaryResponseContent # noqa F401


class ResponseFormat(BaseModel):
type: str
Expand Down

0 comments on commit 473b7fe

Please sign in to comment.