Skip to content

Commit

Permalink
fix fc streaming (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspardBT authored Aug 8, 2024
1 parent b0e02bc commit aee92fa
Show file tree
Hide file tree
Showing 57 changed files with 389 additions and 286 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/sdk_generation_mistralai_sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
mode: pr
set_version: ${{ github.event.inputs.set_version }}
speakeasy_version: latest
target: mistralai-sdk
target: all
secrets:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
pypi_token: ${{ secrets.PYPI_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
README-PYPI.md
.venv/
pyrightconfig.json
src/*.egg-info/
Expand Down
15 changes: 8 additions & 7 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
lockVersion: 2.0.0
id: 2d045ec7-2ebb-4f4d-ad25-40953b132161
management:
docChecksum: 9e7a46648104410da4d94d5c2b373d20
docChecksum: a7c4268dd1228c969aecfd7cfdb6ca3c
docVersion: 0.0.2
speakeasyVersion: 1.356.0
generationVersion: 2.388.1
releaseVersion: 1.0.0
configChecksum: ab3daea0e59b8225d1742719ddfb86f4
speakeasyVersion: 1.357.4
generationVersion: 2.390.6
releaseVersion: 1.0.2
configChecksum: ed07f7fc253047a5a4dd2c0f813b8ea4
repoURL: https://github.com/mistralai/client-python.git
installationURL: https://github.com/mistralai/client-python.git
published: true
features:
python:
additionalDependencies: 1.0.0
constsAndDefaults: 1.0.2
core: 5.3.4
core: 5.3.7
defaultEnabledRetries: 0.2.0
envVarSecurityUsage: 0.3.1
examples: 3.0.0
flatRequests: 1.0.1
flattening: 3.0.0
globalSecurity: 3.0.1
globalSecurity: 3.0.2
globalSecurityCallbacks: 1.0.0
globalSecurityFlattening: 1.0.0
globalServerURLs: 3.0.0
Expand Down Expand Up @@ -51,6 +51,7 @@ generatedFiles:
- py.typed
- pylintrc
- scripts/compile.sh
- scripts/prepare-readme.py
- scripts/publish.sh
- src/mistralai/__init__.py
- src/mistralai/basesdk.py
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
python:
version: 1.0.0
version: 1.0.2
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down
4 changes: 2 additions & 2 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
speakeasyVersion: 1.356.0
speakeasyVersion: 1.357.4
sources: {}
targets:
mistralai-azure-sdk:
Expand All @@ -9,7 +9,7 @@ targets:
outLocation: ./packages/mistralai_gcp
mistralai-sdk:
source: mistral-openapi
outLocation: /github/workspace/repo
outLocation: /Users/gaspard/public-mistral/client-python
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ This SDK supports the following security scheme globally:
| -------------------- | -------------------- | -------------------- | -------------------- |
| `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |

To authenticate with the API the `null` parameter must be set when initializing the SDK client instance. For example:
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
```python
from mistralai import Mistral
import os
Expand Down Expand Up @@ -662,6 +662,16 @@ s = Mistral(debug_logger=logging.getLogger("mistralai"))
```
<!-- End Debugging [debug] -->

<!-- Start IDE Support [idesupport] -->
## IDE Support

### PyCharm

Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.

- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
<!-- End IDE Support [idesupport] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

# Development
Expand Down
10 changes: 5 additions & 5 deletions docs/models/deltamessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

## Fields

| Field | Type | Required | Description |
| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- |
| `role` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `content` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `tool_calls` | [OptionalNullable[models.ToolCall]](../models/toolcall.md) | :heavy_minus_sign: | N/A |
| Field | Type | Required | Description |
| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- |
| `role` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `content` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `tool_calls` | List[[models.ToolCall](../models/toolcall.md)] | :heavy_minus_sign: | N/A |
1 change: 1 addition & 0 deletions packages/mistralai_azure/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
README-PYPI.md
.venv/
venv/
src/*.egg-info/
Expand Down
15 changes: 8 additions & 7 deletions packages/mistralai_azure/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
lockVersion: 2.0.0
id: dc40fa48-2c4d-46ad-ac8b-270749770f34
management:
docChecksum: f04749e097bb06d5fb8850400b089250
docChecksum: ec02d5407fd9354b416518c4b8fa8b95
docVersion: 0.0.2
speakeasyVersion: 1.356.0
generationVersion: 2.388.1
releaseVersion: 1.0.0-rc.2
configChecksum: 98e9cf39c9535097961a0ca73dbac10b
speakeasyVersion: 1.357.4
generationVersion: 2.390.6
releaseVersion: 1.0.0-rc.4
configChecksum: ad8d0273f78dacd83fbba33510acd0a5
published: true
features:
python:
additionalDependencies: 1.0.0
constsAndDefaults: 1.0.2
core: 5.3.4
core: 5.3.7
defaultEnabledRetries: 0.2.0
envVarSecurityUsage: 0.3.1
examples: 3.0.0
flatRequests: 1.0.1
globalSecurity: 3.0.1
globalSecurity: 3.0.2
globalSecurityCallbacks: 1.0.0
globalSecurityFlattening: 1.0.0
globalServerURLs: 3.0.0
Expand All @@ -39,6 +39,7 @@ generatedFiles:
- pylintrc
- pyproject.toml
- scripts/compile.sh
- scripts/prepare-readme.py
- scripts/publish.sh
- src/mistralai_azure/__init__.py
- src/mistralai_azure/basesdk.py
Expand Down
2 changes: 1 addition & 1 deletion packages/mistralai_azure/.speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ generation:
auth:
oAuth2ClientCredentialsEnabled: true
python:
version: 1.0.0-rc.2
version: 1.0.0-rc.4
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down
10 changes: 5 additions & 5 deletions packages/mistralai_azure/docs/models/deltamessage.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

## Fields

| Field | Type | Required | Description |
| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- |
| `role` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `content` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `tool_calls` | [OptionalNullable[models.ToolCall]](../models/toolcall.md) | :heavy_minus_sign: | N/A |
| Field | Type | Required | Description |
| ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- | ---------------------------------------------- |
| `role` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `content` | *Optional[str]* | :heavy_minus_sign: | N/A |
| `tool_calls` | List[[models.ToolCall](../models/toolcall.md)] | :heavy_minus_sign: | N/A |
16 changes: 15 additions & 1 deletion packages/mistralai_azure/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/mistralai_azure/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[tool.poetry]
name = "mistralai_azure"
version = "1.0.0-rc.2"
version = "1.0.0-rc.4"
description = "Python Client SDK for the Mistral AI API in Azure."
authors = ["Mistral",]
readme = "README.md"
readme = "README-PYPI.md"
packages = [
{ include = "mistralai_azure", from = "src" }
]
Expand All @@ -17,6 +17,7 @@ in-project = true

[tool.poetry.dependencies]
python = "^3.8"
eval-type-backport = "^0.2.0"
httpx = "^0.27.0"
jsonpath-python = "^1.0.6"
pydantic = "~2.8.2"
Expand Down
2 changes: 2 additions & 0 deletions packages/mistralai_azure/scripts/compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ run_command() {
} &> "$output_file" &
}

poetry run python scripts/prepare-readme.py

# Create temporary files for outputs and statuses
for cmd in compileall pylint mypy pyright; do
output_files[$cmd]=$(mktemp)
Expand Down
9 changes: 9 additions & 0 deletions packages/mistralai_azure/scripts/prepare-readme.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""

import shutil

try:
shutil.copyfile('README.md', 'README-PYPI.md')
except Exception as e:
print("Failed to copy README.md to README-PYPI.md")
print(e)
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
from typing_extensions import Annotated, NotRequired


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]]
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]


ChatCompletionRequestMessages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]


ChatCompletionRequestToolChoice = Literal["auto", "none", "any"]

class ChatCompletionRequestTypedDict(TypedDict):
Expand Down Expand Up @@ -93,17 +107,3 @@ def serialize_model(self, handler):

return m


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]]
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]


ChatCompletionRequestMessages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@
from typing_extensions import Annotated, NotRequired


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]]
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]


Messages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]


ToolChoice = Literal["auto", "none", "any"]

class ChatCompletionStreamRequestTypedDict(TypedDict):
Expand Down Expand Up @@ -91,17 +105,3 @@ def serialize_model(self, handler):

return m


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]]
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]


Messages = Annotated[Union[Annotated[AssistantMessage, Tag("assistant")], Annotated[SystemMessage, Tag("system")], Annotated[ToolMessage, Tag("tool")], Annotated[UserMessage, Tag("user")]], Discriminator(lambda m: get_discriminator(m, "role", "role"))]

Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
from .toolcall import ToolCall, ToolCallTypedDict
from mistralai_azure.types import BaseModel, Nullable, OptionalNullable, UNSET, UNSET_SENTINEL
from pydantic import model_serializer
from typing import Optional, TypedDict
from typing import List, Optional, TypedDict
from typing_extensions import NotRequired


class DeltaMessageTypedDict(TypedDict):
role: NotRequired[str]
content: NotRequired[str]
tool_calls: NotRequired[Nullable[ToolCallTypedDict]]
tool_calls: NotRequired[Nullable[List[ToolCallTypedDict]]]


class DeltaMessage(BaseModel):
role: Optional[str] = None
content: Optional[str] = None
tool_calls: OptionalNullable[ToolCall] = UNSET
tool_calls: OptionalNullable[List[ToolCall]] = UNSET

@model_serializer(mode="wrap")
def serialize_model(self, handler):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
from typing import Any, Dict, TypedDict, Union


ArgumentsTypedDict = Union[Dict[str, Any], str]


Arguments = Union[Dict[str, Any], str]


class FunctionCallTypedDict(TypedDict):
name: str
arguments: ArgumentsTypedDict
Expand All @@ -14,9 +20,3 @@ class FunctionCall(BaseModel):
name: str
arguments: Arguments


ArgumentsTypedDict = Union[Dict[str, Any], str]


Arguments = Union[Dict[str, Any], str]

Loading

0 comments on commit aee92fa

Please sign in to comment.