relaxai 0.0.1__py3-none-any.whl → 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of relaxai might be problematic. Click here for more details.

relaxai/_base_client.py CHANGED
@@ -529,6 +529,15 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
529
529
  # work around https://github.com/encode/httpx/discussions/2880
530
530
  kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")}
531
531
 
532
+ is_body_allowed = options.method.lower() != "get"
533
+
534
+ if is_body_allowed:
535
+ kwargs["json"] = json_data if is_given(json_data) else None
536
+ kwargs["files"] = files
537
+ else:
538
+ headers.pop("Content-Type", None)
539
+ kwargs.pop("data", None)
540
+
532
541
  # TODO: report this error to httpx
533
542
  return self._client.build_request( # pyright: ignore[reportUnknownMemberType]
534
543
  headers=headers,
@@ -540,8 +549,6 @@ class BaseClient(Generic[_HttpxClientT, _DefaultStreamT]):
540
549
  # so that passing a `TypedDict` doesn't cause an error.
541
550
  # https://github.com/microsoft/pyright/issues/3526#event-6715453066
542
551
  params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None,
543
- json=json_data if is_given(json_data) else None,
544
- files=files,
545
552
  **kwargs,
546
553
  )
547
554
 
relaxai/_client.py CHANGED
@@ -79,7 +79,7 @@ class Relaxai(SyncAPIClient):
79
79
  if base_url is None:
80
80
  base_url = os.environ.get("RELAXAI_BASE_URL")
81
81
  if base_url is None:
82
- base_url = f"/"
82
+ base_url = f"http://127.0.0.1"
83
83
 
