Skip to content

Commit

Permalink
gen azure sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
aac228 committed Dec 4, 2024
1 parent cd26391 commit c27ad54
Show file tree
Hide file tree
Showing 20 changed files with 217 additions and 106 deletions.
10 changes: 5 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ speakeasyVersion: 1.451.1
sources:
mistral-azure-source:
sourceNamespace: mistral-azure-source
sourceRevisionDigest: sha256:c441f2d21e7879f5fb9d8d99e2ae242d1e5a84c0c06db971911eb578173e7f62
sourceBlobDigest: sha256:de4af0f100f15fef89e093a6b5393302b2218fb154230594ec811aacdd4f2ec7
sourceRevisionDigest: sha256:9c35eed0174f2d8165807bcd7c8e7b7111fa97c059a77ae7eeaa352ca7e83b4d
sourceBlobDigest: sha256:07283bfde08363f9f69b133888b482472c4bf12d2e5b59cb33c8993c517278e3
tags:
- latest
mistral-google-cloud-source:
Expand All @@ -22,10 +22,10 @@ targets:
mistralai-azure-sdk:
source: mistral-azure-source
sourceNamespace: mistral-azure-source
sourceRevisionDigest: sha256:c441f2d21e7879f5fb9d8d99e2ae242d1e5a84c0c06db971911eb578173e7f62
sourceBlobDigest: sha256:de4af0f100f15fef89e093a6b5393302b2218fb154230594ec811aacdd4f2ec7
sourceRevisionDigest: sha256:9c35eed0174f2d8165807bcd7c8e7b7111fa97c059a77ae7eeaa352ca7e83b4d
sourceBlobDigest: sha256:07283bfde08363f9f69b133888b482472c4bf12d2e5b59cb33c8993c517278e3
codeSamplesNamespace: mistral-openapi-azure-code-samples
codeSamplesRevisionDigest: sha256:5db0b04cc2b3962de41cb07e87fe817dd5ec8bc5d8b0254245b26faf70ede027
codeSamplesRevisionDigest: sha256:79a227720579444358a825b1a272c153f3d9dd48cd0913be6c988d7931a44241
mistralai-gcp-sdk:
source: mistral-google-cloud-source
sourceNamespace: mistral-google-cloud-source
Expand Down
14 changes: 7 additions & 7 deletions packages/mistralai_azure/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
lockVersion: 2.0.0
id: dc40fa48-2c4d-46ad-ac8b-270749770f34
management:
docChecksum: d0000cbe03848bfe843794965cba332f
docChecksum: 26271aa279a7a7182f7af19df8b67038
docVersion: 0.0.2
speakeasyVersion: 1.440.1
generationVersion: 2.460.1
speakeasyVersion: 1.451.1
generationVersion: 2.470.1
releaseVersion: 1.2.3
configChecksum: 60295c765204eb0aa26205ec02e574fc
published: true
features:
python:
additionalDependencies: 1.0.0
constsAndDefaults: 1.0.5
core: 5.6.5
core: 5.6.8
defaultEnabledRetries: 0.2.0
enumUnions: 0.1.0
envVarSecurityUsage: 0.3.2
Expand All @@ -29,11 +29,10 @@ features:
responseFormat: 1.0.1
retries: 3.0.2
sdkHooks: 1.0.0
serverEvents: 1.0.4
serverEvents: 1.0.7
serverEventsSentinels: 0.1.0
serverIDs: 3.0.0
tests: 1.6.0
unions: 3.0.3
unions: 3.0.4
generatedFiles:
- .gitattributes
- .python-version
Expand Down Expand Up @@ -166,3 +165,4 @@ examples:
"200":
application/json: {"id": "cmpl-e5cc70bb28c444948073e77776eb30ef", "object": "chat.completion", "model": "mistral-small-latest", "usage": {"prompt_tokens": 16, "completion_tokens": 34, "total_tokens": 50}, "created": 1702256327, "choices": []}
"422": {}
generatedTests: {}
4 changes: 2 additions & 2 deletions packages/mistralai_azure/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ eval-type-backport = "^0.2.0"
httpx = "^0.27.0"
jsonpath-python = "^1.0.6"
pydantic = "~2.9.2"
python-dateutil = "2.8.2"
python-dateutil = "^2.8.2"
typing-inspect = "^0.9.0"

[tool.poetry.group.dev.dependencies]
mypy = "==1.10.1"
mypy = "==1.13.0"
pylint = "==3.2.3"
pytest = "^8.2.2"
pytest-asyncio = "^0.23.7"
Expand Down
10 changes: 5 additions & 5 deletions packages/mistralai_azure/src/mistralai_azure/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from mistralai_azure._hooks import HookContext
from mistralai_azure.types import OptionalNullable, UNSET
from mistralai_azure.utils import eventstreaming
from typing import Any, AsyncGenerator, Generator, List, Optional, Union
from typing import Any, List, Optional, Union


