Skip to content

Commit

Permalink
update gcp client 1.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
GaspardBT committed Jan 6, 2025
1 parent 09c7732 commit bda7cf6
Show file tree
Hide file tree
Showing 14 changed files with 102 additions and 59 deletions.
10 changes: 5 additions & 5 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ sources:
- latest
mistral-google-cloud-source:
sourceNamespace: mistral-google-cloud-source
sourceRevisionDigest: sha256:e0fd58ce2dbba068f375d3a23d758b8678c2a68cf4fc7bc46ea7e1b37abe0647
sourceBlobDigest: sha256:0707d8d2566a9ef4ef286bb0abe467f8696ccf83ba73091065d7caf627a06611
sourceRevisionDigest: sha256:36c7de11e35023dc8fa5f3c0fb0e486d2a102275a2df808c08cfe9d43089be04
sourceBlobDigest: sha256:dd65bfa5d0448ad1851ebb18b57aa675533cd3e166beb86a390b0ab51d16a1c1
tags:
- latest
mistral-openapi:
Expand All @@ -30,10 +30,10 @@ targets:
mistralai-gcp-sdk:
source: mistral-google-cloud-source
sourceNamespace: mistral-google-cloud-source
sourceRevisionDigest: sha256:e0fd58ce2dbba068f375d3a23d758b8678c2a68cf4fc7bc46ea7e1b37abe0647
sourceBlobDigest: sha256:0707d8d2566a9ef4ef286bb0abe467f8696ccf83ba73091065d7caf627a06611
sourceRevisionDigest: sha256:36c7de11e35023dc8fa5f3c0fb0e486d2a102275a2df808c08cfe9d43089be04
sourceBlobDigest: sha256:dd65bfa5d0448ad1851ebb18b57aa675533cd3e166beb86a390b0ab51d16a1c1
codeSamplesNamespace: mistral-openapi-google-cloud-code-samples
codeSamplesRevisionDigest: sha256:0657ec41e473356a5a0eeaca3dff137e9ff16080ec1fb50e72553245aa86ffe5
codeSamplesRevisionDigest: sha256:7de23f90d6543356f310f46375bef4db7f43eb22b2871ad4dfe1b7d0cc875bb4
mistralai-sdk:
source: mistral-openapi
sourceNamespace: mistral-openapi
Expand Down
1 change: 1 addition & 0 deletions packages/mistralai_gcp/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.speakeasy/reports
README-PYPI.md
.venv/
venv/
Expand Down
28 changes: 18 additions & 10 deletions packages/mistralai_gcp/.speakeasy/gen.lock
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
lockVersion: 2.0.0
id: ec60f2d8-7869-45c1-918e-773d41a8cf74
management:
docChecksum: d50a06ac34844141709fa2e57cc940c5
docChecksum: 849dde0ef239604ca71711ffc1220b54
docVersion: 0.0.2
speakeasyVersion: 1.451.1
generationVersion: 2.470.1
releaseVersion: 1.2.3
configChecksum: 3fc99d7ec7ee057a323b593ebf8fdb8c
speakeasyVersion: 1.462.2
generationVersion: 2.486.1
releaseVersion: 1.2.6
configChecksum: ba11718a5b49fb4a979ae9693a68b191
published: true
features:
python:
additionalDependencies: 1.0.0
constsAndDefaults: 1.0.5
core: 5.6.8
core: 5.7.4
defaultEnabledRetries: 0.2.0
enumUnions: 0.1.0
envVarSecurityUsage: 0.3.2
Expand All @@ -21,9 +21,9 @@ features:
globalSecurity: 3.0.2
globalSecurityCallbacks: 1.0.0
globalSecurityFlattening: 1.0.0
globalServerURLs: 3.0.0
globalServerURLs: 3.1.0
methodArguments: 1.0.2
nameOverrides: 3.0.0
nameOverrides: 3.0.1
nullables: 1.0.0
openEnums: 1.0.0
responseFormat: 1.0.1
Expand Down Expand Up @@ -166,24 +166,32 @@ examples:
speakeasy-default-stream-chat:
requestBody:
application/json: {"model": "mistral-small-latest", "messages": [{"content": "Who is the best French painter? Answer in one short sentence.", "role": "user"}]}
responses:
"422":
application/json: {}
chat_completion_v1_chat_completions_post:
speakeasy-default-chat-completion-v1-chat-completions-post:
requestBody:
application/json: {"model": "mistral-small-latest", "messages": [{"content": "Who is the best French painter? Answer in one short sentence.", "role": "user"}]}
responses:
"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": {}
"422":
application/json: {}
stream_fim:
speakeasy-default-stream-fim:
requestBody:
application/json: {"model": "codestral-2405", "prompt": "def", "suffix": "return a+b"}
responses:
"422":
application/json: {}
fim_completion_v1_fim_completions_post:
speakeasy-default-fim-completion-v1-fim-completions-post:
requestBody:
application/json: {"model": "codestral-2405", "prompt": "def", "suffix": "return a+b"}
responses:
"200":
application/json: {"id": "cmpl-e5cc70bb28c444948073e77776eb30ef", "object": "chat.completion", "model": "codestral-latest", "usage": {"prompt_tokens": 16, "completion_tokens": 34, "total_tokens": 50}, "created": 1702256327, "choices": []}
"422": {}
"422":
application/json: {}
generatedTests: {}
2 changes: 1 addition & 1 deletion packages/mistralai_gcp/.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.3
version: 1.2.6
additionalDependencies:
dev:
pytest: ^8.2.2
Expand Down
6 changes: 3 additions & 3 deletions packages/mistralai_gcp/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "mistralai-gcp"
version = "1.2.3"
version = "1.2.6"
description = "Python Client SDK for the Mistral AI API in GCP."
authors = ["Mistral",]
readme = "README-PYPI.md"
Expand All @@ -19,9 +19,9 @@ in-project = true
python = "^3.8"
eval-type-backport = "^0.2.0"
google-auth = "2.27.0"
httpx = "^0.27.0"
httpx = "^0.28.1"
jsonpath-python = "^1.0.6"
pydantic = "~2.9.2"
pydantic = "~2.10.3"
python-dateutil = "^2.8.2"
requests = "^2.32.3"
typing-inspect = "^0.9.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/mistralai_gcp/src/mistralai_gcp/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import importlib.metadata