84
84
  super().__init__(
85
85
  version=__version__,
@@ -262,7 +262,7 @@ class AsyncRelaxai(AsyncAPIClient):
262
262
  if base_url is None:
263
263
  base_url = os.environ.get("RELAXAI_BASE_URL")
264
264
  if base_url is None:
265
- base_url = f"/"
265
+ base_url = f"http://127.0.0.1"
266
266
 
267
267
  super().__init__(
268
268
  version=__version__,
relaxai/_models.py CHANGED
@@ -2,9 +2,10 @@ from __future__ import annotations
2
2
 
3
3
  import os
4
4
  import inspect
5
- from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast
5
+ from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast
6
6
  from datetime import date, datetime
7
7
  from typing_extensions import (
8
+ List,
8
9
  Unpack,
9
10
  Literal,
10
11
  ClassVar,
@@ -207,14 +208,18 @@ class BaseModel(pydantic.BaseModel):
207
208
  else:
208
209
  fields_values[name] = field_get_default(field)
209
210
 
211
+ extra_field_type = _get_extra_fields_type(__cls)
212
+
210
213
  _extra = {}
211
214
  for key, value in values.items():
212
215
  if key not in model_fields:
216
+ parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value
217
+
213
218
  if PYDANTIC_V2:
214
- _extra[key] = value
219
+ _extra[key] = parsed
215
220
  else:
216
221
  _fields_set.add(key)
217
- fields_values[key] = value
222
+ fields_values[key] = parsed
218
223
 
219
224
  object.__setattr__(m, "__dict__", fields_values)
220
225
 
@@ -366,7 +371,24 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object:
366
371
  if type_ is None:
367
372
  raise RuntimeError(f"Unexpected field type is None for {key}")
368
373
 
369
- return construct_type(value=value, type_=type_)
374
+ return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None))
375
+
376
+
377
+ def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None:
378
+ if not PYDANTIC_V2:
379
+ # TODO
380
+ return None
381
+
382
+ schema = cls.__pydantic_core_schema__
383
+ if schema["type"] == "model":
384
+ fields = schema["schema"]
385
+ if fields["type"] == "model-fields":
386
+ extras = fields.get("extras_schema")
387
+ if extras and "cls" in extras:
388
+ # mypy can't narrow the type
389
+ return extras["cls"] # type: ignore[no-any-return]
390
+
391
+ return None
370
392
 
371
393
 
372
394
  def is_basemodel(type_: type) -> bool:
@@ -420,7 +442,7 @@ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T:
420
442
  return cast(_T, construct_type(value=value, type_=type_))
421
443
 
422
444
 
423
- def construct_type(*, value: object, type_: object) -> object:
445
+ def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object:
424
446
  """Loose coercion to the expected type with construction of nested values.
425
447
 
426
448
  If the given value does not match the expected type then it is returned as-is.
@@ -438,8 +460,10 @@ def construct_type(*, value: object, type_: object) -> object:
438
460
  type_ = type_.__value__ # type: ignore[unreachable]
439
461
 
440
462
  # unwrap `Annotated[T, ...]` -> `T`
441
- if is_annotated_type(type_):
442
- meta: tuple[Any, ...] = get_args(type_)[1:]
463
+ if metadata is not None and len(metadata) > 0:
464
+ meta: tuple[Any, ...] = tuple(metadata)
465
+ elif is_annotated_type(type_):
466
+ meta = get_args(type_)[1:]
443
467
  type_ = extract_type_arg(type_, 0)
444
468
  else:
445
469
  meta = tuple()
relaxai/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "relaxai"
4
- __version__ = "0.0.1" # x-release-please-version
4
+ __version__ = "0.1.0" # x-release-please-version
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: relaxai
3
- Version: 0.0.1
3
+ Version: 0.1.0
4
4
  Summary: The official Python library for the relaxai API
5
5
  Project-URL: Homepage, https://github.com/relax-ai/python-sdk
6
6
  Project-URL: Repository, https://github.com/relax-ai/python-sdk
@@ -18,6 +18,7 @@ Classifier: Programming Language :: Python :: 3.9
18
18
  Classifier: Programming Language :: Python :: 3.10
19
19
  Classifier: Programming Language :: Python :: 3.11
20
20
  Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
21
22
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
23
  Classifier: Typing :: Typed
23
24
  Requires-Python: >=3.8
@@ -29,12 +30,13 @@ Requires-Dist: sniffio
29
30
  Requires-Dist: typing-extensions<5,>=4.10
30
31
  Provides-Extra: aiohttp
31
32
  Requires-Dist: aiohttp; extra == 'aiohttp'
32
- Requires-Dist: httpx-aiohttp>=0.1.6; extra == 'aiohttp'
33
+ Requires-Dist: httpx-aiohttp>=0.1.8; extra == 'aiohttp'
33
34
  Description-Content-Type: text/markdown
34
35
 
35
36
  # Relaxai Python API library
36
37
 
37
- [![PyPI version](https://github.com/relax-ai/python-sdk/tree/main/<https://img.shields.io/pypi/v/relaxai.svg?label=pypi%20(stable)>)](https://pypi.org/project/relaxai/)
38
+ <!-- prettier-ignore -->
39
+ [![PyPI version](https://img.shields.io/pypi/v/relaxai.svg?label=pypi%20(stable))](https://pypi.org/project/relaxai/)
38
40
 
39
41
  The Relaxai Python library provides convenient access to the Relaxai REST API from any Python 3.8+
40
42
  application. The library includes type definitions for all request params and response fields,
@@ -128,7 +130,6 @@ pip install relaxai[aiohttp]
128
130
  Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:
129
131
 
130
132
  ```python
131
- import os
132
133
  import asyncio
133
134
  from relaxai import DefaultAioHttpClient
134
135
  from relaxai import AsyncRelaxai
@@ -136,7 +137,7 @@ from relaxai import AsyncRelaxai
136
137
 
137
138
  async def main() -> None:
138
139
  async with AsyncRelaxai(
139
- api_key=os.environ.get("RELAXAI_API_KEY"), # This is the default and can be omitted
140
+ api_key="My API Key",
140
141
  http_client=DefaultAioHttpClient(),
141
142
  ) as client:
142
143
  response = await client.chat.create_completion(
@@ -1,17 +1,17 @@
1
1
  relaxai/__init__.py,sha256=jawpphZN3cZd39n6_t5JS-ypY59otlavNWnrP--HOHU,2587
2
- relaxai/_base_client.py,sha256=_FDl5IhRWrFRkktJpIjmHgagrMupFj1FSVvr3t302sE,66716
3
- relaxai/_client.py,sha256=jgqv6k3Soy6PWVJCWcDcwAhrWfUGNiKUrVnXPw5Gpog,17017
2
+ relaxai/_base_client.py,sha256=jQtwK70fFgN0seJMTCfg6E72__5mGwKeFFzm5lMDiyk,66923
3
+ relaxai/_client.py,sha256=29DIWccQ2r86_yEdq1tS5nYzhidCuLUNoZAQ9gvrFdA,17047
4
4
  relaxai/_compat.py,sha256=VWemUKbj6DDkQ-O4baSpHVLJafotzeXmCQGJugfVTIw,6580
5
5
  relaxai/_constants.py,sha256=S14PFzyN9-I31wiV7SmIlL5Ga0MLHxdvegInGdXH7tM,462
6
6
  relaxai/_exceptions.py,sha256=CPRCoUcv5nQ7_hkZu9WvAFxQM0Mf6_ZCGU8JPY81zpY,3222
7
7
  relaxai/_files.py,sha256=mf4dOgL4b0ryyZlbqLhggD3GVgDf6XxdGFAgce01ugE,3549
8
- relaxai/_models.py,sha256=G1vczEodX0vUySeVKbF-mbzlaObNL1oVAYH4c65agRk,29131
8
+ relaxai/_models.py,sha256=KvjsMfb88XZlFUKVoOxr8OyDj47MhoH2OKqWNEbBhk4,30010
9
9
  relaxai/_qs.py,sha256=AOkSz4rHtK4YI3ZU_kzea-zpwBUgEY8WniGmTPyEimc,4846
10
10
  relaxai/_resource.py,sha256=v7qxjafEaUaEfecj54WhuhW2hupVzM8Os0EIHVRmbkc,1106
11
11
  relaxai/_response.py,sha256=URFVS4ivxSoLsvosTN0Rc3f5vbBBb0DIB4Eh2XPGa_Q,28794
12
12
  relaxai/_streaming.py,sha256=Nr4O_q1hh35alNVqo46KKf9ZTbRp-IoXjGFCCNJC1fA,10104
13
13
  relaxai/_types.py,sha256=hzXV2igITH7hq2g4zoT8DOcWoTygjpuzRT2OUh1-V1w,6198
14
- relaxai/_version.py,sha256=lBO430l8VQJh2gQ8xBMny3iZoevD2Qjh21tlBGgBU44,159
14
+ relaxai/_version.py,sha256=4h1HBSt0dx8qYwUN2Ebji_vVmZgjJua0hDlUnoJVNmE,159
15
15
  relaxai/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  relaxai/_utils/__init__.py,sha256=PNZ_QJuzZEgyYXqkO1HVhGkj5IU9bglVUcw7H-Knjzw,2062
17
17
  relaxai/_utils/_logs.py,sha256=JN6s4kBek7yKmmZ_YwCsGFuRdVLEaxfgdkCgnJWcFN0,777
@@ -44,7 +44,7 @@ relaxai/types/health_check_response.py,sha256=6Zn5YYHCQf2RgMjDlf39mtiTPqfaBfC9Vv
44
44
  relaxai/types/model.py,sha256=Du9lb9dn846N1fPrKtDsPSLczkqnzxVAJPb8GMqyVJ8,764
45
45
  relaxai/types/model_list_response.py,sha256=zGGRmJLFa5AQ5R2P75E6Qh5wUjtolqcMkXXJTzzy9nA,380
46
46
  relaxai/types/usage.py,sha256=5KaiAggU1xFXDajFkIbHII-RarAiAsJE-4ECBs-AJZg,647
47
- relaxai-0.0.1.dist-info/METADATA,sha256=w10Vj12ufcWqdtpfEOvYvpJiIuDaSprnmj2XJU3_PoA,15002
48
- relaxai-0.0.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
49
- relaxai-0.0.1.dist-info/licenses/LICENSE,sha256=B0u5zBqmaNCfIZooH665f2J7yFqMmSjQxZtnJhCuID8,11337
50
- relaxai-0.0.1.dist-info/RECORD,,
47
+ relaxai-0.1.0.dist-info/METADATA,sha256=kNnG6W_r3tEBG4oBrF5dseHcGBOAICu7tYMLpBOAnYQ,14954
48
+ relaxai-0.1.0.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
49
+ relaxai-0.1.0.dist-info/licenses/LICENSE,sha256=B0u5zBqmaNCfIZooH665f2J7yFqMmSjQxZtnJhCuID8,11337
50
+ relaxai-0.1.0.dist-info/RECORD,,