class Chat(BaseSDK):
Expand Down Expand Up @@ -41,7 +41,7 @@ def stream(
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
) -> Optional[Generator[models.CompletionEvent, None, None]]:
) -> Optional[eventstreaming.EventStream[models.CompletionEvent]]:
r"""Stream chat completion
Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
Expand Down Expand Up @@ -135,7 +135,7 @@ def stream(

data: Any = None
if utils.match_response(http_res, "200", "text/event-stream"):
return eventstreaming.stream_events(
return eventstreaming.EventStream(
http_res,
lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
sentinel="[DONE]",
Expand Down Expand Up @@ -189,7 +189,7 @@ async def stream_async(
retries: OptionalNullable[utils.RetryConfig] = UNSET,
server_url: Optional[str] = None,
timeout_ms: Optional[int] = None,
) -> Optional[AsyncGenerator[models.CompletionEvent, None]]:
) -> Optional[eventstreaming.EventStreamAsync[models.CompletionEvent]]:
r"""Stream chat completion
Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
Expand Down Expand Up @@ -283,7 +283,7 @@ async def stream_async(

data: Any = None
if utils.match_response(http_res, "200", "text/event-stream"):
return eventstreaming.stream_events_async(
return eventstreaming.EventStreamAsync(
http_res,
lambda raw: utils.unmarshal_json(raw, models.CompletionEvent),
sentinel="[DONE]",
Expand Down
6 changes: 6 additions & 0 deletions packages/mistralai_azure/src/mistralai_azure/httpclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def build_request(
) -> httpx.Request:
pass

def close(self) -> None:
pass


@runtime_checkable
class AsyncHttpClient(Protocol):
Expand Down Expand Up @@ -76,3 +79,6 @@ def build_request(
extensions: Optional[httpx._types.RequestExtensions] = None,
) -> httpx.Request:
pass

async def aclose(self) -> None:
pass
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@
)
from pydantic import model_serializer
from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypedDict
from typing_extensions import NotRequired, TypeAliasType, TypedDict


AssistantMessageContentTypedDict = Union[str, List[ContentChunkTypedDict]]
AssistantMessageContentTypedDict = TypeAliasType(
"AssistantMessageContentTypedDict", Union[str, List[ContentChunkTypedDict]]
)


AssistantMessageContent = Union[str, List[ContentChunk]]
AssistantMessageContent = TypeAliasType(
"AssistantMessageContent", Union[str, List[ContentChunk]]
)


AssistantMessageRole = Literal["assistant"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,30 @@
from mistralai_azure.utils import get_discriminator
from pydantic import Discriminator, Tag, model_serializer
from typing import List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


ChatCompletionRequestStopTypedDict = Union[str, List[str]]
ChatCompletionRequestStopTypedDict = TypeAliasType(
"ChatCompletionRequestStopTypedDict", Union[str, List[str]]
)
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""


ChatCompletionRequestStop = Union[str, List[str]]
ChatCompletionRequestStop = TypeAliasType(
"ChatCompletionRequestStop", Union[str, List[str]]
)
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""


ChatCompletionRequestMessagesTypedDict = Union[
SystemMessageTypedDict,
UserMessageTypedDict,
AssistantMessageTypedDict,
ToolMessageTypedDict,
]
ChatCompletionRequestMessagesTypedDict = TypeAliasType(
"ChatCompletionRequestMessagesTypedDict",
Union[
SystemMessageTypedDict,
UserMessageTypedDict,
AssistantMessageTypedDict,
ToolMessageTypedDict,
],
)


ChatCompletionRequestMessages = Annotated[
Expand All @@ -49,10 +56,15 @@
]


ChatCompletionRequestToolChoiceTypedDict = Union[ToolChoiceTypedDict, ToolChoiceEnum]
ChatCompletionRequestToolChoiceTypedDict = TypeAliasType(
"ChatCompletionRequestToolChoiceTypedDict",
Union[ToolChoiceTypedDict, ToolChoiceEnum],
)


ChatCompletionRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
ChatCompletionRequestToolChoice = TypeAliasType(
"ChatCompletionRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
)


class ChatCompletionRequestTypedDict(TypedDict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,26 @@
from mistralai_azure.utils import get_discriminator
from pydantic import Discriminator, Tag, model_serializer
from typing import List, Optional, Union
from typing_extensions import Annotated, NotRequired, TypedDict
from typing_extensions import Annotated, NotRequired, TypeAliasType, TypedDict


StopTypedDict = Union[str, List[str]]
StopTypedDict = TypeAliasType("StopTypedDict", Union[str, List[str]])
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""


Stop = Union[str, List[str]]
Stop = TypeAliasType("Stop", Union[str, List[str]])
r"""Stop generation if this token is detected. Or if one of these tokens is detected when providing an array"""


MessagesTypedDict = Union[
SystemMessageTypedDict,
UserMessageTypedDict,
AssistantMessageTypedDict,
ToolMessageTypedDict,
]
MessagesTypedDict = TypeAliasType(
"MessagesTypedDict",
Union[
SystemMessageTypedDict,
UserMessageTypedDict,
AssistantMessageTypedDict,
ToolMessageTypedDict,
],
)


Messages = Annotated[
Expand All @@ -49,12 +52,15 @@
]


ChatCompletionStreamRequestToolChoiceTypedDict = Union[
ToolChoiceTypedDict, ToolChoiceEnum
]
ChatCompletionStreamRequestToolChoiceTypedDict = TypeAliasType(
"ChatCompletionStreamRequestToolChoiceTypedDict",
Union[ToolChoiceTypedDict, ToolChoiceEnum],
)


ChatCompletionStreamRequestToolChoice = Union[ToolChoice, ToolChoiceEnum]
ChatCompletionStreamRequestToolChoice = TypeAliasType(
"ChatCompletionStreamRequestToolChoice", Union[ToolChoice, ToolChoiceEnum]
)


class ChatCompletionStreamRequestTypedDict(TypedDict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from mistralai_azure.utils import get_discriminator
from pydantic import Discriminator, Tag
from typing import Union
from typing_extensions import Annotated
from typing_extensions import Annotated, TypeAliasType


ContentChunkTypedDict = Union[TextChunkTypedDict, ReferenceChunkTypedDict]
ContentChunkTypedDict = TypeAliasType(
"ContentChunkTypedDict", Union[TextChunkTypedDict, ReferenceChunkTypedDict]
)


ContentChunk = Annotated[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
)
from pydantic import model_serializer
from typing import List, Union
from typing_extensions import NotRequired, TypedDict
from typing_extensions import NotRequired, TypeAliasType, TypedDict


ContentTypedDict = Union[str, List[ContentChunkTypedDict]]
ContentTypedDict = TypeAliasType(
"ContentTypedDict", Union[str, List[ContentChunkTypedDict]]
)


Content = Union[str, List[ContentChunk]]
Content = TypeAliasType("Content", Union[str, List[ContentChunk]])


class DeltaMessageTypedDict(TypedDict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from __future__ import annotations
from mistralai_azure.types import BaseModel
from typing import Any, Dict, Union
from typing_extensions import TypedDict
from typing_extensions import TypeAliasType, TypedDict


ArgumentsTypedDict = Union[Dict[str, Any], str]
ArgumentsTypedDict = TypeAliasType("ArgumentsTypedDict", Union[Dict[str, Any], str])


Arguments = Union[Dict[str, Any], str]
Arguments = TypeAliasType("Arguments", Union[Dict[str, Any], str])


class FunctionCallTypedDict(TypedDict):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,19 @@

from __future__ import annotations
from mistralai_azure.types import BaseModel
from mistralai_azure.utils import validate_const
import pydantic
from pydantic.functional_validators import AfterValidator
from typing import List, Literal, Optional
from typing_extensions import Annotated, TypedDict
from typing_extensions import NotRequired, TypedDict


ReferenceChunkType = Literal["reference"]


class ReferenceChunkTypedDict(TypedDict):
reference_ids: List[int]
type: ReferenceChunkType
type: NotRequired[ReferenceChunkType]


class ReferenceChunk(BaseModel):
reference_ids: List[int]

TYPE: Annotated[
Annotated[
Optional[ReferenceChunkType], AfterValidator(validate_const("reference"))
],
pydantic.Field(alias="type"),
] = "reference"
type: Optional[ReferenceChunkType] = "reference"
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
from .textchunk import TextChunk, TextChunkTypedDict
from mistralai_azure.types import BaseModel
from typing import List, Literal, Optional, Union
from typing_extensions import NotRequired, TypedDict
from typing_extensions import NotRequired, TypeAliasType, TypedDict


SystemMessageContentTypedDict = Union[str, List[TextChunkTypedDict]]
SystemMessageContentTypedDict = TypeAliasType(
"SystemMessageContentTypedDict", Union[str, List[TextChunkTypedDict]]
)


SystemMessageContent = Union[str, List[TextChunk]]
SystemMessageContent = TypeAliasType(
"SystemMessageContent", Union[str, List[TextChunk]]
)


Role = Literal["system"]
Expand Down
Loading

0 comments on commit c27ad54

Please sign in to comment.