|
18 | 18 | """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" |
19 | 19 |
|
20 | 20 | from __future__ import annotations |
21 | | -from .. import BaseModel |
| 21 | +from .. import BaseModel, UNSET_SENTINEL, current_exclude_none, serialize_with_info |
22 | 22 | from ...utils import validate_const |
| 23 | +from ..basemodel import current_filtered_dump |
23 | 24 | import pydantic |
| 25 | +from pydantic import model_serializer |
24 | 26 | from pydantic.functional_validators import AfterValidator |
25 | | -from typing import Literal |
26 | | -from typing_extensions import Annotated, TypedDict |
| 27 | +from typing import Literal, Optional |
| 28 | +from typing_extensions import Annotated, NotRequired, TypedDict |
27 | 29 |
|
28 | 30 |
|
29 | 31 | class SmartTranscriptionModeParam(TypedDict): |
30 | 32 | r"""Configuration for smart transcription mode.""" |
31 | 33 |
|
| 34 | + source_text: NotRequired[str] |
| 35 | + r"""The source text to be edited or rewritten via voice instructions. |
| 36 | + When provided, the model performs voice-driven editing and outputs the |
| 37 | + finalized replacement text. |
| 38 | + """ |
32 | 39 | type: Literal["smart"] |
33 | 40 |
|
34 | 41 |
|
35 | 42 | class SmartTranscriptionMode(BaseModel): |
36 | 43 | r"""Configuration for smart transcription mode.""" |
37 | 44 |
|
| 45 | + source_text: Optional[str] = None |
| 46 | + r"""The source text to be edited or rewritten via voice instructions. |
| 47 | + When provided, the model performs voice-driven editing and outputs the |
| 48 | + finalized replacement text. |
| 49 | + """ |
| 50 | + |
38 | 51 | type: Annotated[ |
39 | 52 | Annotated[Literal["smart"], AfterValidator(validate_const("smart"))], |
40 | 53 | pydantic.Field(alias="type"), |
41 | 54 | ] = "smart" |
42 | 55 |
|
| 56 | + @model_serializer(mode="wrap") |
| 57 | + def _serialize_model_with_info(self, handler, info): |
| 58 | + return serialize_with_info(self.serialize_model, handler, info) |
| 59 | + |
| 60 | + def serialize_model(self, handler): |
| 61 | + optional_fields = set(["source_text"]) |
| 62 | + exclude_none = current_exclude_none() |
| 63 | + skip_filtered = exclude_none is False or current_filtered_dump() |
| 64 | + serialized = handler(self) |
| 65 | + m = {} |
| 66 | + |
| 67 | + for n, f in type(self).model_fields.items(): |
| 68 | + k = f.alias if f.alias is not None else n |
| 69 | + if k not in serialized and n not in serialized and skip_filtered: |
| 70 | + continue |
| 71 | + val = serialized.get(k, serialized.get(n)) |
| 72 | + |
| 73 | + if val != UNSET_SENTINEL: |
| 74 | + if val is not None or k not in optional_fields: |
| 75 | + m[k] = val |
| 76 | + |
| 77 | + return m |
| 78 | + |
43 | 79 |
|
44 | 80 | try: |
45 | 81 | SmartTranscriptionMode.model_rebuild() |
|
0 commit comments