diff --git a/.markdownlint.json b/.markdownlint.json new file mode 100644 index 0000000..cb84254 --- /dev/null +++ b/.markdownlint.json @@ -0,0 +1,4 @@ +{ + "MD013": false, + "MD033": false +} \ No newline at end of file diff --git a/README.md b/README.md index 4857823..0ebeecc 100644 --- a/README.md +++ b/README.md @@ -1,26 +1,40 @@ -# AI DIAL Client (Python) +

+ DIAL Client SDK +

+

+

+ + About DIALX + +

+

+ + Discord + +

+ +- [AI DIAL Client (Python)](#ai-dial-client-python) + - [Authentication](#authentication) + - [API Keys](#api-keys) + - [Bearer Token](#bearer-token) + - [List Deployments](#list-deployments) + - [Make Completions Requests](#make-completions-requests) + - [Without Streaming](#without-streaming) + - [With Streaming](#with-streaming) + - [Working with Files](#working-with-files) + - [Working with URLs](#working-with-urls) + - [Uploading Files](#uploading-files) + - [Downloading Files](#downloading-files) + - [Deleting Files](#deleting-files) + - [Accessing Metadata](#accessing-metadata) + - [Applications](#applications) + - [List Applications](#list-applications) + - [Get Application by Id](#get-application-by-id) + - [Client Pool](#client-pool) + - [Synchronous Client Pool](#synchronous-client-pool) + - [Asynchronous Client Pool](#asynchronous-client-pool) -## Table of Contents - -- [Authentication](#authentication) - - [API Keys](#api-keys) - - [Bearer Token](#bearer-token) -- [List Deployments](#list-deployments) -- [Make Chat Completions Requests](#make-completions-requests) - - [Without Streaming](#without-streaming) - - [With Streaming](#with-streaming) -- [Working with Files](#working-with-files) - - [Working with URLs](#working-with-urls) - - [Uploading Files](#uploading-files) - - [Downloading Files](#downloading-files) - - [Deleting Files](#deleting-files) - - [Accessing Metadata](#accessing-metadata) -- [Applications](#applications) - - [List Applications](#list-applications) - - [Get Application by Id](#get-application-by-id) -- [Client Pool](#client-pool) - - [Synchronous Client Pool](#synchronous-client-pool) - - [Asynchronous Client Pool](#asynchronous-client-pool) +# AI DIAL Client (Python) ## Authentication @@ -139,7 +153,7 @@ Synchronous: client = Dial(api_key="your-api-key", base_url="https://your-dial-instance.com") completion = client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name="gpt-4o", stream=False, messages=[ { @@ -159,7 +173,7 @@ async_client = AsyncDial( api_key="your-api-key", base_url="https://your-dial-instance.com" ) completion = await async_client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name="gpt-4o", stream=False, messages=[ { @@ -212,7 +226,7 @@ Synchronous: client = Dial(api_key="your-api-key", base_url="https://your-dial-instance.com") completion = client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name="gpt-4o", # Specify a stream parameter stream=True, messages=[ @@ -235,7 +249,7 @@ async_client = AsyncDial( api_key="your-api-key", base_url="https://your-dial-instance.com" ) completion = await async_client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name="gpt-4o", # Specify a stream parameter stream=True, messages=[ diff --git a/tests/integration/configuration.py b/tests/integration/configuration.py new file mode 100644 index 0000000..d9b333c --- /dev/null +++ b/tests/integration/configuration.py @@ -0,0 +1,5 @@ +import os + +INTEGRATION_TEST_DEPLOYMENT_NAME = os.getenv( + "INTEGRATION_TEST_DEPLOYMENT_NAME", "gpt-4o" +) diff --git a/tests/integration/fixtures.py b/tests/integration/fixtures.py index 7927dd6..1b772ef 100644 --- a/tests/integration/fixtures.py +++ b/tests/integration/fixtures.py @@ -35,7 +35,7 @@ def async_client(dial_url, dial_api_key): def test_deployment(sync_client: Dial) -> str: deployments = sync_client.deployments.list() assert len(deployments) - deployment = next((d for d in deployments if d.id.startswith("gpt-"))) + deployment = next((d for d in deployments if d.id.startswith("gpt-4o"))) assert deployment return deployment.id diff --git a/tests/integration/test_async_completions.py b/tests/integration/test_async_completions.py index 6246877..d9e1c90 100644 --- a/tests/integration/test_async_completions.py +++ b/tests/integration/test_async_completions.py @@ -2,6 +2,7 @@ from aidial_client import AsyncDial from aidial_client._exception import DialException +from tests.integration.configuration import INTEGRATION_TEST_DEPLOYMENT_NAME from tests.integration.fixtures import * # noqa @@ -14,7 +15,7 @@ async def test_async_default_api_version( ): with pytest.raises(DialException): await async_client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name=INTEGRATION_TEST_DEPLOYMENT_NAME, stream=False, messages=[ { diff --git a/tests/integration/test_sync_completions.py b/tests/integration/test_sync_completions.py index a35b61c..7a95061 100644 --- a/tests/integration/test_sync_completions.py +++ b/tests/integration/test_sync_completions.py @@ -2,6 +2,7 @@ from aidial_client import Dial from aidial_client._exception import DialException +from tests.integration.configuration import INTEGRATION_TEST_DEPLOYMENT_NAME from tests.integration.fixtures import * # type: ignore # noqa @@ -36,7 +37,7 @@ def test_default_api_version( ): with pytest.raises(DialException): sync_client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name=INTEGRATION_TEST_DEPLOYMENT_NAME, stream=False, messages=[ { @@ -51,7 +52,7 @@ def test_default_api_version( api_version="2024-02-15-preview", ) client_with_default_api_version.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name=INTEGRATION_TEST_DEPLOYMENT_NAME, stream=False, messages=[ { diff --git a/tests/resources/completions/test_completions_streaming_tool_call.py b/tests/resources/completions/test_completions_streaming_tool_call.py index a5b6cfb..21f77d6 100644 --- a/tests/resources/completions/test_completions_streaming_tool_call.py +++ b/tests/resources/completions/test_completions_streaming_tool_call.py @@ -5,6 +5,7 @@ from aidial_client.types.chat import ChatCompletionChunk, ToolParam from tests.client_mock import get_async_client_mock, get_client_mock +from tests.integration.configuration import INTEGRATION_TEST_DEPLOYMENT_NAME from tests.utils.chunks import create_mock_chunk, create_sse_data_field _TOOL_DEFINITION: ToolParam = { @@ -172,7 +173,7 @@ def test_sync_streaming_tool_call(): ) response = client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name=INTEGRATION_TEST_DEPLOYMENT_NAME, messages=[{"role": "user", "content": "what's the weather in Paris?"}], tools=[_TOOL_DEFINITION], stream=True, @@ -190,7 +191,7 @@ async def test_async_streaming_tool_call(): stream_chunks_mock=_STREAM_CHUNKS_MOCK, ) response = await async_client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name=INTEGRATION_TEST_DEPLOYMENT_NAME, messages=[{"role": "user", "content": "what's the weather in Paris?"}], tools=[_TOOL_DEFINITION], stream=True, diff --git a/tests/resources/completions/test_completions_streaming_vanilla.py b/tests/resources/completions/test_completions_streaming_vanilla.py index dcb8492..341b862 100644 --- a/tests/resources/completions/test_completions_streaming_vanilla.py +++ b/tests/resources/completions/test_completions_streaming_vanilla.py @@ -5,6 +5,7 @@ from aidial_client.types.chat import ChatCompletionChunk from tests.client_mock import get_async_client_mock, get_client_mock +from tests.integration.configuration import INTEGRATION_TEST_DEPLOYMENT_NAME from tests.utils.chunks import create_mock_chunk, create_sse_data_field STREAM_CHUNKS_MOCK: List[bytes] = [ @@ -53,7 +54,7 @@ def test_sync_streaming(): ) response = client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name=INTEGRATION_TEST_DEPLOYMENT_NAME, messages=[{"role": "user", "content": "2+3="}], stream=True, ) @@ -70,7 +71,7 @@ async def test_async_streaming(): stream_chunks_mock=STREAM_CHUNKS_MOCK, ) response = await async_client.chat.completions.create( - deployment_name="gpt-35-turbo", + deployment_name=INTEGRATION_TEST_DEPLOYMENT_NAME, messages=[{"role": "user", "content": "2+3="}], stream=True, ) diff --git a/tests/utils/chunks.py b/tests/utils/chunks.py index eee4ca9..29d9d0f 100644 --- a/tests/utils/chunks.py +++ b/tests/utils/chunks.py @@ -1,6 +1,8 @@ import json from typing import Optional, Union +from tests.integration.configuration import INTEGRATION_TEST_DEPLOYMENT_NAME + def create_mock_chunk( *, @@ -19,7 +21,7 @@ def create_mock_chunk( } ], "created": 1723806872, - "model": "gpt-35-turbo", + "model": INTEGRATION_TEST_DEPLOYMENT_NAME, "object": "chat.completion.chunk", "system_fingerprint": None, **({} if usage is None else {"usage": usage}),