diff --git a/poetry.lock b/poetry.lock index 2121280c9efed195fb7b22e3cbd839ef7ff5c2d2..42adb1617152c1dd105f9f721f38b49fd733c64c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -246,12 +246,10 @@ files = [ [package.dependencies] click = ">=8.0.0" -ipython = {version = ">=7.8.0", optional = true, markers = "extra == \"jupyter\""} mypy-extensions = ">=0.4.3" packaging = ">=22.0" pathspec = ">=0.9.0" platformdirs = ">=2" -tokenize-rt = {version = ">=3.2.0", optional = true, markers = "extra == \"jupyter\""} tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} typing-extensions = {version = ">=4.0.1", markers = "python_version < \"3.11\""} @@ -2375,7 +2373,6 @@ files = [ {file = "PyYAML-6.0.1-cp311-cp311-win_amd64.whl", hash = "sha256:bf07ee2fef7014951eeb99f56f39c9bb4af143d8aa3c21b1677805985307da34"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:855fb52b0dc35af121542a76b9a84f8d1cd886ea97c84703eaa6d88e37a2ad28"}, {file = "PyYAML-6.0.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:40df9b996c2b73138957fe23a16a4f0ba614f4c0efce1e9406a184b6d07fa3a9"}, - {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a08c6f0fe150303c1c6b71ebcd7213c2858041a7e01975da3a99aed1e7a378ef"}, {file = "PyYAML-6.0.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:6c22bec3fbe2524cde73d7ada88f6566758a8f7227bfbf93a408a9d86bcc12a0"}, {file = "PyYAML-6.0.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:8d4e9c88387b0f5c7d5f281e55304de64cf7f9c0021a3525bd3b1c542da3b0e4"}, {file = "PyYAML-6.0.1-cp312-cp312-win32.whl", hash = "sha256:d483d2cdf104e7c9fa60c544d92981f12ad66a457afae824d146093b8c294c54"}, @@ -2838,17 +2835,6 @@ files = [ [package.dependencies] mpmath = ">=0.19" -[[package]] -name = "tokenize-rt" -version = "5.2.0" -description = "A wrapper around the stdlib `tokenize` which roundtrips." -optional = false -python-versions = ">=3.8" -files = [ - {file = "tokenize_rt-5.2.0-py2.py3-none-any.whl", hash = "sha256:b79d41a65cfec71285433511b50271b05da3584a1da144a0752e9c621a285289"}, - {file = "tokenize_rt-5.2.0.tar.gz", hash = "sha256:9fe80f8a5c1edad2d3ede0f37481cc0cc1538a2f442c9c2f9e4feacd2792d054"}, -] - [[package]] name = "tokenizers" version = "0.15.0" @@ -3375,4 +3361,4 @@ local = ["llama-cpp-python", "torch", "transformers"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "6e658c338fd236a82fd0a9f03a64393b2bd728802e069b0663a5ff786bd203dc" +content-hash = "20a39eaeaa617613fd7e13038ac4a206cc23e6faf9d5e077bf035bc3243bb5e7" diff --git a/pyproject.toml b/pyproject.toml index b8785a74a94e17e432816e3c4398bfbdc4f9428c..7d2ed027657be97497ea020b2d12d8e7a318a267 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -37,7 +37,6 @@ local = ["torch", "transformers", "llama-cpp-python"] [tool.poetry.group.dev.dependencies] ipykernel = "^6.25.0" ruff = "^0.1.5" -black = {extras = ["jupyter"], version = "^23.12.0"} pytest = "^7.4.3" pytest-mock = "^3.12.0" pytest-cov = "^4.1.0" diff --git a/tests/unit/llms/test_llm_azure_openai.py b/tests/unit/llms/test_llm_azure_openai.py index a8af7f15d2e667a5596872f85768bdb34e3df022..a50b08fb85eca26719da69db41b065d4ceef9e86 100644 --- a/tests/unit/llms/test_llm_azure_openai.py +++ b/tests/unit/llms/test_llm_azure_openai.py @@ -13,7 +13,9 @@ def azure_openai_llm(mocker): class TestOpenAILLM: def test_azure_openai_llm_init_with_api_key(self, azure_openai_llm): assert azure_openai_llm.client is not None, "Client should be initialized" - assert azure_openai_llm.name == "gpt-3.5-turbo", "Default name not set correctly" + assert ( + azure_openai_llm.name == "gpt-3.5-turbo" + ), "Default name not set correctly" def test_azure_openai_llm_init_success(self, mocker): mocker.patch("os.getenv", return_value="fake-api-key") @@ -26,18 +28,22 @@ class TestOpenAILLM: AzureOpenAILLM() # def test_azure_openai_llm_init_without_azure_endpoint(self, mocker): - # mocker.patch("os.getenv", side_effect=[None, "fake-api-key"]) + # mocker.patch("os.getenv", side_effect=[None, "fake-api-key"]) # with pytest.raises(ValueError) as e: # AzureOpenAILLM(openai_api_key="test_api_key") # assert "Azure endpoint API key cannot be 'None'." in str(e.value) def test_azure_openai_llm_init_without_azure_endpoint(self, mocker): - mocker.patch("os.getenv", side_effect=lambda key, default=None: {"OPENAI_CHAT_MODEL_NAME": "test-model-name"}.get(key, default)) + mocker.patch( + "os.getenv", + side_effect=lambda key, default=None: { + "OPENAI_CHAT_MODEL_NAME": "test-model-name" + }.get(key, default), + ) with pytest.raises(ValueError) as e: AzureOpenAILLM(openai_api_key="test_api_key") assert "Azure endpoint API key cannot be 'None'" in str(e.value) - def test_azure_openai_llm_call_uninitialized_client(self, azure_openai_llm): # Set the client to None to simulate an uninitialized client azure_openai_llm.client = None @@ -48,20 +54,29 @@ class TestOpenAILLM: def test_azure_openai_llm_init_exception(self, mocker): mocker.patch("os.getenv", return_value="fake-api-key") - mocker.patch("openai.AzureOpenAI", side_effect=Exception("Initialization error")) + mocker.patch( + "openai.AzureOpenAI", side_effect=Exception("Initialization error") + ) with pytest.raises(ValueError) as e: AzureOpenAILLM() assert ( "AzureOpenAI API client failed to initialize. Error: Initialization error" in str(e.value) ) - + def test_azure_openai_llm_temperature_max_tokens_initialization(self): test_temperature = 0.5 test_max_tokens = 100 - azure_llm = AzureOpenAILLM(openai_api_key="test_api_key",azure_endpoint="test_endpoint", temperature=test_temperature, max_tokens=test_max_tokens) + azure_llm = AzureOpenAILLM( + openai_api_key="test_api_key", + azure_endpoint="test_endpoint", + temperature=test_temperature, + max_tokens=test_max_tokens, + ) - assert azure_llm.temperature == test_temperature, "Temperature not set correctly" + assert ( + azure_llm.temperature == test_temperature + ), "Temperature not set correctly" assert azure_llm.max_tokens == test_max_tokens, "Max tokens not set correctly" def test_azure_openai_llm_call_success(self, azure_openai_llm, mocker): @@ -70,7 +85,9 @@ class TestOpenAILLM: mocker.patch("os.getenv", return_value="fake-api-key") mocker.patch.object( - azure_openai_llm.client.chat.completions, "create", return_value=mock_completion + azure_openai_llm.client.chat.completions, + "create", + return_value=mock_completion, ) llm_input = [Message(role="user", content="test")] output = azure_openai_llm(llm_input)