Skip to content

Commit

Permalink
unpin OpenAI and fix problem with mock (#7364)
Browse files Browse the repository at this point in the history
  • Loading branch information
anakin87 committed Mar 15, 2024
1 parent 2aae847 commit abda78c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dependencies = [
"tqdm",
"tenacity",
"lazy-imports",
"openai==1.13.3", # unpin after fix for https://github.com/deepset-ai/haystack/issues/7358
"openai>=1.1.0",
"Jinja2",
"posthog", # telemetry
"pyyaml",
Expand Down
9 changes: 5 additions & 4 deletions test/components/generators/conftest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from datetime import datetime
from typing import Iterator
from unittest.mock import patch, MagicMock
from unittest.mock import MagicMock, patch

import pytest
from openai import Stream
from openai.types.chat import ChatCompletionChunk
from openai.types.chat.chat_completion_chunk import ChoiceDelta, Choice
from openai.types.chat.chat_completion_chunk import Choice, ChoiceDelta


@pytest.fixture
Expand Down Expand Up @@ -33,8 +33,9 @@ def mock_chat_completion_chunk():
"""

class MockStream(Stream[ChatCompletionChunk]):
def __init__(self, mock_chunk: ChatCompletionChunk, *args, **kwargs):
super().__init__(*args, **kwargs)
def __init__(self, mock_chunk: ChatCompletionChunk, client=None, *args, **kwargs):
client = client or MagicMock()
super().__init__(client=client, *args, **kwargs)
self.mock_chunk = mock_chunk

def __stream__(self) -> Iterator[ChatCompletionChunk]:
Expand Down

0 comments on commit abda78c

Please sign in to comment.