Skip to content

Commit

Permalink
chore: 🐝 Update SDK - Generate MISTRALAI MISTRALAI-SDK 1.2.1 (#154)
Browse files Browse the repository at this point in the history
* ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.434.7

* update the gcp name logic

---------

Co-authored-by: speakeasybot <[email protected]>
Co-authored-by: gaspardBT <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent cc2a09a commit a53f0d1
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .speakeasy/gen.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ id: 2d045ec7-2ebb-4f4d-ad25-40953b132161
management:
docChecksum: ee15d853ecc28d415d6b33191893a6ff
docVersion: 0.0.2
speakeasyVersion: 1.434.4
speakeasyVersion: 1.434.7
generationVersion: 2.452.0
releaseVersion: 1.2.0
configChecksum: 17ae764aa509274d1cf2d75af5bf6abb
releaseVersion: 1.2.1
configChecksum: 5d659f51b118508e47958545e6b539d2
repoURL: https://github.com/mistralai/client-python.git
installationURL: https://github.com/mistralai/client-python.git
published: true
Expand Down
2 changes: 1 addition & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ generation:
oAuth2ClientCredentialsEnabled: true
oAuth2PasswordEnabled: false
python:
version: 1.2.0
version: 1.2.1
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down
5 changes: 3 additions & 2 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
speakeasyVersion: 1.434.4
speakeasyVersion: 1.434.7
sources:
mistral-azure-source:
sourceNamespace: mistral-openapi-azure
Expand All @@ -18,6 +18,7 @@ sources:
sourceBlobDigest: sha256:559403eaaa97c021eaf0022adddb1066694d879a946c87057e942806d5a2a2a2
tags:
- latest
- main
targets:
mistralai-azure-sdk:
source: mistral-azure-source
Expand All @@ -35,7 +36,7 @@ targets:
sourceRevisionDigest: sha256:e658442ebfc83351cbb7873fb17b03f07ff9edebd8eddfce5577e2c5c7bfafce
sourceBlobDigest: sha256:559403eaaa97c021eaf0022adddb1066694d879a946c87057e942806d5a2a2a2
codeSamplesNamespace: mistral-openapi-code-samples
codeSamplesRevisionDigest: sha256:e56faedc510d1c011d19e5fbbaa9d41917ffd6c22833b0795a61aa6da1cbca9b
codeSamplesRevisionDigest: sha256:f48900efe513aa95888e4035452ba1d54a2b1f8e872454ccb5bdca24d4fc7b09
workflow:
workflowVersion: 1.0.0
speakeasyVersion: latest
Expand Down
12 changes: 11 additions & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,14 @@ Based on:
### Generated
- [python v1.2.0] .
### Releases
- [PyPI v1.2.0] https://pypi.org/project/mistralai/1.2.0 - .
- [PyPI v1.2.0] https://pypi.org/project/mistralai/1.2.0 - .

## 2024-11-08 13:41:24
### Changes
Based on:
- OpenAPI Doc
- Speakeasy CLI 1.434.7 (2.452.0) https://github.com/speakeasy-api/speakeasy
### Generated
- [python v1.2.1] .
### Releases
- [PyPI v1.2.1] https://pypi.org/project/mistralai/1.2.1 - .
31 changes: 20 additions & 11 deletions packages/mistralai_gcp/src/mistralai_gcp/sdk.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT."""

import json
from typing import Optional, Union
from typing import Optional, Tuple, Union

import google.auth
import google.auth.credentials
Expand All @@ -20,6 +20,19 @@
from .utils.logger import Logger, NoOpLogger
from .utils.retries import RetryConfig

LEGACY_MODEL_ID_FORMAT = {
"codestral-2405": "codestral@2405",
"mistral-large-2407": "mistral-large@2407",
"mistral-nemo-2407": "mistral-nemo@2407",
}

def get_model_info(model: str) -> Tuple[str,str]:
# if the model requiers the legacy fomat, use it, else do nothing.
model_id = LEGACY_MODEL_ID_FORMAT.get(model, model)
model = "-".join(model.split("-")[:-1])
return model, model_id



class MistralGoogleCloud(BaseSDK):
r"""Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create your account on [La Plateforme](https://console.mistral.ai) to get access and read the [docs](https://docs.mistral.ai) to learn how to use it."""
Expand Down Expand Up @@ -140,28 +153,24 @@ def __init__(self, region: str, project_id: str):
def before_request(
self, hook_ctx, request: httpx.Request
) -> Union[httpx.Request, Exception]:
# The goal of this function is to template in the region, project, model, and model_version into the URL path
# The goal of this function is to template in the region, project and model into the URL path
# We do this here so that the API remains more user-friendly
model = None
model_version = None
model_id = None
new_content = None
if request.content:
parsed = json.loads(request.content.decode("utf-8"))
model_raw = parsed.get("model")
model = "-".join(model_raw.split("-")[:-1])
model_version = model_raw.split("-")[-1]
parsed["model"] = model
model_name, model_id = get_model_info(model_raw)
parsed["model"] = model_name
new_content = json.dumps(parsed).encode("utf-8")

if model == "":
if model_id == "":
raise models.SDKError("model must be provided")

if model_version is None:
raise models.SDKError("model_version must be provided")

stream = "streamRawPredict" in request.url.path
specifier = "streamRawPredict" if stream else "rawPredict"
url = f"/v1/projects/{self.project_id}/locations/{self.region}/publishers/mistralai/models/{model}@{model_version}:{specifier}"
url = f"/v1/projects/{self.project_id}/locations/{self.region}/publishers/mistralai/models/{model_id}:{specifier}"

headers = dict(request.headers)
# Delete content-length header as it will need to be recalculated
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mistralai"
version = "1.2.0"
version = "1.2.1"
description = "Python Client SDK for the Mistral AI API."
authors = ["Mistral"]
readme = "README-PYPI.md"
Expand Down
2 changes: 1 addition & 1 deletion src/mistralai/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import importlib.metadata

__title__: str = "mistralai"
__version__: str = "1.2.0"
__version__: str = "1.2.1"

try:
if __package__ is not None:
Expand Down
4 changes: 2 additions & 2 deletions src/mistralai/sdkconfiguration.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ class SDKConfiguration:
server: Optional[str] = ""
language: str = "python"
openapi_doc_version: str = "0.0.2"
sdk_version: str = "1.2.0"
sdk_version: str = "1.2.1"
gen_version: str = "2.452.0"
user_agent: str = "speakeasy-sdk/python 1.2.0 2.452.0 0.0.2 mistralai"
user_agent: str = "speakeasy-sdk/python 1.2.1 2.452.0 0.0.2 mistralai"
retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
timeout_ms: Optional[int] = None

Expand Down

0 comments on commit a53f0d1

Please sign in to comment.