From a594aa9007f7f3f104a6646a6e62435bcd6c2af5 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 13:53:14 +0200 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.421.2 (#16) Co-authored-by: speakeasybot --- .speakeasy/gen.lock | 34 +- .speakeasy/gen.yaml | 3 +- .speakeasy/workflow.lock | 12 +- README.md | 1 + RELEASES.md | 12 +- codeSamples.yaml | 22 ++ docs/models/components/bodygenimagetotext.md | 10 + .../components/bodygenimagetotextimage.md | 10 + docs/models/components/imagetotextresponse.md | 10 + .../operations/genimagetotextresponse.md | 9 + docs/sdks/generate/README.md | 48 ++- pyproject.toml | 2 +- src/livepeer_ai/__init__.py | 4 + src/livepeer_ai/_version.py | 12 + src/livepeer_ai/generate.py | 290 ++++++++++++++++-- src/livepeer_ai/models/components/__init__.py | 13 + src/livepeer_ai/models/components/apierror.py | 2 +- .../models/components/body_genaudiototext.py | 4 +- .../models/components/body_genimagetoimage.py | 4 +- .../models/components/body_genimagetotext.py | 57 ++++ .../models/components/body_genimagetovideo.py | 4 +- .../models/components/body_genllm.py | 4 +- .../components/body_gensegmentanything2.py | 4 +- .../models/components/body_genupscale.py | 4 +- src/livepeer_ai/models/components/chunk.py | 3 +- .../models/components/httpmetadata.py | 4 +- .../models/components/imageresponse.py | 3 +- .../models/components/imagetotextresponse.py | 19 ++ .../models/components/llmresponse.py | 2 +- .../models/components/masksresponse.py | 2 +- src/livepeer_ai/models/components/media.py | 2 +- src/livepeer_ai/models/components/security.py | 3 +- .../models/components/textresponse.py | 3 +- .../models/components/texttoimageparams.py | 4 +- .../models/components/validationerror.py | 3 +- .../models/components/videoresponse.py | 3 +- src/livepeer_ai/models/operations/__init__.py | 3 + .../models/operations/genaudiototext.py | 4 +- .../models/operations/genimagetoimage.py | 4 +- .../models/operations/genimagetotext.py | 30 ++ .../models/operations/genimagetovideo.py | 4 +- src/livepeer_ai/models/operations/genllm.py | 4 +- .../models/operations/gensegmentanything2.py | 4 +- .../models/operations/gentexttoimage.py | 4 +- .../models/operations/genupscale.py | 4 +- src/livepeer_ai/sdkconfiguration.py | 8 +- src/livepeer_ai/utils/__init__.py | 8 + src/livepeer_ai/utils/annotations.py | 15 +- src/livepeer_ai/utils/serializers.py | 25 ++ 49 files changed, 647 insertions(+), 96 deletions(-) create mode 100644 docs/models/components/bodygenimagetotext.md create mode 100644 docs/models/components/bodygenimagetotextimage.md create mode 100644 docs/models/components/imagetotextresponse.md create mode 100644 docs/models/operations/genimagetotextresponse.md create mode 100644 src/livepeer_ai/_version.py create mode 100644 src/livepeer_ai/models/components/body_genimagetotext.py create mode 100644 src/livepeer_ai/models/components/imagetotextresponse.py create mode 100644 src/livepeer_ai/models/operations/genimagetotext.py diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 6090f7c..b9eb280 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,19 +1,20 @@ lockVersion: 2.0.0 id: 2d5dbf5a-62be-411a-9c7b-bc7b6dc79e13 management: - docChecksum: 21334b8071b6c8e28a5dda229ceafd7e - speakeasyVersion: 1.405.6 - generationVersion: 2.428.1 - releaseVersion: 0.5.2 - configChecksum: 7327f5aa5f764c498c18bf07efe8face + docChecksum: a140881cbcff74961991f5dfff13f0a0 + docVersion: 0.0.0 + speakeasyVersion: 1.421.2 + generationVersion: 2.438.15 + releaseVersion: 0.6.0 + configChecksum: d4f553b7eab1ee8b7b6de14095ab240f repoURL: https://github.com/livepeer/livepeer-ai-python.git installationURL: https://github.com/livepeer/livepeer-ai-python.git published: true features: python: additionalDependencies: 1.0.0 - constsAndDefaults: 1.0.3 - core: 5.5.7 + constsAndDefaults: 1.0.4 + core: 5.6.0 defaultEnabledRetries: 0.2.0 envVarSecurityUsage: 0.3.1 globalSecurity: 3.0.2 @@ -29,6 +30,7 @@ features: uploadStreams: 1.0.0 generatedFiles: - .gitattributes + - .python-version - .vscode/settings.json - CONTRIBUTING.md - USAGE.md @@ -36,6 +38,8 @@ generatedFiles: - docs/models/components/audio.md - docs/models/components/bodygenaudiototext.md - docs/models/components/bodygenimagetoimage.md + - docs/models/components/bodygenimagetotext.md + - docs/models/components/bodygenimagetotextimage.md - docs/models/components/bodygenimagetovideo.md - docs/models/components/bodygenimagetovideoimage.md - docs/models/components/bodygenllm.md @@ -47,6 +51,7 @@ generatedFiles: - docs/models/components/httpmetadata.md - docs/models/components/image.md - docs/models/components/imageresponse.md + - docs/models/components/imagetotextresponse.md - docs/models/components/llmresponse.md - docs/models/components/loc.md - docs/models/components/masksresponse.md @@ -60,6 +65,7 @@ generatedFiles: - docs/models/errors/httpvalidationerror.md - docs/models/operations/genaudiototextresponse.md - docs/models/operations/genimagetoimageresponse.md + - docs/models/operations/genimagetotextresponse.md - docs/models/operations/genimagetovideoresponse.md - docs/models/operations/genllmresponse.md - docs/models/operations/gensegmentanything2response.md @@ -79,6 +85,7 @@ generatedFiles: - src/livepeer_ai/_hooks/__init__.py - src/livepeer_ai/_hooks/sdkhooks.py - src/livepeer_ai/_hooks/types.py + - src/livepeer_ai/_version.py - src/livepeer_ai/basesdk.py - src/livepeer_ai/generate.py - src/livepeer_ai/httpclient.py @@ -86,6 +93,7 @@ generatedFiles: - src/livepeer_ai/models/components/apierror.py - src/livepeer_ai/models/components/body_genaudiototext.py - src/livepeer_ai/models/components/body_genimagetoimage.py + - src/livepeer_ai/models/components/body_genimagetotext.py - src/livepeer_ai/models/components/body_genimagetovideo.py - src/livepeer_ai/models/components/body_genllm.py - src/livepeer_ai/models/components/body_gensegmentanything2.py @@ -93,6 +101,7 @@ generatedFiles: - src/livepeer_ai/models/components/chunk.py - src/livepeer_ai/models/components/httpmetadata.py - src/livepeer_ai/models/components/imageresponse.py + - src/livepeer_ai/models/components/imagetotextresponse.py - src/livepeer_ai/models/components/llmresponse.py - src/livepeer_ai/models/components/masksresponse.py - src/livepeer_ai/models/components/media.py @@ -108,6 +117,7 @@ generatedFiles: - src/livepeer_ai/models/operations/__init__.py - src/livepeer_ai/models/operations/genaudiototext.py - src/livepeer_ai/models/operations/genimagetoimage.py + - src/livepeer_ai/models/operations/genimagetotext.py - src/livepeer_ai/models/operations/genimagetovideo.py - src/livepeer_ai/models/operations/genllm.py - src/livepeer_ai/models/operations/gensegmentanything2.py @@ -204,3 +214,13 @@ examples: "400": application/json: {"detail": {"msg": ""}} "422": {} + genImageToText: + speakeasy-default-gen-image-to-text: + requestBody: + multipart/form-data: {"image": {}} + responses: + "200": + application/json: {"text": ""} + "400": + application/json: {"detail": {"msg": ""}} + "422": {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 5ef80af..c8f495d 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true python: - version: 0.5.2 + version: 0.6.0 additionalDependencies: dev: {} main: {} @@ -26,6 +26,7 @@ python: responseRequiredSep2024: false flattenGlobalSecurity: true flattenRequests: false + flatteningOrder: parameters-first imports: option: openapi paths: diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index f7c21a4..9329b11 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.405.6 +speakeasyVersion: 1.421.2 sources: livepeer_ai-OAS: sourceNamespace: livepeer-ai-oas - sourceRevisionDigest: sha256:6c083bb976ce725193fa116da1525e922c5cc008dc6f138ca265003b272d1667 - sourceBlobDigest: sha256:1381f76cad0ec28b51d5559fdf87a0b14f39e2946fe25e0c21c0b8b0fe42cf99 + sourceRevisionDigest: sha256:7c2d0e199d6baf10fef5575a8a79a5ee1486404713486f96ded33578ba6d01d1 + sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f tags: - latest - main @@ -16,10 +16,10 @@ targets: livepeer-ai-python: source: livepeer_ai-OAS sourceNamespace: livepeer-ai-oas - sourceRevisionDigest: sha256:6c083bb976ce725193fa116da1525e922c5cc008dc6f138ca265003b272d1667 - sourceBlobDigest: sha256:1381f76cad0ec28b51d5559fdf87a0b14f39e2946fe25e0c21c0b8b0fe42cf99 + sourceRevisionDigest: sha256:7c2d0e199d6baf10fef5575a8a79a5ee1486404713486f96ded33578ba6d01d1 + sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f codeSamplesNamespace: code-samples-python-livepeer-python - codeSamplesRevisionDigest: sha256:2a3c5eac4d47d04d2509592307bd0e451ce09ecacdba64a6638329f2f3286f76 + codeSamplesRevisionDigest: sha256:7cae186a8c5eb7d239ad39407c0ca1c5f2269a0e6e17921baacc1ee895fead94 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index a7951ff..7a0fbfa 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ asyncio.run(main()) * [audio_to_text](docs/sdks/generate/README.md#audio_to_text) - Audio To Text * [segment_anything2](docs/sdks/generate/README.md#segment_anything2) - Segment Anything 2 * [llm](docs/sdks/generate/README.md#llm) - LLM +* [image_to_text](docs/sdks/generate/README.md#image_to_text) - Image To Text diff --git a/RELEASES.md b/RELEASES.md index 41a43ea..0313524 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -88,4 +88,14 @@ Based on: ### Generated - [python v0.5.2] . ### Releases -- [PyPI v0.5.2] https://pypi.org/project/livepeer-ai/0.5.2 - . \ No newline at end of file +- [PyPI v0.5.2] https://pypi.org/project/livepeer-ai/0.5.2 - . + +## 2024-10-25 00:16:56 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.421.2 (2.438.15) https://github.com/speakeasy-api/speakeasy +### Generated +- [python v0.6.0] . +### Releases +- [PyPI v0.6.0] https://pypi.org/project/livepeer-ai/0.6.0 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index b2d35c3..6c05836 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -48,6 +48,28 @@ actions: if res.image_response is not None: # handle response pass + - target: $["paths"]["/image-to-text"]["post"] + update: + x-codeSamples: + - lang: python + label: genImageToText + source: |- + from livepeer_ai import Livepeer + + s = Livepeer( + http_bearer="", + ) + + res = s.generate.image_to_text(request={ + "image": { + "file_name": "example.file", + "content": open("example.file", "rb"), + }, + }) + + if res.image_to_text_response is not None: + # handle response + pass - target: $["paths"]["/image-to-video"]["post"] update: x-codeSamples: diff --git a/docs/models/components/bodygenimagetotext.md b/docs/models/components/bodygenimagetotext.md new file mode 100644 index 0000000..8d02a08 --- /dev/null +++ b/docs/models/components/bodygenimagetotext.md @@ -0,0 +1,10 @@ +# BodyGenImageToText + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `image` | [components.BodyGenImageToTextImage](../../models/components/bodygenimagetotextimage.md) | :heavy_check_mark: | Uploaded image to transform with the pipeline. | +| `prompt` | *Optional[str]* | :heavy_minus_sign: | Text prompt(s) to guide transformation. | +| `model_id` | *Optional[str]* | :heavy_minus_sign: | Hugging Face model ID used for transformation. | \ No newline at end of file diff --git a/docs/models/components/bodygenimagetotextimage.md b/docs/models/components/bodygenimagetotextimage.md new file mode 100644 index 0000000..c76024f --- /dev/null +++ b/docs/models/components/bodygenimagetotextimage.md @@ -0,0 +1,10 @@ +# BodyGenImageToTextImage + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `file_name` | *str* | :heavy_check_mark: | N/A | +| `content` | *Union[bytes, IO[bytes], io.BufferedReader]* | :heavy_check_mark: | N/A | +| `content_type` | *Optional[str]* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/docs/models/components/imagetotextresponse.md b/docs/models/components/imagetotextresponse.md new file mode 100644 index 0000000..0b1a93c --- /dev/null +++ b/docs/models/components/imagetotextresponse.md @@ -0,0 +1,10 @@ +# ImageToTextResponse + +Response model for text generation. + + +## Fields + +| Field | Type | Required | Description | +| ------------------- | ------------------- | ------------------- | ------------------- | +| `text` | *str* | :heavy_check_mark: | The generated text. | \ No newline at end of file diff --git a/docs/models/operations/genimagetotextresponse.md b/docs/models/operations/genimagetotextresponse.md new file mode 100644 index 0000000..ffd2da5 --- /dev/null +++ b/docs/models/operations/genimagetotextresponse.md @@ -0,0 +1,9 @@ +# GenImageToTextResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `http_meta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `image_to_text_response` | [Optional[components.ImageToTextResponse]](../../models/components/imagetotextresponse.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/docs/sdks/generate/README.md b/docs/sdks/generate/README.md index 122bcd0..ad0fb7d 100644 --- a/docs/sdks/generate/README.md +++ b/docs/sdks/generate/README.md @@ -12,6 +12,7 @@ * [audio_to_text](#audio_to_text) - Audio To Text * [segment_anything2](#segment_anything2) - Segment Anything 2 * [llm](#llm) - LLM +* [image_to_text](#image_to_text) - Image To Text ## text_to_image @@ -233,7 +234,7 @@ if res.text_response is not None: | Error Type | Status Code | Content Type | | -------------------------- | -------------------------- | -------------------------- | -| errors.HTTPError | 400, 401, 413, 500 | application/json | +| errors.HTTPError | 400, 401, 413, 415, 500 | application/json | | errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | @@ -322,4 +323,49 @@ if res.llm_response is not None: | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPError | 400, 401, 500 | application/json | | errors.HTTPValidationError | 422 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | + +## image_to_text + +Transform image files to text. + +### Example Usage + +```python +from livepeer_ai import Livepeer + +s = Livepeer( + http_bearer="", +) + +res = s.generate.image_to_text(request={ + "image": { + "file_name": "example.file", + "content": open("example.file", "rb"), + }, +}) + +if res.image_to_text_response is not None: + # handle response + pass + +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `request` | [components.BodyGenImageToText](../../models/components/bodygenimagetotext.md) | :heavy_check_mark: | The request object to use for the request. | +| `retries` | [Optional[utils.RetryConfig]](../../models/utils/retryconfig.md) | :heavy_minus_sign: | Configuration to override the default retry behavior of the client. | + +### Response + +**[operations.GenImageToTextResponse](../../models/operations/genimagetotextresponse.md)** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------- | -------------------------- | -------------------------- | +| errors.HTTPError | 400, 401, 413, 500 | application/json | +| errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 2c45817..e1b6f29 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "livepeer-ai" -version = "0.5.2" +version = "0.6.0" description = "Python Client SDK for the Livepeer AI API." authors = ["Speakeasy",] readme = "README-PYPI.md" diff --git a/src/livepeer_ai/__init__.py b/src/livepeer_ai/__init__.py index d8d60c4..5c34917 100644 --- a/src/livepeer_ai/__init__.py +++ b/src/livepeer_ai/__init__.py @@ -1,4 +1,8 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" +from ._version import __title__, __version__ from .sdk import * from .sdkconfiguration import * + + +VERSION: str = __version__ diff --git a/src/livepeer_ai/_version.py b/src/livepeer_ai/_version.py new file mode 100644 index 0000000..d650997 --- /dev/null +++ b/src/livepeer_ai/_version.py @@ -0,0 +1,12 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +import importlib.metadata + +__title__: str = "livepeer-ai" +__version__: str = "0.6.0" + +try: + if __package__ is not None: + __version__ = importlib.metadata.version(__package__) +except importlib.metadata.PackageNotFoundError: + pass diff --git a/src/livepeer_ai/generate.py b/src/livepeer_ai/generate.py index e803f6e..9ef9617 100644 --- a/src/livepeer_ai/generate.py +++ b/src/livepeer_ai/generate.py @@ -92,15 +92,17 @@ def text_to_image( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -187,15 +189,17 @@ async def text_to_image_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -282,15 +286,17 @@ def image_to_image( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -377,15 +383,17 @@ async def image_to_image_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -472,15 +480,17 @@ def image_to_video( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -567,15 +577,17 @@ async def image_to_video_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -660,15 +672,17 @@ def upscale( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -753,15 +767,17 @@ async def upscale_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -829,7 +845,7 @@ def audio_to_text( security_source=self.sdk_configuration.security, ), request=req, - error_status_codes=["400", "401", "413", "422", "4XX", "500", "5XX"], + error_status_codes=["400", "401", "413", "415", "422", "4XX", "500", "5XX"], retry_config=retry_config, ) @@ -842,7 +858,7 @@ def audio_to_text( http_meta=components.HTTPMetadata(request=req, response=http_res), ) if utils.match_response( - http_res, ["400", "401", "413", "500"], "application/json" + http_res, ["400", "401", "413", "415", "500"], "application/json" ): data = utils.unmarshal_json(http_res.text, errors.HTTPErrorData) raise errors.HTTPError(data=data) @@ -850,15 +866,17 @@ def audio_to_text( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -926,7 +944,7 @@ async def audio_to_text_async( security_source=self.sdk_configuration.security, ), request=req, - error_status_codes=["400", "401", "413", "422", "4XX", "500", "5XX"], + error_status_codes=["400", "401", "413", "415", "422", "4XX", "500", "5XX"], retry_config=retry_config, ) @@ -939,7 +957,7 @@ async def audio_to_text_async( http_meta=components.HTTPMetadata(request=req, response=http_res), ) if utils.match_response( - http_res, ["400", "401", "413", "500"], "application/json" + http_res, ["400", "401", "413", "415", "500"], "application/json" ): data = utils.unmarshal_json(http_res.text, errors.HTTPErrorData) raise errors.HTTPError(data=data) @@ -947,15 +965,17 @@ async def audio_to_text_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -1043,15 +1063,17 @@ def segment_anything2( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -1139,15 +1161,17 @@ async def segment_anything2_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -1232,15 +1256,17 @@ def llm( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) @@ -1325,14 +1351,214 @@ async def llm_async( data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) raise errors.HTTPValidationError(data=data) if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + + content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) + raise errors.SDKError( + f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", + http_res.status_code, + http_res_text, + http_res, + ) + + def image_to_text( + self, + *, + request: Union[ + components.BodyGenImageToText, components.BodyGenImageToTextTypedDict + ], + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + ) -> operations.GenImageToTextResponse: + r"""Image To Text + + Transform image files to text. + + :param request: The request object to send. + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + + if not isinstance(request, BaseModel): + request = utils.unmarshal(request, components.BodyGenImageToText) + request = cast(components.BodyGenImageToText, request) + + req = self.build_request( + method="POST", + path="/image-to-text", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=True, + request_has_path_params=False, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request, False, False, "multipart", components.BodyGenImageToText + ), + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["429", "500", "502", "503", "504"]) + + http_res = self.do_request( + hook_ctx=HookContext( + operation_id="genImageToText", + oauth2_scopes=[], + security_source=self.sdk_configuration.security, + ), + request=req, + error_status_codes=["400", "401", "413", "422", "4XX", "500", "5XX"], + retry_config=retry_config, + ) + + data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return operations.GenImageToTextResponse( + image_to_text_response=utils.unmarshal_json( + http_res.text, Optional[components.ImageToTextResponse] + ), + http_meta=components.HTTPMetadata(request=req, response=http_res), + ) + if utils.match_response( + http_res, ["400", "401", "413", "500"], "application/json" + ): + data = utils.unmarshal_json(http_res.text, errors.HTTPErrorData) + raise errors.HTTPError(data=data) + if utils.match_response(http_res, "422", "application/json"): + data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) + raise errors.HTTPValidationError(data=data) + if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + "API error occurred", http_res.status_code, http_res_text, http_res + ) + + content_type = http_res.headers.get("Content-Type") + http_res_text = utils.stream_to_text(http_res) + raise errors.SDKError( + f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", + http_res.status_code, + http_res_text, + http_res, + ) + + async def image_to_text_async( + self, + *, + request: Union[ + components.BodyGenImageToText, components.BodyGenImageToTextTypedDict + ], + retries: OptionalNullable[utils.RetryConfig] = UNSET, + server_url: Optional[str] = None, + timeout_ms: Optional[int] = None, + ) -> operations.GenImageToTextResponse: + r"""Image To Text + + Transform image files to text. + + :param request: The request object to send. + :param retries: Override the default retry configuration for this method + :param server_url: Override the default server URL for this method + :param timeout_ms: Override the default request timeout configuration for this method in milliseconds + """ + base_url = None + url_variables = None + if timeout_ms is None: + timeout_ms = self.sdk_configuration.timeout_ms + + if server_url is not None: + base_url = server_url + + if not isinstance(request, BaseModel): + request = utils.unmarshal(request, components.BodyGenImageToText) + request = cast(components.BodyGenImageToText, request) + + req = self.build_request_async( + method="POST", + path="/image-to-text", + base_url=base_url, + url_variables=url_variables, + request=request, + request_body_required=True, + request_has_path_params=False, + request_has_query_params=True, + user_agent_header="user-agent", + accept_header_value="application/json", + security=self.sdk_configuration.security, + get_serialized_body=lambda: utils.serialize_request_body( + request, False, False, "multipart", components.BodyGenImageToText + ), + timeout_ms=timeout_ms, + ) + + if retries == UNSET: + if self.sdk_configuration.retry_config is not UNSET: + retries = self.sdk_configuration.retry_config + + retry_config = None + if isinstance(retries, utils.RetryConfig): + retry_config = (retries, ["429", "500", "502", "503", "504"]) + + http_res = await self.do_request_async( + hook_ctx=HookContext( + operation_id="genImageToText", + oauth2_scopes=[], + security_source=self.sdk_configuration.security, + ), + request=req, + error_status_codes=["400", "401", "413", "422", "4XX", "500", "5XX"], + retry_config=retry_config, + ) + + data: Any = None + if utils.match_response(http_res, "200", "application/json"): + return operations.GenImageToTextResponse( + image_to_text_response=utils.unmarshal_json( + http_res.text, Optional[components.ImageToTextResponse] + ), + http_meta=components.HTTPMetadata(request=req, response=http_res), + ) + if utils.match_response( + http_res, ["400", "401", "413", "500"], "application/json" + ): + data = utils.unmarshal_json(http_res.text, errors.HTTPErrorData) + raise errors.HTTPError(data=data) + if utils.match_response(http_res, "422", "application/json"): + data = utils.unmarshal_json(http_res.text, errors.HTTPValidationErrorData) + raise errors.HTTPValidationError(data=data) + if utils.match_response(http_res, ["4XX", "5XX"], "*"): + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( - "API error occurred", http_res.status_code, http_res.text, http_res + "API error occurred", http_res.status_code, http_res_text, http_res ) content_type = http_res.headers.get("Content-Type") + http_res_text = await utils.stream_to_text_async(http_res) raise errors.SDKError( f"Unexpected response received (code: {http_res.status_code}, type: {content_type})", http_res.status_code, - http_res.text, + http_res_text, http_res, ) diff --git a/src/livepeer_ai/models/components/__init__.py b/src/livepeer_ai/models/components/__init__.py index 093587b..aea7955 100644 --- a/src/livepeer_ai/models/components/__init__.py +++ b/src/livepeer_ai/models/components/__init__.py @@ -13,6 +13,12 @@ Image, ImageTypedDict, ) +from .body_genimagetotext import ( + BodyGenImageToText, + BodyGenImageToTextImage, + BodyGenImageToTextImageTypedDict, + BodyGenImageToTextTypedDict, +) from .body_genimagetovideo import ( BodyGenImageToVideo, BodyGenImageToVideoImage, @@ -35,6 +41,7 @@ from .chunk import Chunk, ChunkTypedDict from .httpmetadata import HTTPMetadata, HTTPMetadataTypedDict from .imageresponse import ImageResponse, ImageResponseTypedDict +from .imagetotextresponse import ImageToTextResponse, ImageToTextResponseTypedDict from .llmresponse import LLMResponse, LLMResponseTypedDict from .masksresponse import MasksResponse, MasksResponseTypedDict from .media import Media, MediaTypedDict @@ -58,6 +65,10 @@ "BodyGenAudioToTextTypedDict", "BodyGenImageToImage", "BodyGenImageToImageTypedDict", + "BodyGenImageToText", + "BodyGenImageToTextImage", + "BodyGenImageToTextImageTypedDict", + "BodyGenImageToTextTypedDict", "BodyGenImageToVideo", "BodyGenImageToVideoImage", "BodyGenImageToVideoImageTypedDict", @@ -79,6 +90,8 @@ "Image", "ImageResponse", "ImageResponseTypedDict", + "ImageToTextResponse", + "ImageToTextResponseTypedDict", "ImageTypedDict", "LLMResponse", "LLMResponseTypedDict", diff --git a/src/livepeer_ai/models/components/apierror.py b/src/livepeer_ai/models/components/apierror.py index 2a265ce..9fe49e5 100644 --- a/src/livepeer_ai/models/components/apierror.py +++ b/src/livepeer_ai/models/components/apierror.py @@ -2,7 +2,7 @@ from __future__ import annotations from livepeer_ai.types import BaseModel -from typing import TypedDict +from typing_extensions import TypedDict class APIErrorTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/body_genaudiototext.py b/src/livepeer_ai/models/components/body_genaudiototext.py index 325a30c..ac850ff 100644 --- a/src/livepeer_ai/models/components/body_genaudiototext.py +++ b/src/livepeer_ai/models/components/body_genaudiototext.py @@ -5,8 +5,8 @@ from livepeer_ai.types import BaseModel from livepeer_ai.utils import FieldMetadata, MultipartFormMetadata import pydantic -from typing import IO, Optional, TypedDict, Union -from typing_extensions import Annotated, NotRequired +from typing import IO, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict class AudioTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/body_genimagetoimage.py b/src/livepeer_ai/models/components/body_genimagetoimage.py index 7298ab4..f490bb5 100644 --- a/src/livepeer_ai/models/components/body_genimagetoimage.py +++ b/src/livepeer_ai/models/components/body_genimagetoimage.py @@ -5,8 +5,8 @@ from livepeer_ai.types import BaseModel from livepeer_ai.utils import FieldMetadata, MultipartFormMetadata import pydantic -from typing import IO, Optional, TypedDict, Union -from typing_extensions import Annotated, NotRequired +from typing import IO, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict class ImageTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/body_genimagetotext.py b/src/livepeer_ai/models/components/body_genimagetotext.py new file mode 100644 index 0000000..63ed6bf --- /dev/null +++ b/src/livepeer_ai/models/components/body_genimagetotext.py @@ -0,0 +1,57 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +import io +from livepeer_ai.types import BaseModel +from livepeer_ai.utils import FieldMetadata, MultipartFormMetadata +import pydantic +from typing import IO, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict + + +class BodyGenImageToTextImageTypedDict(TypedDict): + file_name: str + content: Union[bytes, IO[bytes], io.BufferedReader] + content_type: NotRequired[str] + + +class BodyGenImageToTextImage(BaseModel): + file_name: Annotated[ + str, pydantic.Field(alias="image"), FieldMetadata(multipart=True) + ] + + content: Annotated[ + Union[bytes, IO[bytes], io.BufferedReader], + pydantic.Field(alias=""), + FieldMetadata(multipart=MultipartFormMetadata(content=True)), + ] + + content_type: Annotated[ + Optional[str], + pydantic.Field(alias="Content-Type"), + FieldMetadata(multipart=True), + ] = None + + +class BodyGenImageToTextTypedDict(TypedDict): + image: BodyGenImageToTextImageTypedDict + r"""Uploaded image to transform with the pipeline.""" + prompt: NotRequired[str] + r"""Text prompt(s) to guide transformation.""" + model_id: NotRequired[str] + r"""Hugging Face model ID used for transformation.""" + + +class BodyGenImageToText(BaseModel): + image: Annotated[ + BodyGenImageToTextImage, + pydantic.Field(alias=""), + FieldMetadata(multipart=MultipartFormMetadata(file=True)), + ] + r"""Uploaded image to transform with the pipeline.""" + + prompt: Annotated[Optional[str], FieldMetadata(multipart=True)] = "" + r"""Text prompt(s) to guide transformation.""" + + model_id: Annotated[Optional[str], FieldMetadata(multipart=True)] = "" + r"""Hugging Face model ID used for transformation.""" diff --git a/src/livepeer_ai/models/components/body_genimagetovideo.py b/src/livepeer_ai/models/components/body_genimagetovideo.py index 3c5102f..b5883bb 100644 --- a/src/livepeer_ai/models/components/body_genimagetovideo.py +++ b/src/livepeer_ai/models/components/body_genimagetovideo.py @@ -5,8 +5,8 @@ from livepeer_ai.types import BaseModel from livepeer_ai.utils import FieldMetadata, MultipartFormMetadata import pydantic -from typing import IO, Optional, TypedDict, Union -from typing_extensions import Annotated, NotRequired +from typing import IO, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict class BodyGenImageToVideoImageTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/body_genllm.py b/src/livepeer_ai/models/components/body_genllm.py index 6efc188..14ecff9 100644 --- a/src/livepeer_ai/models/components/body_genllm.py +++ b/src/livepeer_ai/models/components/body_genllm.py @@ -3,8 +3,8 @@ from __future__ import annotations from livepeer_ai.types import BaseModel from livepeer_ai.utils import FieldMetadata -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class BodyGenLLMTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/body_gensegmentanything2.py b/src/livepeer_ai/models/components/body_gensegmentanything2.py index ee68c1f..d9ecadd 100644 --- a/src/livepeer_ai/models/components/body_gensegmentanything2.py +++ b/src/livepeer_ai/models/components/body_gensegmentanything2.py @@ -5,8 +5,8 @@ from livepeer_ai.types import BaseModel from livepeer_ai.utils import FieldMetadata, MultipartFormMetadata import pydantic -from typing import IO, Optional, TypedDict, Union -from typing_extensions import Annotated, NotRequired +from typing import IO, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict class BodyGenSegmentAnything2ImageTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/body_genupscale.py b/src/livepeer_ai/models/components/body_genupscale.py index d03c549..1b6b3b5 100644 --- a/src/livepeer_ai/models/components/body_genupscale.py +++ b/src/livepeer_ai/models/components/body_genupscale.py @@ -5,8 +5,8 @@ from livepeer_ai.types import BaseModel from livepeer_ai.utils import FieldMetadata, MultipartFormMetadata import pydantic -from typing import IO, Optional, TypedDict, Union -from typing_extensions import Annotated, NotRequired +from typing import IO, Optional, Union +from typing_extensions import Annotated, NotRequired, TypedDict class BodyGenUpscaleImageTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/chunk.py b/src/livepeer_ai/models/components/chunk.py index 61f8757..ee398c9 100644 --- a/src/livepeer_ai/models/components/chunk.py +++ b/src/livepeer_ai/models/components/chunk.py @@ -2,7 +2,8 @@ from __future__ import annotations from livepeer_ai.types import BaseModel -from typing import Any, List, TypedDict +from typing import Any, List +from typing_extensions import TypedDict class ChunkTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/httpmetadata.py b/src/livepeer_ai/models/components/httpmetadata.py index 3269e79..f22b604 100644 --- a/src/livepeer_ai/models/components/httpmetadata.py +++ b/src/livepeer_ai/models/components/httpmetadata.py @@ -4,8 +4,8 @@ import httpx from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated +from typing import Optional +from typing_extensions import Annotated, TypedDict class HTTPMetadataTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/imageresponse.py b/src/livepeer_ai/models/components/imageresponse.py index c2b9ed3..723fd8f 100644 --- a/src/livepeer_ai/models/components/imageresponse.py +++ b/src/livepeer_ai/models/components/imageresponse.py @@ -3,7 +3,8 @@ from __future__ import annotations from .media import Media, MediaTypedDict from livepeer_ai.types import BaseModel -from typing import List, TypedDict +from typing import List +from typing_extensions import TypedDict class ImageResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/imagetotextresponse.py b/src/livepeer_ai/models/components/imagetotextresponse.py new file mode 100644 index 0000000..c6d4180 --- /dev/null +++ b/src/livepeer_ai/models/components/imagetotextresponse.py @@ -0,0 +1,19 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from livepeer_ai.types import BaseModel +from typing_extensions import TypedDict + + +class ImageToTextResponseTypedDict(TypedDict): + r"""Response model for text generation.""" + + text: str + r"""The generated text.""" + + +class ImageToTextResponse(BaseModel): + r"""Response model for text generation.""" + + text: str + r"""The generated text.""" diff --git a/src/livepeer_ai/models/components/llmresponse.py b/src/livepeer_ai/models/components/llmresponse.py index 3b165e7..5a53642 100644 --- a/src/livepeer_ai/models/components/llmresponse.py +++ b/src/livepeer_ai/models/components/llmresponse.py @@ -2,7 +2,7 @@ from __future__ import annotations from livepeer_ai.types import BaseModel -from typing import TypedDict +from typing_extensions import TypedDict class LLMResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/masksresponse.py b/src/livepeer_ai/models/components/masksresponse.py index 4f00a02..4ec6a74 100644 --- a/src/livepeer_ai/models/components/masksresponse.py +++ b/src/livepeer_ai/models/components/masksresponse.py @@ -2,7 +2,7 @@ from __future__ import annotations from livepeer_ai.types import BaseModel -from typing import TypedDict +from typing_extensions import TypedDict class MasksResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/media.py b/src/livepeer_ai/models/components/media.py index 106de18..458852e 100644 --- a/src/livepeer_ai/models/components/media.py +++ b/src/livepeer_ai/models/components/media.py @@ -2,7 +2,7 @@ from __future__ import annotations from livepeer_ai.types import BaseModel -from typing import TypedDict +from typing_extensions import TypedDict class MediaTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/security.py b/src/livepeer_ai/models/components/security.py index 680b40e..c8c6d3b 100644 --- a/src/livepeer_ai/models/components/security.py +++ b/src/livepeer_ai/models/components/security.py @@ -3,8 +3,7 @@ from __future__ import annotations from livepeer_ai.types import BaseModel from livepeer_ai.utils import FieldMetadata, SecurityMetadata -from typing import TypedDict -from typing_extensions import Annotated +from typing_extensions import Annotated, TypedDict class SecurityTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/textresponse.py b/src/livepeer_ai/models/components/textresponse.py index 91e885d..b98e23a 100644 --- a/src/livepeer_ai/models/components/textresponse.py +++ b/src/livepeer_ai/models/components/textresponse.py @@ -3,7 +3,8 @@ from __future__ import annotations from .chunk import Chunk, ChunkTypedDict from livepeer_ai.types import BaseModel -from typing import List, TypedDict +from typing import List +from typing_extensions import TypedDict class TextResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/texttoimageparams.py b/src/livepeer_ai/models/components/texttoimageparams.py index 2832a58..c4db985 100644 --- a/src/livepeer_ai/models/components/texttoimageparams.py +++ b/src/livepeer_ai/models/components/texttoimageparams.py @@ -2,8 +2,8 @@ from __future__ import annotations from livepeer_ai.types import BaseModel -from typing import Optional, TypedDict -from typing_extensions import NotRequired +from typing import Optional +from typing_extensions import NotRequired, TypedDict class TextToImageParamsTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/components/validationerror.py b/src/livepeer_ai/models/components/validationerror.py index 980f265..6637ea3 100644 --- a/src/livepeer_ai/models/components/validationerror.py +++ b/src/livepeer_ai/models/components/validationerror.py @@ -2,7 +2,8 @@ from __future__ import annotations from livepeer_ai.types import BaseModel -from typing import List, TypedDict, Union +from typing import List, Union +from typing_extensions import TypedDict LocTypedDict = Union[str, int] diff --git a/src/livepeer_ai/models/components/videoresponse.py b/src/livepeer_ai/models/components/videoresponse.py index e8a8f99..00ee4b4 100644 --- a/src/livepeer_ai/models/components/videoresponse.py +++ b/src/livepeer_ai/models/components/videoresponse.py @@ -3,7 +3,8 @@ from __future__ import annotations from .media import Media, MediaTypedDict from livepeer_ai.types import BaseModel -from typing import List, TypedDict +from typing import List +from typing_extensions import TypedDict class VideoResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/operations/__init__.py b/src/livepeer_ai/models/operations/__init__.py index 6984013..edfb961 100644 --- a/src/livepeer_ai/models/operations/__init__.py +++ b/src/livepeer_ai/models/operations/__init__.py @@ -2,6 +2,7 @@ from .genaudiototext import GenAudioToTextResponse, GenAudioToTextResponseTypedDict from .genimagetoimage import GenImageToImageResponse, GenImageToImageResponseTypedDict +from .genimagetotext import GenImageToTextResponse, GenImageToTextResponseTypedDict from .genimagetovideo import GenImageToVideoResponse, GenImageToVideoResponseTypedDict from .genllm import GenLLMResponse, GenLLMResponseTypedDict from .gensegmentanything2 import ( @@ -16,6 +17,8 @@ "GenAudioToTextResponseTypedDict", "GenImageToImageResponse", "GenImageToImageResponseTypedDict", + "GenImageToTextResponse", + "GenImageToTextResponseTypedDict", "GenImageToVideoResponse", "GenImageToVideoResponseTypedDict", "GenLLMResponse", diff --git a/src/livepeer_ai/models/operations/genaudiototext.py b/src/livepeer_ai/models/operations/genaudiototext.py index 6db5432..f803a91 100644 --- a/src/livepeer_ai/models/operations/genaudiototext.py +++ b/src/livepeer_ai/models/operations/genaudiototext.py @@ -7,8 +7,8 @@ ) from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class GenAudioToTextResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/operations/genimagetoimage.py b/src/livepeer_ai/models/operations/genimagetoimage.py index cd70ca7..7bc5eb8 100644 --- a/src/livepeer_ai/models/operations/genimagetoimage.py +++ b/src/livepeer_ai/models/operations/genimagetoimage.py @@ -7,8 +7,8 @@ ) from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class GenImageToImageResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/operations/genimagetotext.py b/src/livepeer_ai/models/operations/genimagetotext.py new file mode 100644 index 0000000..0b490e3 --- /dev/null +++ b/src/livepeer_ai/models/operations/genimagetotext.py @@ -0,0 +1,30 @@ +"""Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" + +from __future__ import annotations +from livepeer_ai.models.components import ( + httpmetadata as components_httpmetadata, + imagetotextresponse as components_imagetotextresponse, +) +from livepeer_ai.types import BaseModel +import pydantic +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict + + +class GenImageToTextResponseTypedDict(TypedDict): + http_meta: components_httpmetadata.HTTPMetadataTypedDict + image_to_text_response: NotRequired[ + components_imagetotextresponse.ImageToTextResponseTypedDict + ] + r"""Successful Response""" + + +class GenImageToTextResponse(BaseModel): + http_meta: Annotated[ + Optional[components_httpmetadata.HTTPMetadata], pydantic.Field(exclude=True) + ] = None + + image_to_text_response: Optional[ + components_imagetotextresponse.ImageToTextResponse + ] = None + r"""Successful Response""" diff --git a/src/livepeer_ai/models/operations/genimagetovideo.py b/src/livepeer_ai/models/operations/genimagetovideo.py index 8d71d0e..6c151a0 100644 --- a/src/livepeer_ai/models/operations/genimagetovideo.py +++ b/src/livepeer_ai/models/operations/genimagetovideo.py @@ -7,8 +7,8 @@ ) from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class GenImageToVideoResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/operations/genllm.py b/src/livepeer_ai/models/operations/genllm.py index f2c420f..a4714f9 100644 --- a/src/livepeer_ai/models/operations/genllm.py +++ b/src/livepeer_ai/models/operations/genllm.py @@ -7,8 +7,8 @@ ) from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class GenLLMResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/operations/gensegmentanything2.py b/src/livepeer_ai/models/operations/gensegmentanything2.py index 7b597cb..066fe67 100644 --- a/src/livepeer_ai/models/operations/gensegmentanything2.py +++ b/src/livepeer_ai/models/operations/gensegmentanything2.py @@ -7,8 +7,8 @@ ) from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class GenSegmentAnything2ResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/operations/gentexttoimage.py b/src/livepeer_ai/models/operations/gentexttoimage.py index 79bbcd4..4b9a34a 100644 --- a/src/livepeer_ai/models/operations/gentexttoimage.py +++ b/src/livepeer_ai/models/operations/gentexttoimage.py @@ -7,8 +7,8 @@ ) from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class GenTextToImageResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/models/operations/genupscale.py b/src/livepeer_ai/models/operations/genupscale.py index ce288bb..7f3809e 100644 --- a/src/livepeer_ai/models/operations/genupscale.py +++ b/src/livepeer_ai/models/operations/genupscale.py @@ -7,8 +7,8 @@ ) from livepeer_ai.types import BaseModel import pydantic -from typing import Optional, TypedDict -from typing_extensions import Annotated, NotRequired +from typing import Optional +from typing_extensions import Annotated, NotRequired, TypedDict class GenUpscaleResponseTypedDict(TypedDict): diff --git a/src/livepeer_ai/sdkconfiguration.py b/src/livepeer_ai/sdkconfiguration.py index fd3cb67..1355522 100644 --- a/src/livepeer_ai/sdkconfiguration.py +++ b/src/livepeer_ai/sdkconfiguration.py @@ -30,10 +30,10 @@ class SDKConfiguration: server_url: Optional[str] = "" server_idx: Optional[int] = 0 language: str = "python" - openapi_doc_version: str = "" - sdk_version: str = "0.5.2" - gen_version: str = "2.428.1" - user_agent: str = "speakeasy-sdk/python 0.5.2 2.428.1 livepeer-ai" + openapi_doc_version: str = "0.0.0" + sdk_version: str = "0.6.0" + gen_version: str = "2.438.15" + user_agent: str = "speakeasy-sdk/python 0.6.0 2.438.15 0.0.0 livepeer-ai" retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET) timeout_ms: Optional[int] = None diff --git a/src/livepeer_ai/utils/__init__.py b/src/livepeer_ai/utils/__init__.py index 6c26aeb..26d51ae 100644 --- a/src/livepeer_ai/utils/__init__.py +++ b/src/livepeer_ai/utils/__init__.py @@ -27,6 +27,10 @@ serialize_float, serialize_int, stream_to_text, + stream_to_text_async, + stream_to_bytes, + stream_to_bytes_async, + validate_const, validate_decimal, validate_float, validate_int, @@ -79,10 +83,14 @@ "serialize_request_body", "SerializedRequestBody", "stream_to_text", + "stream_to_text_async", + "stream_to_bytes", + "stream_to_bytes_async", "template_url", "unmarshal", "unmarshal_json", "validate_decimal", + "validate_const", "validate_float", "validate_int", "validate_open_enum", diff --git a/src/livepeer_ai/utils/annotations.py b/src/livepeer_ai/utils/annotations.py index 0d17472..5b3bbb0 100644 --- a/src/livepeer_ai/utils/annotations.py +++ b/src/livepeer_ai/utils/annotations.py @@ -1,5 +1,6 @@ """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.""" +from enum import Enum from typing import Any def get_discriminator(model: Any, fieldname: str, key: str) -> str: @@ -10,10 +11,20 @@ def get_discriminator(model: Any, fieldname: str, key: str) -> str: raise ValueError(f'Could not find discriminator key {key} in {model}') from e if hasattr(model, fieldname): - return f'{getattr(model, fieldname)}' + attr = getattr(model, fieldname) + + if isinstance(attr, Enum): + return f'{attr.value}' + + return f'{attr}' fieldname = fieldname.upper() if hasattr(model, fieldname): - return f'{getattr(model, fieldname)}' + attr = getattr(model, fieldname) + + if isinstance(attr, Enum): + return f'{attr.value}' + + return f'{attr}' raise ValueError(f'Could not find discriminator field {fieldname} in {model}') diff --git a/src/livepeer_ai/utils/serializers.py b/src/livepeer_ai/utils/serializers.py index 85d57f4..c5eb365 100644 --- a/src/livepeer_ai/utils/serializers.py +++ b/src/livepeer_ai/utils/serializers.py @@ -116,6 +116,19 @@ def validate(e): return validate +def validate_const(v): + def validate(c): + if is_optional_type(type(c)) and c is None: + return None + + if v != c: + raise ValueError(f"Expected {v}") + + return c + + return validate + + def unmarshal_json(raw, typ: Any) -> Any: return unmarshal(from_json(raw), typ) @@ -172,6 +185,18 @@ def stream_to_text(stream: httpx.Response) -> str: return "".join(stream.iter_text()) +async def stream_to_text_async(stream: httpx.Response) -> str: + return "".join([chunk async for chunk in stream.aiter_text()]) + + +def stream_to_bytes(stream: httpx.Response) -> bytes: + return stream.content + + +async def stream_to_bytes_async(stream: httpx.Response) -> bytes: + return await stream.aread() + + def get_pydantic_model(data: Any, typ: Any) -> Any: if not _contains_pydantic_model(data): return unmarshal(data, typ)