__title__: str = "mistralai-gcp"
__version__: str = "1.2.3"
__version__: str = "1.2.6"

try:
if __package__ is not None:
Expand Down
34 changes: 25 additions & 9 deletions packages/mistralai_gcp/src/mistralai_gcp/basesdk.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
BeforeRequestContext,
)
from mistralai_gcp.utils import RetryConfig, SerializedRequestBody, get_body_content
from typing import Callable, List, Optional, Tuple
from typing import Callable, List, Mapping, Optional, Tuple
from urllib.parse import parse_qs, urlparse


class BaseSDK:
Expand All @@ -18,7 +19,7 @@ class BaseSDK:
def __init__(self, sdk_config: SDKConfiguration) -> None:
self.sdk_configuration = sdk_config

def get_url(self, base_url, url_variables):
def _get_url(self, base_url, url_variables):
sdk_url, sdk_variables = self.sdk_configuration.get_server_details()

if base_url is None:
Expand All @@ -29,7 +30,7 @@ def get_url(self, base_url, url_variables):

return utils.template_url(base_url, url_variables)

def build_request_async(
def _build_request_async(
self,
method,
path,
Expand All @@ -48,9 +49,10 @@ def build_request_async(
Callable[[], Optional[SerializedRequestBody]]
] = None,
url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None,
) -> httpx.Request:
client = self.sdk_configuration.async_client
return self.build_request_with_client(
return self._build_request_with_client(
client,
method,
path,
Expand All @@ -67,9 +69,10 @@ def build_request_async(
timeout_ms,
get_serialized_body,
url_override,
http_headers,
)

def build_request(
def _build_request(
self,
method,
path,
Expand All @@ -88,9 +91,10 @@ def build_request(
Callable[[], Optional[SerializedRequestBody]]
] = None,
url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None,
) -> httpx.Request:
client = self.sdk_configuration.client
return self.build_request_with_client(
return self._build_request_with_client(
client,
method,
path,
Expand All @@ -107,9 +111,10 @@ def build_request(
timeout_ms,
get_serialized_body,
url_override,
http_headers,
)

def build_request_with_client(
def _build_request_with_client(
self,
client,
method,
Expand All @@ -129,13 +134,14 @@ def build_request_with_client(
Callable[[], Optional[SerializedRequestBody]]
] = None,
url_override: Optional[str] = None,
http_headers: Optional[Mapping[str, str]] = None,
) -> httpx.Request:
query_params = {}

url = url_override
if url is None:
url = utils.generate_url(
self.get_url(base_url, url_variables),
self._get_url(base_url, url_variables),
path,
request if request_has_path_params else None,
_globals if request_has_path_params else None,
Expand All @@ -145,6 +151,12 @@ def build_request_with_client(
request if request_has_query_params else None,
_globals if request_has_query_params else None,
)
else:
# Pick up the query parameter from the override so they can be
# preserved when building the request later on (necessary as of
# httpx 0.28).
parsed_override = urlparse(str(url_override))
query_params = parse_qs(parsed_override.query, keep_blank_values=True)

headers = utils.get_headers(request, _globals)
headers["Accept"] = accept_header_value
Expand All @@ -159,7 +171,7 @@ def build_request_with_client(
headers = {**headers, **security_headers}
query_params = {**query_params, **security_query_params}

serialized_request_body = SerializedRequestBody("application/octet-stream")
serialized_request_body = SerializedRequestBody()
if get_serialized_body is not None:
rb = get_serialized_body()
if request_body_required and rb is None:
Expand All @@ -178,6 +190,10 @@ def build_request_with_client(
):
headers["content-type"] = serialized_request_body.media_type

if http_headers is not None:
for header, value in http_headers.items():
headers[header] = value

timeout = timeout_ms / 1000 if timeout_ms is not None else None

return client.build_request(
Expand Down
Loading

0 comments on commit bda7cf6

Please sign in to comment.