diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4208b5cb..1b77f506 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.6.0" + ".": "0.7.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index c6e434cd..d4c15816 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 48 +configured_endpoints: 49 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/mixedbread%2Fmixedbread-a331b701867ba3d3dd907c8389fde663be4fda24c91e23f54f4dde8a6ade683f.yml openapi_spec_hash: 95587d9746abb97d5b294bfedf86b782 -config_hash: 8545159b6ba2d638b8a2e7bbed6f04e7 +config_hash: ca0dfb431a44ea42464c42b224addf36 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a341037..cb86c84a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,18 @@ # Changelog +## 0.7.0 (2025-06-16) + +Full Changelog: [v0.6.0...v0.7.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.6.0...v0.7.0) + +### Features + +* **api:** update via SDK Studio ([6859024](https://github.com/mixedbread-ai/mixedbread-python/commit/6859024cb7bd569462d50c83e84ca8864cd4fb23)) + + +### Chores + +* update the vs identifiers ([319e732](https://github.com/mixedbread-ai/mixedbread-python/commit/319e732d66ce6f793fb7ddd783d2fc61c4277801)) + ## 0.6.0 (2025-06-13) Full Changelog: [v0.5.0...v0.6.0](https://github.com/mixedbread-ai/mixedbread-python/compare/v0.5.0...v0.6.0) diff --git a/api.md b/api.md index 0008e67f..20463369 100644 --- a/api.md +++ b/api.md @@ -59,7 +59,9 @@ Types: ```python from mixedbread.types.vector_stores import ( + RerankConfig, ScoredVectorStoreFile, + VectorStoreFileStatus, VectorStoreFile, FileDeleteResponse, FileSearchResponse, @@ -179,6 +181,9 @@ from mixedbread.types import ( DataSource, DataSourceOauth2Params, DataSourceType, + LinearDataSource, + NotionDataSource, + Oauth2Params, DataSourceDeleteResponse, ) ``` @@ -223,3 +228,9 @@ Methods: - client.api_keys.delete(api_key_id) -> APIKeyDeleteResponse - client.api_keys.reroll(api_key_id) -> APIKeyCreated - client.api_keys.revoke(api_key_id) -> APIKey + +# Chat + +Methods: + +- client.chat.create_completion() -> object diff --git a/pyproject.toml b/pyproject.toml index 6de28979..a2c8b86e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "mixedbread" -version = "0.6.0" +version = "0.7.0" description = "The official Python library for the Mixedbread API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/mixedbread/_client.py b/src/mixedbread/_client.py index f75adc2f..bd402d87 100644 --- a/src/mixedbread/_client.py +++ b/src/mixedbread/_client.py @@ -36,7 +36,7 @@ async_to_raw_response_wrapper, async_to_streamed_response_wrapper, ) -from .resources import files, api_keys, embeddings +from .resources import chat, files, api_keys, embeddings from ._streaming import Stream as Stream, AsyncStream as AsyncStream from ._exceptions import APIStatusError, MixedbreadError from ._base_client import ( @@ -80,6 +80,7 @@ class Mixedbread(SyncAPIClient): embeddings: embeddings.EmbeddingsResource data_sources: data_sources.DataSourcesResource api_keys: api_keys.APIKeysResource + chat: chat.ChatResource with_raw_response: MixedbreadWithRawResponse with_streaming_response: MixedbreadWithStreamedResponse @@ -168,6 +169,7 @@ def __init__( self.embeddings = embeddings.EmbeddingsResource(self) self.data_sources = data_sources.DataSourcesResource(self) self.api_keys = api_keys.APIKeysResource(self) + self.chat = chat.ChatResource(self) self.with_raw_response = MixedbreadWithRawResponse(self) self.with_streaming_response = MixedbreadWithStreamedResponse(self) @@ -441,6 +443,7 @@ class AsyncMixedbread(AsyncAPIClient): embeddings: embeddings.AsyncEmbeddingsResource data_sources: data_sources.AsyncDataSourcesResource api_keys: api_keys.AsyncAPIKeysResource + chat: chat.AsyncChatResource with_raw_response: AsyncMixedbreadWithRawResponse with_streaming_response: AsyncMixedbreadWithStreamedResponse @@ -529,6 +532,7 @@ def __init__( self.embeddings = embeddings.AsyncEmbeddingsResource(self) self.data_sources = data_sources.AsyncDataSourcesResource(self) self.api_keys = api_keys.AsyncAPIKeysResource(self) + self.chat = chat.AsyncChatResource(self) self.with_raw_response = AsyncMixedbreadWithRawResponse(self) self.with_streaming_response = AsyncMixedbreadWithStreamedResponse(self) @@ -803,6 +807,7 @@ def __init__(self, client: Mixedbread) -> None: self.embeddings = embeddings.EmbeddingsResourceWithRawResponse(client.embeddings) self.data_sources = data_sources.DataSourcesResourceWithRawResponse(client.data_sources) self.api_keys = api_keys.APIKeysResourceWithRawResponse(client.api_keys) + self.chat = chat.ChatResourceWithRawResponse(client.chat) self.embed = to_raw_response_wrapper( client.embed, @@ -824,6 +829,7 @@ def __init__(self, client: AsyncMixedbread) -> None: self.embeddings = embeddings.AsyncEmbeddingsResourceWithRawResponse(client.embeddings) self.data_sources = data_sources.AsyncDataSourcesResourceWithRawResponse(client.data_sources) self.api_keys = api_keys.AsyncAPIKeysResourceWithRawResponse(client.api_keys) + self.chat = chat.AsyncChatResourceWithRawResponse(client.chat) self.embed = async_to_raw_response_wrapper( client.embed, @@ -845,6 +851,7 @@ def __init__(self, client: Mixedbread) -> None: self.embeddings = embeddings.EmbeddingsResourceWithStreamingResponse(client.embeddings) self.data_sources = data_sources.DataSourcesResourceWithStreamingResponse(client.data_sources) self.api_keys = api_keys.APIKeysResourceWithStreamingResponse(client.api_keys) + self.chat = chat.ChatResourceWithStreamingResponse(client.chat) self.embed = to_streamed_response_wrapper( client.embed, @@ -866,6 +873,7 @@ def __init__(self, client: AsyncMixedbread) -> None: self.embeddings = embeddings.AsyncEmbeddingsResourceWithStreamingResponse(client.embeddings) self.data_sources = data_sources.AsyncDataSourcesResourceWithStreamingResponse(client.data_sources) self.api_keys = api_keys.AsyncAPIKeysResourceWithStreamingResponse(client.api_keys) + self.chat = chat.AsyncChatResourceWithStreamingResponse(client.chat) self.embed = async_to_streamed_response_wrapper( client.embed, diff --git a/src/mixedbread/_version.py b/src/mixedbread/_version.py index 6060c6be..d3e3c3b6 100644 --- a/src/mixedbread/_version.py +++ b/src/mixedbread/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "mixedbread" -__version__ = "0.6.0" # x-release-please-version +__version__ = "0.7.0" # x-release-please-version diff --git a/src/mixedbread/resources/__init__.py b/src/mixedbread/resources/__init__.py index 284cc1cb..0b3e0954 100644 --- a/src/mixedbread/resources/__init__.py +++ b/src/mixedbread/resources/__init__.py @@ -1,5 +1,13 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +from .chat import ( + ChatResource, + AsyncChatResource, + ChatResourceWithRawResponse, + AsyncChatResourceWithRawResponse, + ChatResourceWithStreamingResponse, + AsyncChatResourceWithStreamingResponse, +) from .files import ( FilesResource, AsyncFilesResource, @@ -100,4 +108,10 @@ "AsyncAPIKeysResourceWithRawResponse", "APIKeysResourceWithStreamingResponse", "AsyncAPIKeysResourceWithStreamingResponse", + "ChatResource", + "AsyncChatResource", + "ChatResourceWithRawResponse", + "AsyncChatResourceWithRawResponse", + "ChatResourceWithStreamingResponse", + "AsyncChatResourceWithStreamingResponse", ] diff --git a/src/mixedbread/resources/chat.py b/src/mixedbread/resources/chat.py new file mode 100644 index 00000000..f9b1b0ce --- /dev/null +++ b/src/mixedbread/resources/chat.py @@ -0,0 +1,164 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import httpx + +from .._types import NOT_GIVEN, Body, Query, Headers, NotGiven +from .._compat import cached_property +from .._resource import SyncAPIResource, AsyncAPIResource +from .._response import ( + to_raw_response_wrapper, + to_streamed_response_wrapper, + async_to_raw_response_wrapper, + async_to_streamed_response_wrapper, +) +from .._base_client import make_request_options + +__all__ = ["ChatResource", "AsyncChatResource"] + + +class ChatResource(SyncAPIResource): + @cached_property + def with_raw_response(self) -> ChatResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#accessing-raw-response-data-eg-headers + """ + return ChatResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> ChatResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#with_streaming_response + """ + return ChatResourceWithStreamingResponse(self) + + def create_completion( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Create a chat completion using the provided parameters. + + Generates a completion response based on the chat messages and model parameters + provided. The response can be either a full completion or streamed chunks + depending on the request parameters. + + Args: params: Parameters for creating the chat completion including messages, + model selection, and generation settings user: The authenticated user making the + request + + Returns: Either a ChatCompletion containing the full response, or + ChatCompletionChunk for streaming + + Raises: HTTPException: If there is an error creating the completion (500) + """ + return self._post( + "/v1/chat/completions", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class AsyncChatResource(AsyncAPIResource): + @cached_property + def with_raw_response(self) -> AsyncChatResourceWithRawResponse: + """ + This property can be used as a prefix for any HTTP method call to return + the raw response object instead of the parsed content. + + For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#accessing-raw-response-data-eg-headers + """ + return AsyncChatResourceWithRawResponse(self) + + @cached_property + def with_streaming_response(self) -> AsyncChatResourceWithStreamingResponse: + """ + An alternative to `.with_raw_response` that doesn't eagerly read the response body. + + For more information, see https://www.github.com/mixedbread-ai/mixedbread-python#with_streaming_response + """ + return AsyncChatResourceWithStreamingResponse(self) + + async def create_completion( + self, + *, + # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. + # The extra values given here take precedence over values defined on the client or passed to this method. + extra_headers: Headers | None = None, + extra_query: Query | None = None, + extra_body: Body | None = None, + timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + ) -> object: + """ + Create a chat completion using the provided parameters. + + Generates a completion response based on the chat messages and model parameters + provided. The response can be either a full completion or streamed chunks + depending on the request parameters. + + Args: params: Parameters for creating the chat completion including messages, + model selection, and generation settings user: The authenticated user making the + request + + Returns: Either a ChatCompletion containing the full response, or + ChatCompletionChunk for streaming + + Raises: HTTPException: If there is an error creating the completion (500) + """ + return await self._post( + "/v1/chat/completions", + options=make_request_options( + extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout + ), + cast_to=object, + ) + + +class ChatResourceWithRawResponse: + def __init__(self, chat: ChatResource) -> None: + self._chat = chat + + self.create_completion = to_raw_response_wrapper( + chat.create_completion, + ) + + +class AsyncChatResourceWithRawResponse: + def __init__(self, chat: AsyncChatResource) -> None: + self._chat = chat + + self.create_completion = async_to_raw_response_wrapper( + chat.create_completion, + ) + + +class ChatResourceWithStreamingResponse: + def __init__(self, chat: ChatResource) -> None: + self._chat = chat + + self.create_completion = to_streamed_response_wrapper( + chat.create_completion, + ) + + +class AsyncChatResourceWithStreamingResponse: + def __init__(self, chat: AsyncChatResource) -> None: + self._chat = chat + + self.create_completion = async_to_streamed_response_wrapper( + chat.create_completion, + ) diff --git a/src/mixedbread/resources/data_sources/data_sources.py b/src/mixedbread/resources/data_sources/data_sources.py index 1f3fc0f9..d1fcf526 100644 --- a/src/mixedbread/resources/data_sources/data_sources.py +++ b/src/mixedbread/resources/data_sources/data_sources.py @@ -7,7 +7,13 @@ import httpx -from ...types import DataSourceType, data_source_list_params, data_source_create_params, data_source_update_params +from ...types import ( + Oauth2Params, + DataSourceType, + data_source_list_params, + data_source_create_params, + data_source_update_params, +) from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ..._utils import required_args, maybe_transform, async_maybe_transform from ..._compat import cached_property @@ -29,6 +35,7 @@ from ...pagination import SyncLimitOffset, AsyncLimitOffset from ..._base_client import AsyncPaginator, make_request_options from ...types.data_source import DataSource +from ...types.oauth2_params import Oauth2Params from ...types.data_source_type import DataSourceType from ...types.data_source_delete_response import DataSourceDeleteResponse @@ -66,8 +73,7 @@ def create( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_create_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -109,8 +115,7 @@ def create( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_create_params.LinearDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -151,8 +156,8 @@ def create( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_create_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | Optional[data_source_create_params.LinearDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams] + | Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -225,8 +230,7 @@ def update( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_update_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -273,8 +277,7 @@ def update( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_update_params.LinearDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -320,8 +323,8 @@ def update( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_update_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | Optional[data_source_update_params.LinearDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams] + | Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -467,8 +470,7 @@ async def create( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_create_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -510,8 +512,7 @@ async def create( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_create_params.LinearDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -552,8 +553,8 @@ async def create( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_create_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | Optional[data_source_create_params.LinearDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[data_source_create_params.NotionDataSourceAuthParams] + | Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. @@ -626,8 +627,7 @@ async def update( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_update_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -674,8 +674,7 @@ async def update( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_update_params.LinearDataSourceCreateOrUpdateParamsAuthParams] - | NotGiven = NOT_GIVEN, + auth_params: Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, @@ -721,8 +720,8 @@ async def update( type: DataSourceType | NotGiven = NOT_GIVEN, name: str, metadata: object | NotGiven = NOT_GIVEN, - auth_params: Optional[data_source_update_params.NotionDataSourceCreateOrUpdateParamsAuthParams] - | Optional[data_source_update_params.LinearDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[data_source_update_params.NotionDataSourceAuthParams] + | Optional[Oauth2Params] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. diff --git a/src/mixedbread/types/__init__.py b/src/mixedbread/types/__init__.py index 4b299a86..5fead10f 100644 --- a/src/mixedbread/types/__init__.py +++ b/src/mixedbread/types/__init__.py @@ -11,6 +11,7 @@ from .vector_store import VectorStore as VectorStore from .expires_after import ExpiresAfter as ExpiresAfter from .info_response import InfoResponse as InfoResponse +from .oauth2_params import Oauth2Params as Oauth2Params from .api_key_created import APIKeyCreated as APIKeyCreated from .encoding_format import EncodingFormat as EncodingFormat from .rerank_response import RerankResponse as RerankResponse @@ -29,7 +30,9 @@ from .data_source_list_params import DataSourceListParams as DataSourceListParams from .embedding_create_params import EmbeddingCreateParams as EmbeddingCreateParams from .scored_text_input_chunk import ScoredTextInputChunk as ScoredTextInputChunk +from .linear_data_source_param import LinearDataSourceParam as LinearDataSourceParam from .multi_encoding_embedding import MultiEncodingEmbedding as MultiEncodingEmbedding +from .notion_data_source_param import NotionDataSourceParam as NotionDataSourceParam from .vector_store_list_params import VectorStoreListParams as VectorStoreListParams from .data_source_create_params import DataSourceCreateParams as DataSourceCreateParams from .data_source_oauth2_params import DataSourceOauth2Params as DataSourceOauth2Params diff --git a/src/mixedbread/types/data_source_create_params.py b/src/mixedbread/types/data_source_create_params.py index e9794cdb..caa23d67 100644 --- a/src/mixedbread/types/data_source_create_params.py +++ b/src/mixedbread/types/data_source_create_params.py @@ -5,20 +5,19 @@ from typing import Union, Optional from typing_extensions import Literal, Required, TypeAlias, TypedDict +from .oauth2_params import Oauth2Params from .data_source_type import DataSourceType __all__ = [ "DataSourceCreateParams", - "NotionDataSourceCreateOrUpdateParams", - "NotionDataSourceCreateOrUpdateParamsAuthParams", - "NotionDataSourceCreateOrUpdateParamsAuthParamsOAuth2CreateOrUpdateParams", - "NotionDataSourceCreateOrUpdateParamsAuthParamsAPIKeyCreateOrUpdateParams", - "LinearDataSourceCreateOrUpdateParams", - "LinearDataSourceCreateOrUpdateParamsAuthParams", + "NotionDataSource", + "NotionDataSourceAuthParams", + "NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams", + "LinearDataSource", ] -class NotionDataSourceCreateOrUpdateParams(TypedDict, total=False): +class NotionDataSource(TypedDict, total=False): type: DataSourceType """The type of data source to create""" @@ -28,31 +27,24 @@ class NotionDataSourceCreateOrUpdateParams(TypedDict, total=False): metadata: object """The metadata of the data source""" - auth_params: Optional[NotionDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[NotionDataSourceAuthParams] """The authentication parameters of the data source. Notion supports OAuth2 and API key. """ -class NotionDataSourceCreateOrUpdateParamsAuthParamsOAuth2CreateOrUpdateParams(TypedDict, total=False): - type: Literal["oauth2"] - - -class NotionDataSourceCreateOrUpdateParamsAuthParamsAPIKeyCreateOrUpdateParams(TypedDict, total=False): +class NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams(TypedDict, total=False): type: Literal["api_key"] api_key: Required[str] """The API key""" -NotionDataSourceCreateOrUpdateParamsAuthParams: TypeAlias = Union[ - NotionDataSourceCreateOrUpdateParamsAuthParamsOAuth2CreateOrUpdateParams, - NotionDataSourceCreateOrUpdateParamsAuthParamsAPIKeyCreateOrUpdateParams, -] +NotionDataSourceAuthParams: TypeAlias = Union[Oauth2Params, NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams] -class LinearDataSourceCreateOrUpdateParams(TypedDict, total=False): +class LinearDataSource(TypedDict, total=False): type: DataSourceType """The type of data source to create""" @@ -62,12 +54,8 @@ class LinearDataSourceCreateOrUpdateParams(TypedDict, total=False): metadata: object """The metadata of the data source""" - auth_params: Optional[LinearDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[Oauth2Params] """Base class for OAuth2 create or update parameters.""" -class LinearDataSourceCreateOrUpdateParamsAuthParams(TypedDict, total=False): - type: Literal["oauth2"] - - -DataSourceCreateParams: TypeAlias = Union[NotionDataSourceCreateOrUpdateParams, LinearDataSourceCreateOrUpdateParams] +DataSourceCreateParams: TypeAlias = Union[NotionDataSource, LinearDataSource] diff --git a/src/mixedbread/types/data_source_update_params.py b/src/mixedbread/types/data_source_update_params.py index 23d34c4a..6c283f81 100644 --- a/src/mixedbread/types/data_source_update_params.py +++ b/src/mixedbread/types/data_source_update_params.py @@ -5,20 +5,19 @@ from typing import Union, Optional from typing_extensions import Literal, Required, TypeAlias, TypedDict +from .oauth2_params import Oauth2Params from .data_source_type import DataSourceType __all__ = [ "DataSourceUpdateParams", - "NotionDataSourceCreateOrUpdateParams", - "NotionDataSourceCreateOrUpdateParamsAuthParams", - "NotionDataSourceCreateOrUpdateParamsAuthParamsOAuth2CreateOrUpdateParams", - "NotionDataSourceCreateOrUpdateParamsAuthParamsAPIKeyCreateOrUpdateParams", - "LinearDataSourceCreateOrUpdateParams", - "LinearDataSourceCreateOrUpdateParamsAuthParams", + "NotionDataSource", + "NotionDataSourceAuthParams", + "NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams", + "LinearDataSource", ] -class NotionDataSourceCreateOrUpdateParams(TypedDict, total=False): +class NotionDataSource(TypedDict, total=False): type: DataSourceType """The type of data source to create""" @@ -28,31 +27,24 @@ class NotionDataSourceCreateOrUpdateParams(TypedDict, total=False): metadata: object """The metadata of the data source""" - auth_params: Optional[NotionDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[NotionDataSourceAuthParams] """The authentication parameters of the data source. Notion supports OAuth2 and API key. """ -class NotionDataSourceCreateOrUpdateParamsAuthParamsOAuth2CreateOrUpdateParams(TypedDict, total=False): - type: Literal["oauth2"] - - -class NotionDataSourceCreateOrUpdateParamsAuthParamsAPIKeyCreateOrUpdateParams(TypedDict, total=False): +class NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams(TypedDict, total=False): type: Literal["api_key"] api_key: Required[str] """The API key""" -NotionDataSourceCreateOrUpdateParamsAuthParams: TypeAlias = Union[ - NotionDataSourceCreateOrUpdateParamsAuthParamsOAuth2CreateOrUpdateParams, - NotionDataSourceCreateOrUpdateParamsAuthParamsAPIKeyCreateOrUpdateParams, -] +NotionDataSourceAuthParams: TypeAlias = Union[Oauth2Params, NotionDataSourceAuthParamsAPIKeyCreateOrUpdateParams] -class LinearDataSourceCreateOrUpdateParams(TypedDict, total=False): +class LinearDataSource(TypedDict, total=False): type: DataSourceType """The type of data source to create""" @@ -62,12 +54,8 @@ class LinearDataSourceCreateOrUpdateParams(TypedDict, total=False): metadata: object """The metadata of the data source""" - auth_params: Optional[LinearDataSourceCreateOrUpdateParamsAuthParams] + auth_params: Optional[Oauth2Params] """Base class for OAuth2 create or update parameters.""" -class LinearDataSourceCreateOrUpdateParamsAuthParams(TypedDict, total=False): - type: Literal["oauth2"] - - -DataSourceUpdateParams: TypeAlias = Union[NotionDataSourceCreateOrUpdateParams, LinearDataSourceCreateOrUpdateParams] +DataSourceUpdateParams: TypeAlias = Union[NotionDataSource, LinearDataSource] diff --git a/src/mixedbread/types/linear_data_source_param.py b/src/mixedbread/types/linear_data_source_param.py new file mode 100644 index 00000000..9dbe8904 --- /dev/null +++ b/src/mixedbread/types/linear_data_source_param.py @@ -0,0 +1,25 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Optional +from typing_extensions import Required, TypedDict + +from .oauth2_params import Oauth2Params +from .data_source_type import DataSourceType + +__all__ = ["LinearDataSourceParam"] + + +class LinearDataSourceParam(TypedDict, total=False): + type: DataSourceType + """The type of data source to create""" + + name: Required[str] + """The name of the data source""" + + metadata: object + """The metadata of the data source""" + + auth_params: Optional[Oauth2Params] + """Base class for OAuth2 create or update parameters.""" diff --git a/src/mixedbread/types/notion_data_source_param.py b/src/mixedbread/types/notion_data_source_param.py new file mode 100644 index 00000000..914c502f --- /dev/null +++ b/src/mixedbread/types/notion_data_source_param.py @@ -0,0 +1,38 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import Union, Optional +from typing_extensions import Literal, Required, TypeAlias, TypedDict + +from .oauth2_params import Oauth2Params +from .data_source_type import DataSourceType + +__all__ = ["NotionDataSourceParam", "AuthParams", "AuthParamsAPIKeyCreateOrUpdateParams"] + + +class AuthParamsAPIKeyCreateOrUpdateParams(TypedDict, total=False): + type: Literal["api_key"] + + api_key: Required[str] + """The API key""" + + +AuthParams: TypeAlias = Union[Oauth2Params, AuthParamsAPIKeyCreateOrUpdateParams] + + +class NotionDataSourceParam(TypedDict, total=False): + type: DataSourceType + """The type of data source to create""" + + name: Required[str] + """The name of the data source""" + + metadata: object + """The metadata of the data source""" + + auth_params: Optional[AuthParams] + """The authentication parameters of the data source. + + Notion supports OAuth2 and API key. + """ diff --git a/src/mixedbread/types/oauth2_params.py b/src/mixedbread/types/oauth2_params.py new file mode 100644 index 00000000..6b0e2fa8 --- /dev/null +++ b/src/mixedbread/types/oauth2_params.py @@ -0,0 +1,11 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing_extensions import Literal, TypedDict + +__all__ = ["Oauth2Params"] + + +class Oauth2Params(TypedDict, total=False): + type: Literal["oauth2"] diff --git a/src/mixedbread/types/vector_store_chunk_search_options_param.py b/src/mixedbread/types/vector_store_chunk_search_options_param.py index f5fb8437..eed57858 100644 --- a/src/mixedbread/types/vector_store_chunk_search_options_param.py +++ b/src/mixedbread/types/vector_store_chunk_search_options_param.py @@ -2,27 +2,14 @@ from __future__ import annotations -from typing import List, Union, Optional +from typing import Union, Optional from typing_extensions import TypeAlias, TypedDict -__all__ = ["VectorStoreChunkSearchOptionsParam", "Rerank", "RerankRerankConfig"] +from .vector_stores.rerank_config_param import RerankConfigParam +__all__ = ["VectorStoreChunkSearchOptionsParam", "Rerank"] -class RerankRerankConfig(TypedDict, total=False): - model: str - """The name of the reranking model""" - - with_metadata: Union[bool, List[str]] - """Whether to include metadata in the reranked results""" - - top_k: Optional[int] - """Maximum number of results to return after reranking. - - If None, returns all reranked results. - """ - - -Rerank: TypeAlias = Union[bool, RerankRerankConfig] +Rerank: TypeAlias = Union[bool, RerankConfigParam] class VectorStoreChunkSearchOptionsParam(TypedDict, total=False): diff --git a/src/mixedbread/types/vector_stores/__init__.py b/src/mixedbread/types/vector_stores/__init__.py index e1af64d5..6ce1aafe 100644 --- a/src/mixedbread/types/vector_stores/__init__.py +++ b/src/mixedbread/types/vector_stores/__init__.py @@ -6,6 +6,8 @@ from .vector_store_file import VectorStoreFile as VectorStoreFile from .file_create_params import FileCreateParams as FileCreateParams from .file_search_params import FileSearchParams as FileSearchParams +from .rerank_config_param import RerankConfigParam as RerankConfigParam from .file_delete_response import FileDeleteResponse as FileDeleteResponse from .file_search_response import FileSearchResponse as FileSearchResponse from .scored_vector_store_file import ScoredVectorStoreFile as ScoredVectorStoreFile +from .vector_store_file_status import VectorStoreFileStatus as VectorStoreFileStatus diff --git a/src/mixedbread/types/vector_stores/file_search_params.py b/src/mixedbread/types/vector_stores/file_search_params.py index 2844c28a..17886660 100644 --- a/src/mixedbread/types/vector_stores/file_search_params.py +++ b/src/mixedbread/types/vector_stores/file_search_params.py @@ -5,16 +5,10 @@ from typing import List, Union, Iterable, Optional from typing_extensions import Required, TypeAlias, TypedDict +from .rerank_config_param import RerankConfigParam from ..shared_params.search_filter_condition import SearchFilterCondition -__all__ = [ - "FileSearchParams", - "Filters", - "FiltersUnionMember2", - "SearchOptions", - "SearchOptionsRerank", - "SearchOptionsRerankRerankConfig", -] +__all__ = ["FileSearchParams", "Filters", "FiltersUnionMember2", "SearchOptions", "SearchOptionsRerank"] class FileSearchParams(TypedDict, total=False): @@ -43,22 +37,7 @@ class FileSearchParams(TypedDict, total=False): Filters: TypeAlias = Union["SearchFilter", SearchFilterCondition, Iterable[FiltersUnionMember2]] - -class SearchOptionsRerankRerankConfig(TypedDict, total=False): - model: str - """The name of the reranking model""" - - with_metadata: Union[bool, List[str]] - """Whether to include metadata in the reranked results""" - - top_k: Optional[int] - """Maximum number of results to return after reranking. - - If None, returns all reranked results. - """ - - -SearchOptionsRerank: TypeAlias = Union[bool, SearchOptionsRerankRerankConfig] +SearchOptionsRerank: TypeAlias = Union[bool, RerankConfigParam] class SearchOptions(TypedDict, total=False): diff --git a/src/mixedbread/types/vector_stores/rerank_config_param.py b/src/mixedbread/types/vector_stores/rerank_config_param.py new file mode 100644 index 00000000..da1f0a33 --- /dev/null +++ b/src/mixedbread/types/vector_stores/rerank_config_param.py @@ -0,0 +1,22 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +from typing import List, Union, Optional +from typing_extensions import TypedDict + +__all__ = ["RerankConfigParam"] + + +class RerankConfigParam(TypedDict, total=False): + model: str + """The name of the reranking model""" + + with_metadata: Union[bool, List[str]] + """Whether to include metadata in the reranked results""" + + top_k: Optional[int] + """Maximum number of results to return after reranking. + + If None, returns all reranked results. + """ diff --git a/src/mixedbread/types/vector_stores/scored_vector_store_file.py b/src/mixedbread/types/vector_stores/scored_vector_store_file.py index 919dffec..225806b2 100644 --- a/src/mixedbread/types/vector_stores/scored_vector_store_file.py +++ b/src/mixedbread/types/vector_stores/scored_vector_store_file.py @@ -7,6 +7,7 @@ from ..._utils import PropertyInfo from ..._models import BaseModel from ..scored_text_input_chunk import ScoredTextInputChunk +from .vector_store_file_status import VectorStoreFileStatus from ..scored_audio_url_input_chunk import ScoredAudioURLInputChunk from ..scored_image_url_input_chunk import ScoredImageURLInputChunk from ..scored_video_url_input_chunk import ScoredVideoURLInputChunk @@ -29,7 +30,7 @@ class ScoredVectorStoreFile(BaseModel): metadata: Optional[object] = None """Optional file metadata""" - status: Optional[Literal["pending", "in_progress", "cancelled", "completed", "failed"]] = None + status: Optional[VectorStoreFileStatus] = None """Processing status of the file""" last_error: Optional[object] = None diff --git a/src/mixedbread/types/vector_stores/vector_store_file.py b/src/mixedbread/types/vector_stores/vector_store_file.py index d6e5efda..642c066f 100644 --- a/src/mixedbread/types/vector_stores/vector_store_file.py +++ b/src/mixedbread/types/vector_stores/vector_store_file.py @@ -5,6 +5,7 @@ from typing_extensions import Literal from ..._models import BaseModel +from .vector_store_file_status import VectorStoreFileStatus __all__ = ["VectorStoreFile"] @@ -19,7 +20,7 @@ class VectorStoreFile(BaseModel): metadata: Optional[object] = None """Optional file metadata""" - status: Optional[Literal["pending", "in_progress", "cancelled", "completed", "failed"]] = None + status: Optional[VectorStoreFileStatus] = None """Processing status of the file""" last_error: Optional[object] = None diff --git a/src/mixedbread/types/vector_stores/vector_store_file_status.py b/src/mixedbread/types/vector_stores/vector_store_file_status.py new file mode 100644 index 00000000..12e80abd --- /dev/null +++ b/src/mixedbread/types/vector_stores/vector_store_file_status.py @@ -0,0 +1,7 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from typing_extensions import Literal, TypeAlias + +__all__ = ["VectorStoreFileStatus"] + +VectorStoreFileStatus: TypeAlias = Literal["pending", "in_progress", "cancelled", "completed", "failed"] diff --git a/tests/api_resources/test_chat.py b/tests/api_resources/test_chat.py new file mode 100644 index 00000000..65341369 --- /dev/null +++ b/tests/api_resources/test_chat.py @@ -0,0 +1,71 @@ +# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +from __future__ import annotations + +import os +from typing import Any, cast + +import pytest + +from mixedbread import Mixedbread, AsyncMixedbread +from tests.utils import assert_matches_type + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + + +class TestChat: + parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + def test_method_create_completion(self, client: Mixedbread) -> None: + chat = client.chat.create_completion() + assert_matches_type(object, chat, path=["response"]) + + @parametrize + def test_raw_response_create_completion(self, client: Mixedbread) -> None: + response = client.chat.with_raw_response.create_completion() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + chat = response.parse() + assert_matches_type(object, chat, path=["response"]) + + @parametrize + def test_streaming_response_create_completion(self, client: Mixedbread) -> None: + with client.chat.with_streaming_response.create_completion() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + chat = response.parse() + assert_matches_type(object, chat, path=["response"]) + + assert cast(Any, response.is_closed) is True + + +class TestAsyncChat: + parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) + + @parametrize + async def test_method_create_completion(self, async_client: AsyncMixedbread) -> None: + chat = await async_client.chat.create_completion() + assert_matches_type(object, chat, path=["response"]) + + @parametrize + async def test_raw_response_create_completion(self, async_client: AsyncMixedbread) -> None: + response = await async_client.chat.with_raw_response.create_completion() + + assert response.is_closed is True + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + chat = await response.parse() + assert_matches_type(object, chat, path=["response"]) + + @parametrize + async def test_streaming_response_create_completion(self, async_client: AsyncMixedbread) -> None: + async with async_client.chat.with_streaming_response.create_completion() as response: + assert not response.is_closed + assert response.http_request.headers.get("X-Stainless-Lang") == "python" + + chat = await response.parse() + assert_matches_type(object, chat, path=["response"]) + + assert cast(Any, response.is_closed) is True