From 653c9c9f5a278d4e498e2f60a510e49dc5fd4448 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 7 Nov 2024 08:36:22 +0100 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.434.0 (#21) Co-authored-by: speakeasybot --- .speakeasy/gen.lock | 54 +++++- .speakeasy/gen.yaml | 3 +- .speakeasy/workflow.lock | 12 +- README.md | 4 + RELEASES.md | 12 +- codeSamples.yaml | 43 +++++ docs/models/components/audioresponse.md | 21 +++ docs/models/components/bodygenaudiototext.md | 9 +- docs/models/components/imageresponse.md | 4 +- .../components/livevideotovideoparams.md | 21 +++ .../components/livevideotovideoresponse.md | 21 +++ docs/models/components/llmresponse.md | 2 +- docs/models/components/loc.md | 2 +- docs/models/components/media.md | 4 +- docs/models/components/mediaurl.md | 19 +++ docs/models/components/params.md | 16 ++ docs/models/components/texttospeechparams.md | 17 ++ docs/models/components/validationerror.md | 2 +- docs/models/components/videoresponse.md | 4 +- .../operations/genlivevideotovideoresponse.md | 24 +++ .../operations/gentexttospeechresponse.md | 24 +++ docs/sdks/generate/README.md | 156 ++++++++++++++++++ jsr.json | 2 +- package-lock.json | 4 +- package.json | 2 +- src/funcs/generateAudioToText.ts | 15 +- src/funcs/generateImageToImage.ts | 12 +- src/funcs/generateImageToText.ts | 12 +- src/funcs/generateImageToVideo.ts | 12 +- src/funcs/generateLiveVideoToVideo.ts | 138 ++++++++++++++++ src/funcs/generateLlm.ts | 12 +- src/funcs/generateSegmentAnything2.ts | 12 +- src/funcs/generateTextToImage.ts | 12 +- src/funcs/generateTextToSpeech.ts | 138 ++++++++++++++++ src/funcs/generateUpscale.ts | 12 +- src/hooks/types.ts | 2 + src/lib/config.ts | 6 +- src/lib/retries.ts | 94 +++++++---- src/lib/sdks.ts | 34 ++-- src/models/components/audioresponse.ts | 57 +++++++ src/models/components/bodygenaudiototext.ts | 9 + src/models/components/index.ts | 5 + .../components/livevideotovideoparams.ts | 114 +++++++++++++ .../components/livevideotovideoresponse.ts | 69 ++++++++ src/models/components/mediaurl.ts | 51 ++++++ src/models/components/texttospeechparams.ts | 75 +++++++++ src/models/operations/genlivevideotovideo.ts | 91 ++++++++++ src/models/operations/gentexttospeech.ts | 87 ++++++++++ src/models/operations/index.ts | 2 + src/sdk/generate.ts | 36 ++++ 50 files changed, 1474 insertions(+), 115 deletions(-) create mode 100644 docs/models/components/audioresponse.md create mode 100644 docs/models/components/livevideotovideoparams.md create mode 100644 docs/models/components/livevideotovideoresponse.md create mode 100644 docs/models/components/mediaurl.md create mode 100644 docs/models/components/params.md create mode 100644 docs/models/components/texttospeechparams.md create mode 100644 docs/models/operations/genlivevideotovideoresponse.md create mode 100644 docs/models/operations/gentexttospeechresponse.md create mode 100644 src/funcs/generateLiveVideoToVideo.ts create mode 100644 src/funcs/generateTextToSpeech.ts create mode 100644 src/models/components/audioresponse.ts create mode 100644 src/models/components/livevideotovideoparams.ts create mode 100644 src/models/components/livevideotovideoresponse.ts create mode 100644 src/models/components/mediaurl.ts create mode 100644 src/models/components/texttospeechparams.ts create mode 100644 src/models/operations/genlivevideotovideo.ts create mode 100644 src/models/operations/gentexttospeech.ts diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index 02b2cc3..23b4f82 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 8bd6d3b6-cae6-4e55-b72f-6fdc1dbce9a1 management: - docChecksum: a140881cbcff74961991f5dfff13f0a0 + docChecksum: c22f8c1b01f75ba608165e53e64fb450 docVersion: 0.0.0 - speakeasyVersion: 1.421.2 - generationVersion: 2.438.15 - releaseVersion: 0.4.1 - configChecksum: 2d2321dd652b40627a863461eab6e343 + speakeasyVersion: 1.434.0 + generationVersion: 2.452.0 + releaseVersion: 0.5.0 + configChecksum: aedc0e9ba8ffdca9aa407f90c308a96c repoURL: https://github.com/livepeer/livepeer-ai-js.git installationURL: https://github.com/livepeer/livepeer-ai-js published: true @@ -14,9 +14,9 @@ features: typescript: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.11 - core: 3.18.2 + core: 3.18.3 defaultEnabledRetries: 0.1.0 - envVarSecurityUsage: 0.1.1 + envVarSecurityUsage: 0.1.2 globalSecurity: 2.82.11 globalSecurityCallbacks: 0.1.0 globalSecurityFlattening: 0.1.0 @@ -24,8 +24,9 @@ features: nameOverrides: 2.81.2 responseFormat: 0.2.3 retries: 2.83.0 - sdkHooks: 0.1.0 - unions: 2.85.7 + sdkHooks: 0.2.0 + tests: 0.7.0 + unions: 2.85.8 uploadStreams: 0.1.0 generatedFiles: - .eslintrc.cjs @@ -37,6 +38,7 @@ generatedFiles: - docs/lib/utils/retryconfig.md - docs/models/components/apierror.md - docs/models/components/audio.md + - docs/models/components/audioresponse.md - docs/models/components/bodygenaudiototext.md - docs/models/components/bodygenimagetoimage.md - docs/models/components/bodygenimagetotext.md @@ -52,13 +54,18 @@ generatedFiles: - docs/models/components/image.md - docs/models/components/imageresponse.md - docs/models/components/imagetotextresponse.md + - docs/models/components/livevideotovideoparams.md + - docs/models/components/livevideotovideoresponse.md - docs/models/components/llmresponse.md - docs/models/components/loc.md - docs/models/components/masksresponse.md - docs/models/components/media.md + - docs/models/components/mediaurl.md + - docs/models/components/params.md - docs/models/components/security.md - docs/models/components/textresponse.md - docs/models/components/texttoimageparams.md + - docs/models/components/texttospeechparams.md - docs/models/components/validationerror.md - docs/models/components/videoresponse.md - docs/models/errors/httperror.md @@ -67,9 +74,11 @@ generatedFiles: - docs/models/operations/genimagetoimageresponse.md - docs/models/operations/genimagetotextresponse.md - docs/models/operations/genimagetovideoresponse.md + - docs/models/operations/genlivevideotovideoresponse.md - docs/models/operations/genllmresponse.md - docs/models/operations/gensegmentanything2response.md - docs/models/operations/gentexttoimageresponse.md + - docs/models/operations/gentexttospeechresponse.md - docs/models/operations/genupscaleresponse.md - docs/sdks/generate/README.md - docs/sdks/livepeer/README.md @@ -80,9 +89,11 @@ generatedFiles: - src/funcs/generateImageToImage.ts - src/funcs/generateImageToText.ts - src/funcs/generateImageToVideo.ts + - src/funcs/generateLiveVideoToVideo.ts - src/funcs/generateLlm.ts - src/funcs/generateSegmentAnything2.ts - src/funcs/generateTextToImage.ts + - src/funcs/generateTextToSpeech.ts - src/funcs/generateUpscale.ts - src/hooks/hooks.ts - src/hooks/index.ts @@ -104,6 +115,7 @@ generatedFiles: - src/lib/security.ts - src/lib/url.ts - src/models/components/apierror.ts + - src/models/components/audioresponse.ts - src/models/components/bodygenaudiototext.ts - src/models/components/bodygenimagetoimage.ts - src/models/components/bodygenimagetotext.ts @@ -115,12 +127,16 @@ generatedFiles: - src/models/components/imageresponse.ts - src/models/components/imagetotextresponse.ts - src/models/components/index.ts + - src/models/components/livevideotovideoparams.ts + - src/models/components/livevideotovideoresponse.ts - src/models/components/llmresponse.ts - src/models/components/masksresponse.ts - src/models/components/media.ts + - src/models/components/mediaurl.ts - src/models/components/security.ts - src/models/components/textresponse.ts - src/models/components/texttoimageparams.ts + - src/models/components/texttospeechparams.ts - src/models/components/validationerror.ts - src/models/components/videoresponse.ts - src/models/errors/httpclienterrors.ts @@ -133,9 +149,11 @@ generatedFiles: - src/models/operations/genimagetoimage.ts - src/models/operations/genimagetotext.ts - src/models/operations/genimagetovideo.ts + - src/models/operations/genlivevideotovideo.ts - src/models/operations/genllm.ts - src/models/operations/gensegmentanything2.ts - src/models/operations/gentexttoimage.ts + - src/models/operations/gentexttospeech.ts - src/models/operations/genupscale.ts - src/models/operations/index.ts - src/sdk/generate.ts @@ -231,3 +249,21 @@ examples: "400": application/json: {"detail": {"msg": ""}} "422": {} + genLiveVideoToVideo: + speakeasy-default-gen-live-video-to-video: + requestBody: + application/json: {"subscribe_url": "https://soulful-lava.org/", "publish_url": "https://vain-tabletop.biz"} + responses: + "200": + application/json: {"subscribe_url": "https://vain-kiss.name", "publish_url": "https://frail-duffel.com"} + "400": + application/json: {"detail": {"msg": ""}} + "422": {} + genTextToSpeech: + speakeasy-default-gen-text-to-speech: + responses: + "200": + application/json: {"audio": {"url": "https://accurate-parsnip.net/"}} + "400": + application/json: {"detail": {"msg": ""}} + "422": {} diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index 4d88e33..01008d6 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -10,8 +10,9 @@ generation: requestResponseComponentNamesFeb2024: false auth: oAuth2ClientCredentialsEnabled: false + oAuth2PasswordEnabled: false typescript: - version: 0.4.1 + version: 0.5.0 additionalDependencies: dependencies: jest: ^29.7.0 diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 635d027..452f6ba 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.421.2 +speakeasyVersion: 1.434.0 sources: livepeer-ai-OAS: sourceNamespace: livepeer-ai-oas - sourceRevisionDigest: sha256:5354d8a69a4e1db3706c645db7becd62271bfc93572f1a65dc1df1fc8575ed1a - sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f + sourceRevisionDigest: sha256:2b05b4d158138f959e4c1780587470df5cbe29ce56bea9714d8e202946f7e06b + sourceBlobDigest: sha256:c56907fa67feba848782a2720c447e2d442b420d4c1feae871ac97b3476e2c08 tags: - latest - main @@ -11,10 +11,10 @@ targets: livepeer-ai-ts: source: livepeer-ai-OAS sourceNamespace: livepeer-ai-oas - sourceRevisionDigest: sha256:5354d8a69a4e1db3706c645db7becd62271bfc93572f1a65dc1df1fc8575ed1a - sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f + sourceRevisionDigest: sha256:2b05b4d158138f959e4c1780587470df5cbe29ce56bea9714d8e202946f7e06b + sourceBlobDigest: sha256:c56907fa67feba848782a2720c447e2d442b420d4c1feae871ac97b3476e2c08 codeSamplesNamespace: code-samples-typescript-livepeer-ts - codeSamplesRevisionDigest: sha256:18cc5cd255be78c6bec9835dcfab751472a892f985bc172cb82f5cb6dadd6cb1 + codeSamplesRevisionDigest: sha256:a455e5bc3bf0384a0ec996d72d5f856137508822bc5b725be51cea223ff91477 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index ead047d..257b46c 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,8 @@ run(); * [segmentAnything2](docs/sdks/generate/README.md#segmentanything2) - Segment Anything 2 * [llm](docs/sdks/generate/README.md#llm) - LLM * [imageToText](docs/sdks/generate/README.md#imagetotext) - Image To Text +* [liveVideoToVideo](docs/sdks/generate/README.md#livevideotovideo) - Video To Video +* [textToSpeech](docs/sdks/generate/README.md#texttospeech) - Text To Speech @@ -114,9 +116,11 @@ To read more about standalone functions, check [FUNCTIONS.md](./FUNCTIONS.md). - [`generateImageToImage`](docs/sdks/generate/README.md#imagetoimage) - Image To Image - [`generateImageToText`](docs/sdks/generate/README.md#imagetotext) - Image To Text - [`generateImageToVideo`](docs/sdks/generate/README.md#imagetovideo) - Image To Video +- [`generateLiveVideoToVideo`](docs/sdks/generate/README.md#livevideotovideo) - Video To Video - [`generateLlm`](docs/sdks/generate/README.md#llm) - LLM - [`generateSegmentAnything2`](docs/sdks/generate/README.md#segmentanything2) - Segment Anything 2 - [`generateTextToImage`](docs/sdks/generate/README.md#texttoimage) - Text To Image +- [`generateTextToSpeech`](docs/sdks/generate/README.md#texttospeech) - Text To Speech - [`generateUpscale`](docs/sdks/generate/README.md#upscale) - Upscale diff --git a/RELEASES.md b/RELEASES.md index e94012f..153381c 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -100,4 +100,14 @@ Based on: ### Generated - [typescript v0.4.1] . ### Releases -- [NPM v0.4.1] https://www.npmjs.com/package/@livepeer/ai/v/0.4.1 - . \ No newline at end of file +- [NPM v0.4.1] https://www.npmjs.com/package/@livepeer/ai/v/0.4.1 - . + +## 2024-11-07 00:01:06 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.434.0 (2.452.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.5.0] . +### Releases +- [NPM v0.5.0] https://www.npmjs.com/package/@livepeer/ai/v/0.5.0 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 51e1b9a..3622038 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -95,6 +95,29 @@ actions: console.log(result); } + run(); + - target: $["paths"]["/live-video-to-video"]["post"] + update: + x-codeSamples: + - lang: typescript + label: genLiveVideoToVideo + source: |- + import { Livepeer } from "@livepeer/ai"; + + const livepeer = new Livepeer({ + httpBearer: "", + }); + + async function run() { + const result = await livepeer.generate.liveVideoToVideo({ + subscribeUrl: "https://soulful-lava.org/", + publishUrl: "https://vain-tabletop.biz", + }); + + // Handle the result + console.log(result); + } + run(); - target: $["paths"]["/llm"]["post"] update: @@ -162,6 +185,26 @@ actions: console.log(result); } + run(); + - target: $["paths"]["/text-to-speech"]["post"] + update: + x-codeSamples: + - lang: typescript + label: genTextToSpeech + source: |- + import { Livepeer } from "@livepeer/ai"; + + const livepeer = new Livepeer({ + httpBearer: "", + }); + + async function run() { + const result = await livepeer.generate.textToSpeech({}); + + // Handle the result + console.log(result); + } + run(); - target: $["paths"]["/upscale"]["post"] update: diff --git a/docs/models/components/audioresponse.md b/docs/models/components/audioresponse.md new file mode 100644 index 0000000..e532126 --- /dev/null +++ b/docs/models/components/audioresponse.md @@ -0,0 +1,21 @@ +# AudioResponse + +Response model for audio generation. + +## Example Usage + +```typescript +import { AudioResponse } from "@livepeer/ai/models/components"; + +let value: AudioResponse = { + audio: { + url: "https://quarrelsome-disappointment.info/", + }, +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `audio` | [components.MediaURL](../../models/components/mediaurl.md) | :heavy_check_mark: | The generated audio. | \ No newline at end of file diff --git a/docs/models/components/bodygenaudiototext.md b/docs/models/components/bodygenaudiototext.md index e2e3fb2..f789266 100644 --- a/docs/models/components/bodygenaudiototext.md +++ b/docs/models/components/bodygenaudiototext.md @@ -10,7 +10,8 @@ import { BodyGenAudioToText } from "@livepeer/ai/models/components"; ## Fields -| Field | Type | Required | Description | -| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `audio` | [File](https://developer.mozilla.org/en-US/docs/Web/API/File) \| [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) \| [components.Audio](../../models/components/audio.md) | :heavy_check_mark: | Uploaded audio file to be transcribed. | -| `modelId` | *string* | :heavy_minus_sign: | Hugging Face model ID used for transcription. | \ No newline at end of file +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `audio` | [File](https://developer.mozilla.org/en-US/docs/Web/API/File) \| [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) \| [components.Audio](../../models/components/audio.md) | :heavy_check_mark: | Uploaded audio file to be transcribed. | +| `modelId` | *string* | :heavy_minus_sign: | Hugging Face model ID used for transcription. | +| `returnTimestamps` | *string* | :heavy_minus_sign: | Return timestamps for the transcribed text. Supported values: 'sentence', 'word', or a string boolean ('true' or 'false'). Default is 'true' ('sentence'). 'false' means no timestamps. 'word' means word-based timestamps. | \ No newline at end of file diff --git a/docs/models/components/imageresponse.md b/docs/models/components/imageresponse.md index 458da10..8b1c58d 100644 --- a/docs/models/components/imageresponse.md +++ b/docs/models/components/imageresponse.md @@ -10,8 +10,8 @@ import { ImageResponse } from "@livepeer/ai/models/components"; let value: ImageResponse = { images: [ { - url: "https://talkative-sauerkraut.org/", - seed: 978619, + url: "https://steep-independence.net", + seed: 118274, nsfw: false, }, ], diff --git a/docs/models/components/livevideotovideoparams.md b/docs/models/components/livevideotovideoparams.md new file mode 100644 index 0000000..7cc6e62 --- /dev/null +++ b/docs/models/components/livevideotovideoparams.md @@ -0,0 +1,21 @@ +# LiveVideoToVideoParams + +## Example Usage + +```typescript +import { LiveVideoToVideoParams } from "@livepeer/ai/models/components"; + +let value: LiveVideoToVideoParams = { + subscribeUrl: "https://gigantic-freezing.name/", + publishUrl: "https://writhing-brochure.biz/", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `subscribeUrl` | *string* | :heavy_check_mark: | Source URL of the incoming stream to subscribe to. | +| `publishUrl` | *string* | :heavy_check_mark: | Destination URL of the outgoing stream to publish. | +| `modelId` | *string* | :heavy_minus_sign: | Hugging Face model ID used for image generation. | +| `params` | [components.Params](../../models/components/params.md) | :heavy_minus_sign: | Initial parameters for the model. | \ No newline at end of file diff --git a/docs/models/components/livevideotovideoresponse.md b/docs/models/components/livevideotovideoresponse.md new file mode 100644 index 0000000..d172db7 --- /dev/null +++ b/docs/models/components/livevideotovideoresponse.md @@ -0,0 +1,21 @@ +# LiveVideoToVideoResponse + +Response model for live video-to-video generation. + +## Example Usage + +```typescript +import { LiveVideoToVideoResponse } from "@livepeer/ai/models/components"; + +let value: LiveVideoToVideoResponse = { + subscribeUrl: "https://hateful-humor.net", + publishUrl: "https://rare-pillbox.biz/", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | ---------------------------------------------------- | +| `subscribeUrl` | *string* | :heavy_check_mark: | Source URL of the incoming stream to subscribe to | +| `publishUrl` | *string* | :heavy_check_mark: | Destination URL of the outgoing stream to publish to | \ No newline at end of file diff --git a/docs/models/components/llmresponse.md b/docs/models/components/llmresponse.md index b07f1df..4c9b4d1 100644 --- a/docs/models/components/llmresponse.md +++ b/docs/models/components/llmresponse.md @@ -7,7 +7,7 @@ import { LLMResponse } from "@livepeer/ai/models/components"; let value: LLMResponse = { response: "", - tokensUsed: 18789, + tokensUsed: 943749, }; ``` diff --git a/docs/models/components/loc.md b/docs/models/components/loc.md index 161afed..88f2507 100644 --- a/docs/models/components/loc.md +++ b/docs/models/components/loc.md @@ -12,6 +12,6 @@ const value: string = ""; ### `number` ```typescript -const value: number = 143353; +const value: number = 264555; ``` diff --git a/docs/models/components/media.md b/docs/models/components/media.md index 24daf7b..dfad591 100644 --- a/docs/models/components/media.md +++ b/docs/models/components/media.md @@ -8,8 +8,8 @@ A media object containing information about the generated media. import { Media } from "@livepeer/ai/models/components"; let value: Media = { - url: "https://leading-scaffold.com", - seed: 639921, + url: "https://corrupt-unblinking.name", + seed: 414662, nsfw: false, }; ``` diff --git a/docs/models/components/mediaurl.md b/docs/models/components/mediaurl.md new file mode 100644 index 0000000..dbd4f2b --- /dev/null +++ b/docs/models/components/mediaurl.md @@ -0,0 +1,19 @@ +# MediaURL + +A URL from which media can be accessed. + +## Example Usage + +```typescript +import { MediaURL } from "@livepeer/ai/models/components"; + +let value: MediaURL = { + url: "https://cumbersome-calculus.name/", +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | ---------------------------------------- | +| `url` | *string* | :heavy_check_mark: | The URL where the media can be accessed. | \ No newline at end of file diff --git a/docs/models/components/params.md b/docs/models/components/params.md new file mode 100644 index 0000000..1c7764f --- /dev/null +++ b/docs/models/components/params.md @@ -0,0 +1,16 @@ +# Params + +Initial parameters for the model. + +## Example Usage + +```typescript +import { Params } from "@livepeer/ai/models/components"; + +let value: Params = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/docs/models/components/texttospeechparams.md b/docs/models/components/texttospeechparams.md new file mode 100644 index 0000000..9696fb8 --- /dev/null +++ b/docs/models/components/texttospeechparams.md @@ -0,0 +1,17 @@ +# TextToSpeechParams + +## Example Usage + +```typescript +import { TextToSpeechParams } from "@livepeer/ai/models/components"; + +let value: TextToSpeechParams = {}; +``` + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `modelId` | *string* | :heavy_minus_sign: | Hugging Face model ID used for text to speech generation. | +| `text` | *string* | :heavy_minus_sign: | Text input for speech generation. | +| `description` | *string* | :heavy_minus_sign: | Description of speaker to steer text to speech generation. | \ No newline at end of file diff --git a/docs/models/components/validationerror.md b/docs/models/components/validationerror.md index 8f58658..e1af620 100644 --- a/docs/models/components/validationerror.md +++ b/docs/models/components/validationerror.md @@ -7,7 +7,7 @@ import { ValidationError } from "@livepeer/ai/models/components"; let value: ValidationError = { loc: [ - 521848, + 456150, ], msg: "", type: "", diff --git a/docs/models/components/videoresponse.md b/docs/models/components/videoresponse.md index 5ed83e8..c858bfb 100644 --- a/docs/models/components/videoresponse.md +++ b/docs/models/components/videoresponse.md @@ -10,8 +10,8 @@ import { VideoResponse } from "@livepeer/ai/models/components"; let value: VideoResponse = { images: [ { - url: "https://favorable-sand.info/", - seed: 568434, + url: "https://agitated-ocelot.name", + seed: 616934, nsfw: false, }, ], diff --git a/docs/models/operations/genlivevideotovideoresponse.md b/docs/models/operations/genlivevideotovideoresponse.md new file mode 100644 index 0000000..39c8b8f --- /dev/null +++ b/docs/models/operations/genlivevideotovideoresponse.md @@ -0,0 +1,24 @@ +# GenLiveVideoToVideoResponse + +## Example Usage + +```typescript +import { GenLiveVideoToVideoResponse } from "@livepeer/ai/models/operations"; + +let value: GenLiveVideoToVideoResponse = { + contentType: "", + statusCode: 103, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `contentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `statusCode` | *number* | :heavy_check_mark: | HTTP response status code for this operation | +| `rawResponse` | [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `liveVideoToVideoResponse` | [components.LiveVideoToVideoResponse](../../models/components/livevideotovideoresponse.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/docs/models/operations/gentexttospeechresponse.md b/docs/models/operations/gentexttospeechresponse.md new file mode 100644 index 0000000..380027f --- /dev/null +++ b/docs/models/operations/gentexttospeechresponse.md @@ -0,0 +1,24 @@ +# GenTextToSpeechResponse + +## Example Usage + +```typescript +import { GenTextToSpeechResponse } from "@livepeer/ai/models/operations"; + +let value: GenTextToSpeechResponse = { + contentType: "", + statusCode: 428, + rawResponse: new Response("{\"message\": \"hello world\"}", { + headers: { "Content-Type": "application/json" }, + }), +}; +``` + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | +| `contentType` | *string* | :heavy_check_mark: | HTTP response content type for this operation | +| `statusCode` | *number* | :heavy_check_mark: | HTTP response status code for this operation | +| `rawResponse` | [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `audioResponse` | [components.AudioResponse](../../models/components/audioresponse.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 4be3023..0494390 100644 --- a/docs/sdks/generate/README.md +++ b/docs/sdks/generate/README.md @@ -13,6 +13,8 @@ * [segmentAnything2](#segmentanything2) - Segment Anything 2 * [llm](#llm) - LLM * [imageToText](#imagetotext) - Image To Text +* [liveVideoToVideo](#livevideotovideo) - Video To Video +* [textToSpeech](#texttospeech) - Text To Speech ## textToImage @@ -652,4 +654,158 @@ run(); | -------------------------- | -------------------------- | -------------------------- | | errors.HTTPError | 400, 401, 413, 500 | application/json | | errors.HTTPValidationError | 422 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | + +## liveVideoToVideo + +Apply video-like transformations to a provided image. + +### Example Usage + +```typescript +import { Livepeer } from "@livepeer/ai"; + +const livepeer = new Livepeer({ + httpBearer: "", +}); + +async function run() { + const result = await livepeer.generate.liveVideoToVideo({ + subscribeUrl: "https://soulful-lava.org/", + publishUrl: "https://vain-tabletop.biz", + }); + + // Handle the result + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { LivepeerCore } from "@livepeer/ai/core.js"; +import { generateLiveVideoToVideo } from "@livepeer/ai/funcs/generateLiveVideoToVideo.js"; + +// Use `LivepeerCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const livepeer = new LivepeerCore({ + httpBearer: "", +}); + +async function run() { + const res = await generateLiveVideoToVideo(livepeer, { + subscribeUrl: "https://soulful-lava.org/", + publishUrl: "https://vain-tabletop.biz", + }); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [components.LiveVideoToVideoParams](../../models/components/livevideotovideoparams.md) | :heavy_check_mark: | The request object to use for the request. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.GenLiveVideoToVideoResponse](../../models/operations/genlivevideotovideoresponse.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------- | -------------------------- | -------------------------- | +| errors.HTTPError | 400, 401, 500 | application/json | +| errors.HTTPValidationError | 422 | application/json | +| errors.SDKError | 4XX, 5XX | \*/\* | + +## textToSpeech + +Generate a text-to-speech audio file based on the provided text input and speaker description. + +### Example Usage + +```typescript +import { Livepeer } from "@livepeer/ai"; + +const livepeer = new Livepeer({ + httpBearer: "", +}); + +async function run() { + const result = await livepeer.generate.textToSpeech({}); + + // Handle the result + console.log(result); +} + +run(); +``` + +### Standalone function + +The standalone function version of this method: + +```typescript +import { LivepeerCore } from "@livepeer/ai/core.js"; +import { generateTextToSpeech } from "@livepeer/ai/funcs/generateTextToSpeech.js"; + +// Use `LivepeerCore` for best tree-shaking performance. +// You can create one instance of it to use across an application. +const livepeer = new LivepeerCore({ + httpBearer: "", +}); + +async function run() { + const res = await generateTextToSpeech(livepeer, {}); + + if (!res.ok) { + throw res.error; + } + + const { value: result } = res; + + // Handle the result + console.log(result); +} + +run(); +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `request` | [components.TextToSpeechParams](../../models/components/texttospeechparams.md) | :heavy_check_mark: | The request object to use for the request. | +| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | +| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | +| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | + +### Response + +**Promise\<[operations.GenTextToSpeechResponse](../../models/operations/gentexttospeechresponse.md)\>** + +### Errors + +| Error Type | Status Code | Content Type | +| -------------------------- | -------------------------- | -------------------------- | +| errors.HTTPError | 400, 401, 500 | application/json | +| errors.HTTPValidationError | 422 | application/json | | errors.SDKError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/jsr.json b/jsr.json index bb0aad6..272f474 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@livepeer/ai", - "version": "0.4.1", + "version": "0.5.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index d3dc5f9..c7deac3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@livepeer/ai", - "version": "0.4.1", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@livepeer/ai", - "version": "0.4.1", + "version": "0.5.0", "dependencies": { "jest": "^29.7.0", "jest-junit": "^16.0.0", diff --git a/package.json b/package.json index 59f6d21..d905ef5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@livepeer/ai", - "version": "0.4.1", + "version": "0.5.0", "author": "Livepeer", "main": "./index.js", "sideEffects": false, diff --git a/src/funcs/generateAudioToText.ts b/src/funcs/generateAudioToText.ts index 89614c4..58f5891 100644 --- a/src/funcs/generateAudioToText.ts +++ b/src/funcs/generateAudioToText.ts @@ -76,6 +76,9 @@ export async function generateAudioToText( if (payload.model_id !== undefined) { body.append("model_id", payload.model_id); } + if (payload.return_timestamps !== undefined) { + body.append("return_timestamps", payload.return_timestamps); + } const path = pathToFunc("/audio-to-text")(); @@ -85,12 +88,17 @@ export async function generateAudioToText( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genAudioToText", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -108,9 +116,8 @@ export async function generateAudioToText( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "413", "415", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/generateImageToImage.ts b/src/funcs/generateImageToImage.ts index eace91f..b20b26a 100644 --- a/src/funcs/generateImageToImage.ts +++ b/src/funcs/generateImageToImage.ts @@ -113,12 +113,17 @@ export async function generateImageToImage( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genImageToImage", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -136,9 +141,8 @@ export async function generateImageToImage( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/generateImageToText.ts b/src/funcs/generateImageToText.ts index 430d3fb..e13cd4c 100644 --- a/src/funcs/generateImageToText.ts +++ b/src/funcs/generateImageToText.ts @@ -88,12 +88,17 @@ export async function generateImageToText( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genImageToText", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -111,9 +116,8 @@ export async function generateImageToText( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "413", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/generateImageToVideo.ts b/src/funcs/generateImageToVideo.ts index a3e83dc..015f901 100644 --- a/src/funcs/generateImageToVideo.ts +++ b/src/funcs/generateImageToVideo.ts @@ -109,12 +109,17 @@ export async function generateImageToVideo( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genImageToVideo", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -132,9 +137,8 @@ export async function generateImageToVideo( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/generateLiveVideoToVideo.ts b/src/funcs/generateLiveVideoToVideo.ts new file mode 100644 index 0000000..e732f03 --- /dev/null +++ b/src/funcs/generateLiveVideoToVideo.ts @@ -0,0 +1,138 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { LivepeerCore } from "../core.js"; +import { encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Video To Video + * + * @remarks + * Apply video-like transformations to a provided image. + */ +export async function generateLiveVideoToVideo( + client: LivepeerCore, + request: components.LiveVideoToVideoParams, + options?: RequestOptions, +): Promise< + Result< + operations.GenLiveVideoToVideoResponse, + | errors.HTTPError + | errors.HTTPValidationError + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => components.LiveVideoToVideoParams$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload, { explode: true }); + + const path = pathToFunc("/live-video-to-video")(); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.httpBearer); + const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "genLiveVideoToVideo", + oAuth2Scopes: [], + securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result] = await M.match< + operations.GenLiveVideoToVideoResponse, + | errors.HTTPError + | errors.HTTPValidationError + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, operations.GenLiveVideoToVideoResponse$inboundSchema, { + key: "LiveVideoToVideoResponse", + }), + M.jsonErr([400, 401, 500], errors.HTTPError$inboundSchema), + M.jsonErr(422, errors.HTTPValidationError$inboundSchema), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/src/funcs/generateLlm.ts b/src/funcs/generateLlm.ts index 26c6dbc..9d18355 100644 --- a/src/funcs/generateLlm.ts +++ b/src/funcs/generateLlm.ts @@ -70,12 +70,17 @@ export async function generateLlm( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genLLM", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -93,9 +98,8 @@ export async function generateLlm( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/generateSegmentAnything2.ts b/src/funcs/generateSegmentAnything2.ts index ee79ed2..1bb01e7 100644 --- a/src/funcs/generateSegmentAnything2.ts +++ b/src/funcs/generateSegmentAnything2.ts @@ -106,12 +106,17 @@ export async function generateSegmentAnything2( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genSegmentAnything2", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -129,9 +134,8 @@ export async function generateSegmentAnything2( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/generateTextToImage.ts b/src/funcs/generateTextToImage.ts index f32260e..03b5726 100644 --- a/src/funcs/generateTextToImage.ts +++ b/src/funcs/generateTextToImage.ts @@ -67,12 +67,17 @@ export async function generateTextToImage( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genTextToImage", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -90,9 +95,8 @@ export async function generateTextToImage( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/funcs/generateTextToSpeech.ts b/src/funcs/generateTextToSpeech.ts new file mode 100644 index 0000000..e71bef9 --- /dev/null +++ b/src/funcs/generateTextToSpeech.ts @@ -0,0 +1,138 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import { LivepeerCore } from "../core.js"; +import { encodeJSON } from "../lib/encodings.js"; +import * as M from "../lib/matchers.js"; +import { safeParse } from "../lib/schemas.js"; +import { RequestOptions } from "../lib/sdks.js"; +import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js"; +import { pathToFunc } from "../lib/url.js"; +import * as components from "../models/components/index.js"; +import { + ConnectionError, + InvalidRequestError, + RequestAbortedError, + RequestTimeoutError, + UnexpectedClientError, +} from "../models/errors/httpclienterrors.js"; +import * as errors from "../models/errors/index.js"; +import { SDKError } from "../models/errors/sdkerror.js"; +import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; +import * as operations from "../models/operations/index.js"; +import { Result } from "../types/fp.js"; + +/** + * Text To Speech + * + * @remarks + * Generate a text-to-speech audio file based on the provided text input and speaker description. + */ +export async function generateTextToSpeech( + client: LivepeerCore, + request: components.TextToSpeechParams, + options?: RequestOptions, +): Promise< + Result< + operations.GenTextToSpeechResponse, + | errors.HTTPError + | errors.HTTPValidationError + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + > +> { + const parsed = safeParse( + request, + (value) => components.TextToSpeechParams$outboundSchema.parse(value), + "Input validation failed", + ); + if (!parsed.ok) { + return parsed; + } + const payload = parsed.value; + const body = encodeJSON("body", payload, { explode: true }); + + const path = pathToFunc("/text-to-speech")(); + + const headers = new Headers({ + "Content-Type": "application/json", + Accept: "application/json", + }); + + const secConfig = await extractSecurity(client._options.httpBearer); + const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + + const context = { + operationID: "genTextToSpeech", + oAuth2Scopes: [], + securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + }; + + const requestRes = client._createRequest(context, { + security: requestSecurity, + method: "POST", + path: path, + headers: headers, + body: body, + timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, + }, options); + if (!requestRes.ok) { + return requestRes; + } + const req = requestRes.value; + + const doResult = await client._do(req, { + context, + errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, + }); + if (!doResult.ok) { + return doResult; + } + const response = doResult.value; + + const responseFields = { + ContentType: response.headers.get("content-type") + ?? "application/octet-stream", + StatusCode: response.status, + RawResponse: response, + Headers: {}, + }; + + const [result] = await M.match< + operations.GenTextToSpeechResponse, + | errors.HTTPError + | errors.HTTPValidationError + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >( + M.json(200, operations.GenTextToSpeechResponse$inboundSchema, { + key: "AudioResponse", + }), + M.jsonErr([400, 401, 500], errors.HTTPError$inboundSchema), + M.jsonErr(422, errors.HTTPValidationError$inboundSchema), + M.fail(["4XX", "5XX"]), + )(response, { extraFields: responseFields }); + if (!result.ok) { + return result; + } + + return result; +} diff --git a/src/funcs/generateUpscale.ts b/src/funcs/generateUpscale.ts index 003e424..5d74dc3 100644 --- a/src/funcs/generateUpscale.ts +++ b/src/funcs/generateUpscale.ts @@ -95,12 +95,17 @@ export async function generateUpscale( const secConfig = await extractSecurity(client._options.httpBearer); const securityInput = secConfig == null ? {} : { httpBearer: secConfig }; + const requestSecurity = resolveGlobalSecurity(securityInput); + const context = { operationID: "genUpscale", oAuth2Scopes: [], securitySource: client._options.httpBearer, + retryConfig: options?.retries + || client._options.retryConfig + || { strategy: "none" }, + retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], }; - const requestSecurity = resolveGlobalSecurity(securityInput); const requestRes = client._createRequest(context, { security: requestSecurity, @@ -118,9 +123,8 @@ export async function generateUpscale( const doResult = await client._do(req, { context, errorCodes: ["400", "401", "422", "4XX", "500", "5XX"], - retryConfig: options?.retries - || client._options.retryConfig, - retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"], + retryConfig: context.retryConfig, + retryCodes: context.retryCodes, }); if (!doResult.ok) { return doResult; diff --git a/src/hooks/types.ts b/src/hooks/types.ts index 656b9e3..4079cc9 100644 --- a/src/hooks/types.ts +++ b/src/hooks/types.ts @@ -3,11 +3,13 @@ */ import { HTTPClient, RequestInput } from "../lib/http.js"; +import { RetryConfig } from "../lib/retries.js"; export type HookContext = { operationID: string; oAuth2Scopes?: string[]; securitySource?: any | (() => Promise); + retryConfig: RetryConfig; }; export type Awaitable = T | Promise; diff --git a/src/lib/config.ts b/src/lib/config.ts index 224bafe..2ac6740 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -61,7 +61,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "0.0.0", - sdkVersion: "0.4.1", - genVersion: "2.438.15", - userAgent: "speakeasy-sdk/typescript 0.4.1 2.438.15 0.0.0 @livepeer/ai", + sdkVersion: "0.5.0", + genVersion: "2.452.0", + userAgent: "speakeasy-sdk/typescript 0.5.0 2.452.0 0.0.0 @livepeer/ai", } as const; diff --git a/src/lib/retries.ts b/src/lib/retries.ts index df3e0bc..93ebc8d 100644 --- a/src/lib/retries.ts +++ b/src/lib/retries.ts @@ -26,23 +26,44 @@ export type RetryConfig = retryConnectionErrors?: boolean; }; -class PermanentError extends Error { - inner: unknown; +/** + * PermanentError is an error that is not recoverable. Throwing this error will + * cause a retry loop to terminate. + */ +export class PermanentError extends Error { + /** The underlying cause of the error. */ + override readonly cause: unknown; + + constructor(message: string, options?: { cause?: unknown }) { + let msg = message; + if (options?.cause) { + msg += `: ${options.cause}`; + } - constructor(inner: unknown) { - super("Permanent error"); - this.inner = inner; + super(msg, options); + this.name = "PermanentError"; + // In older runtimes, the cause field would not have been assigned through + // the super() call. + if (typeof this.cause === "undefined") { + this.cause = options?.cause; + } Object.setPrototypeOf(this, PermanentError.prototype); } } -class TemporaryError extends Error { - res: Response; +/** + * TemporaryError is an error is used to signal that an HTTP request can be + * retried as part of a retry loop. If retry attempts are exhausted and this + * error is thrown, the response will be returned to the caller. + */ +export class TemporaryError extends Error { + response: Response; - constructor(res: Response) { - super("Temporary error"); - this.res = res; + constructor(message: string, response: Response) { + super(message); + this.response = response; + this.name = "TemporaryError"; Object.setPrototypeOf(this, TemporaryError.prototype); } @@ -80,11 +101,14 @@ function wrapFetcher( try { const res = await fn(); if (isRetryableResponse(res, options.statusCodes)) { - throw new TemporaryError(res); + throw new TemporaryError( + "Response failed with retryable status code", + res, + ); } return res; - } catch (err) { + } catch (err: unknown) { if (err instanceof TemporaryError) { throw err; } @@ -96,7 +120,7 @@ function wrapFetcher( throw err; } - throw new PermanentError(err); + throw new PermanentError("Permanent error", { cause: err }); } }; } @@ -139,37 +163,25 @@ async function retryBackoff( try { const res = await fn(); return res; - } catch (err) { + } catch (err: unknown) { if (err instanceof PermanentError) { - throw err.inner; + throw err.cause; } const elapsed = Date.now() - start; if (elapsed > maxElapsedTime) { if (err instanceof TemporaryError) { - return err.res; + return err.response; } throw err; } let retryInterval = 0; - if (err instanceof TemporaryError && err.res && err.res.headers) { - const retryVal = err.res.headers.get("retry-after") || ""; - if (retryVal != "") { - const parsedNumber = Number(retryVal); - if (!isNaN(parsedNumber) && Number.isInteger(parsedNumber)) { - retryInterval = parsedNumber * 1000; - } else { - const parsedDate = Date.parse(retryVal); - if (!isNaN(parsedDate)) { - const deltaMS = parsedDate - Date.now(); - retryInterval = deltaMS > 0 ? Math.ceil(deltaMS) : 0; - } - } - } + if (err instanceof TemporaryError) { + retryInterval = retryIntervalFromResponse(err.response); } - if (retryInterval == 0) { + if (retryInterval <= 0) { retryInterval = initialInterval * Math.pow(x, exponent) + Math.random() * 1000; } @@ -182,6 +194,26 @@ async function retryBackoff( } } +function retryIntervalFromResponse(res: Response): number { + const retryVal = res.headers.get("retry-after") || ""; + if (!retryVal) { + return 0; + } + + const parsedNumber = Number(retryVal); + if (Number.isInteger(parsedNumber)) { + return parsedNumber * 1000; + } + + const parsedDate = Date.parse(retryVal); + if (Number.isInteger(parsedDate)) { + const deltaMS = parsedDate - Date.now(); + return deltaMS > 0 ? Math.ceil(deltaMS) : 0; + } + + return 0; +} + async function delay(delay: number): Promise { return new Promise((resolve) => setTimeout(resolve, delay)); } diff --git a/src/lib/sdks.ts b/src/lib/sdks.ts index a0f4de1..2ce720a 100644 --- a/src/lib/sdks.ts +++ b/src/lib/sdks.ts @@ -220,8 +220,8 @@ export class ClientSDK { options: { context: HookContext; errorCodes: number | string | (number | string)[]; - retryConfig?: RetryConfig | undefined; - retryCodes?: string[] | undefined; + retryConfig: RetryConfig; + retryCodes: string[]; }, ): Promise< Result< @@ -233,8 +233,6 @@ export class ClientSDK { > > { const { context, errorCodes } = options; - const retryConfig = options.retryConfig || { strategy: "none" }; - const retryCodes = options.retryCodes || []; return retry( async () => { @@ -245,22 +243,28 @@ export class ClientSDK { let response = await this.#httpClient.request(req); - if (matchStatusCode(response, errorCodes)) { - const result = await this.#hooks.afterError(context, response, null); - if (result.error) { - throw result.error; + try { + if (matchStatusCode(response, errorCodes)) { + const result = await this.#hooks.afterError( + context, + response, + null, + ); + if (result.error) { + throw result.error; + } + response = result.response || response; + } else { + response = await this.#hooks.afterSuccess(context, response); } - response = result.response || response; - } else { - response = await this.#hooks.afterSuccess(context, response); + } finally { + await logResponse(this.#logger, response, req) + .catch(e => this.#logger?.log("Failed to log response:", e)); } - await logResponse(this.#logger, response, req) - .catch(e => this.#logger?.log("Failed to log response:", e)); - return response; }, - { config: retryConfig, statusCodes: retryCodes }, + { config: options.retryConfig, statusCodes: options.retryCodes }, ).then( (r) => OK(r), (err) => { diff --git a/src/models/components/audioresponse.ts b/src/models/components/audioresponse.ts new file mode 100644 index 0000000..9faeebf --- /dev/null +++ b/src/models/components/audioresponse.ts @@ -0,0 +1,57 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { + MediaURL, + MediaURL$inboundSchema, + MediaURL$Outbound, + MediaURL$outboundSchema, +} from "./mediaurl.js"; + +/** + * Response model for audio generation. + */ +export type AudioResponse = { + /** + * The generated audio. + */ + audio: MediaURL; +}; + +/** @internal */ +export const AudioResponse$inboundSchema: z.ZodType< + AudioResponse, + z.ZodTypeDef, + unknown +> = z.object({ + audio: MediaURL$inboundSchema, +}); + +/** @internal */ +export type AudioResponse$Outbound = { + audio: MediaURL$Outbound; +}; + +/** @internal */ +export const AudioResponse$outboundSchema: z.ZodType< + AudioResponse$Outbound, + z.ZodTypeDef, + AudioResponse +> = z.object({ + audio: MediaURL$outboundSchema, +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace AudioResponse$ { + /** @deprecated use `AudioResponse$inboundSchema` instead. */ + export const inboundSchema = AudioResponse$inboundSchema; + /** @deprecated use `AudioResponse$outboundSchema` instead. */ + export const outboundSchema = AudioResponse$outboundSchema; + /** @deprecated use `AudioResponse$Outbound` instead. */ + export type Outbound = AudioResponse$Outbound; +} diff --git a/src/models/components/bodygenaudiototext.ts b/src/models/components/bodygenaudiototext.ts index 6cc3390..6590b0c 100644 --- a/src/models/components/bodygenaudiototext.ts +++ b/src/models/components/bodygenaudiototext.ts @@ -20,6 +20,10 @@ export type BodyGenAudioToText = { * Hugging Face model ID used for transcription. */ modelId?: string | undefined; + /** + * Return timestamps for the transcribed text. Supported values: 'sentence', 'word', or a string boolean ('true' or 'false'). Default is 'true' ('sentence'). 'false' means no timestamps. 'word' means word-based timestamps. + */ + returnTimestamps?: string | undefined; }; /** @internal */ @@ -76,9 +80,11 @@ export const BodyGenAudioToText$inboundSchema: z.ZodType< > = z.object({ audio: z.lazy(() => Audio$inboundSchema), model_id: z.string().default(""), + return_timestamps: z.string().default("true"), }).transform((v) => { return remap$(v, { "model_id": "modelId", + "return_timestamps": "returnTimestamps", }); }); @@ -86,6 +92,7 @@ export const BodyGenAudioToText$inboundSchema: z.ZodType< export type BodyGenAudioToText$Outbound = { audio: Audio$Outbound | Blob; model_id: string; + return_timestamps: string; }; /** @internal */ @@ -96,9 +103,11 @@ export const BodyGenAudioToText$outboundSchema: z.ZodType< > = z.object({ audio: z.lazy(() => Audio$outboundSchema).or(blobLikeSchema), modelId: z.string().default(""), + returnTimestamps: z.string().default("true"), }).transform((v) => { return remap$(v, { modelId: "model_id", + returnTimestamps: "return_timestamps", }); }); diff --git a/src/models/components/index.ts b/src/models/components/index.ts index b97d8f0..6a6854a 100644 --- a/src/models/components/index.ts +++ b/src/models/components/index.ts @@ -3,6 +3,7 @@ */ export * from "./apierror.js"; +export * from "./audioresponse.js"; export * from "./bodygenaudiototext.js"; export * from "./bodygenimagetoimage.js"; export * from "./bodygenimagetotext.js"; @@ -13,11 +14,15 @@ export * from "./bodygenupscale.js"; export * from "./chunk.js"; export * from "./imageresponse.js"; export * from "./imagetotextresponse.js"; +export * from "./livevideotovideoparams.js"; +export * from "./livevideotovideoresponse.js"; export * from "./llmresponse.js"; export * from "./masksresponse.js"; export * from "./media.js"; +export * from "./mediaurl.js"; export * from "./security.js"; export * from "./textresponse.js"; export * from "./texttoimageparams.js"; +export * from "./texttospeechparams.js"; export * from "./validationerror.js"; export * from "./videoresponse.js"; diff --git a/src/models/components/livevideotovideoparams.ts b/src/models/components/livevideotovideoparams.ts new file mode 100644 index 0000000..71c44ec --- /dev/null +++ b/src/models/components/livevideotovideoparams.ts @@ -0,0 +1,114 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; + +/** + * Initial parameters for the model. + */ +export type Params = {}; + +export type LiveVideoToVideoParams = { + /** + * Source URL of the incoming stream to subscribe to. + */ + subscribeUrl: string; + /** + * Destination URL of the outgoing stream to publish. + */ + publishUrl: string; + /** + * Hugging Face model ID used for image generation. + */ + modelId?: string | undefined; + /** + * Initial parameters for the model. + */ + params?: Params | undefined; +}; + +/** @internal */ +export const Params$inboundSchema: z.ZodType = z + .object({}); + +/** @internal */ +export type Params$Outbound = {}; + +/** @internal */ +export const Params$outboundSchema: z.ZodType< + Params$Outbound, + z.ZodTypeDef, + Params +> = z.object({}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace Params$ { + /** @deprecated use `Params$inboundSchema` instead. */ + export const inboundSchema = Params$inboundSchema; + /** @deprecated use `Params$outboundSchema` instead. */ + export const outboundSchema = Params$outboundSchema; + /** @deprecated use `Params$Outbound` instead. */ + export type Outbound = Params$Outbound; +} + +/** @internal */ +export const LiveVideoToVideoParams$inboundSchema: z.ZodType< + LiveVideoToVideoParams, + z.ZodTypeDef, + unknown +> = z.object({ + subscribe_url: z.string(), + publish_url: z.string(), + model_id: z.string().default(""), + params: z.lazy(() => Params$inboundSchema).optional(), +}).transform((v) => { + return remap$(v, { + "subscribe_url": "subscribeUrl", + "publish_url": "publishUrl", + "model_id": "modelId", + }); +}); + +/** @internal */ +export type LiveVideoToVideoParams$Outbound = { + subscribe_url: string; + publish_url: string; + model_id: string; + params?: Params$Outbound | undefined; +}; + +/** @internal */ +export const LiveVideoToVideoParams$outboundSchema: z.ZodType< + LiveVideoToVideoParams$Outbound, + z.ZodTypeDef, + LiveVideoToVideoParams +> = z.object({ + subscribeUrl: z.string(), + publishUrl: z.string(), + modelId: z.string().default(""), + params: z.lazy(() => Params$outboundSchema).optional(), +}).transform((v) => { + return remap$(v, { + subscribeUrl: "subscribe_url", + publishUrl: "publish_url", + modelId: "model_id", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace LiveVideoToVideoParams$ { + /** @deprecated use `LiveVideoToVideoParams$inboundSchema` instead. */ + export const inboundSchema = LiveVideoToVideoParams$inboundSchema; + /** @deprecated use `LiveVideoToVideoParams$outboundSchema` instead. */ + export const outboundSchema = LiveVideoToVideoParams$outboundSchema; + /** @deprecated use `LiveVideoToVideoParams$Outbound` instead. */ + export type Outbound = LiveVideoToVideoParams$Outbound; +} diff --git a/src/models/components/livevideotovideoresponse.ts b/src/models/components/livevideotovideoresponse.ts new file mode 100644 index 0000000..6849e9b --- /dev/null +++ b/src/models/components/livevideotovideoresponse.ts @@ -0,0 +1,69 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; + +/** + * Response model for live video-to-video generation. + */ +export type LiveVideoToVideoResponse = { + /** + * Source URL of the incoming stream to subscribe to + */ + subscribeUrl: string; + /** + * Destination URL of the outgoing stream to publish to + */ + publishUrl: string; +}; + +/** @internal */ +export const LiveVideoToVideoResponse$inboundSchema: z.ZodType< + LiveVideoToVideoResponse, + z.ZodTypeDef, + unknown +> = z.object({ + subscribe_url: z.string(), + publish_url: z.string(), +}).transform((v) => { + return remap$(v, { + "subscribe_url": "subscribeUrl", + "publish_url": "publishUrl", + }); +}); + +/** @internal */ +export type LiveVideoToVideoResponse$Outbound = { + subscribe_url: string; + publish_url: string; +}; + +/** @internal */ +export const LiveVideoToVideoResponse$outboundSchema: z.ZodType< + LiveVideoToVideoResponse$Outbound, + z.ZodTypeDef, + LiveVideoToVideoResponse +> = z.object({ + subscribeUrl: z.string(), + publishUrl: z.string(), +}).transform((v) => { + return remap$(v, { + subscribeUrl: "subscribe_url", + publishUrl: "publish_url", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace LiveVideoToVideoResponse$ { + /** @deprecated use `LiveVideoToVideoResponse$inboundSchema` instead. */ + export const inboundSchema = LiveVideoToVideoResponse$inboundSchema; + /** @deprecated use `LiveVideoToVideoResponse$outboundSchema` instead. */ + export const outboundSchema = LiveVideoToVideoResponse$outboundSchema; + /** @deprecated use `LiveVideoToVideoResponse$Outbound` instead. */ + export type Outbound = LiveVideoToVideoResponse$Outbound; +} diff --git a/src/models/components/mediaurl.ts b/src/models/components/mediaurl.ts new file mode 100644 index 0000000..cd316b2 --- /dev/null +++ b/src/models/components/mediaurl.ts @@ -0,0 +1,51 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; + +/** + * A URL from which media can be accessed. + */ +export type MediaURL = { + /** + * The URL where the media can be accessed. + */ + url: string; +}; + +/** @internal */ +export const MediaURL$inboundSchema: z.ZodType< + MediaURL, + z.ZodTypeDef, + unknown +> = z.object({ + url: z.string(), +}); + +/** @internal */ +export type MediaURL$Outbound = { + url: string; +}; + +/** @internal */ +export const MediaURL$outboundSchema: z.ZodType< + MediaURL$Outbound, + z.ZodTypeDef, + MediaURL +> = z.object({ + url: z.string(), +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace MediaURL$ { + /** @deprecated use `MediaURL$inboundSchema` instead. */ + export const inboundSchema = MediaURL$inboundSchema; + /** @deprecated use `MediaURL$outboundSchema` instead. */ + export const outboundSchema = MediaURL$outboundSchema; + /** @deprecated use `MediaURL$Outbound` instead. */ + export type Outbound = MediaURL$Outbound; +} diff --git a/src/models/components/texttospeechparams.ts b/src/models/components/texttospeechparams.ts new file mode 100644 index 0000000..78d3e7c --- /dev/null +++ b/src/models/components/texttospeechparams.ts @@ -0,0 +1,75 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; + +export type TextToSpeechParams = { + /** + * Hugging Face model ID used for text to speech generation. + */ + modelId?: string | undefined; + /** + * Text input for speech generation. + */ + text?: string | undefined; + /** + * Description of speaker to steer text to speech generation. + */ + description?: string | undefined; +}; + +/** @internal */ +export const TextToSpeechParams$inboundSchema: z.ZodType< + TextToSpeechParams, + z.ZodTypeDef, + unknown +> = z.object({ + model_id: z.string().default(""), + text: z.string().default(""), + description: z.string().default( + "A male speaker delivers a slightly expressive and animated speech with a moderate speed and pitch.", + ), +}).transform((v) => { + return remap$(v, { + "model_id": "modelId", + }); +}); + +/** @internal */ +export type TextToSpeechParams$Outbound = { + model_id: string; + text: string; + description: string; +}; + +/** @internal */ +export const TextToSpeechParams$outboundSchema: z.ZodType< + TextToSpeechParams$Outbound, + z.ZodTypeDef, + TextToSpeechParams +> = z.object({ + modelId: z.string().default(""), + text: z.string().default(""), + description: z.string().default( + "A male speaker delivers a slightly expressive and animated speech with a moderate speed and pitch.", + ), +}).transform((v) => { + return remap$(v, { + modelId: "model_id", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace TextToSpeechParams$ { + /** @deprecated use `TextToSpeechParams$inboundSchema` instead. */ + export const inboundSchema = TextToSpeechParams$inboundSchema; + /** @deprecated use `TextToSpeechParams$outboundSchema` instead. */ + export const outboundSchema = TextToSpeechParams$outboundSchema; + /** @deprecated use `TextToSpeechParams$Outbound` instead. */ + export type Outbound = TextToSpeechParams$Outbound; +} diff --git a/src/models/operations/genlivevideotovideo.ts b/src/models/operations/genlivevideotovideo.ts new file mode 100644 index 0000000..7d6f069 --- /dev/null +++ b/src/models/operations/genlivevideotovideo.ts @@ -0,0 +1,91 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as components from "../components/index.js"; + +export type GenLiveVideoToVideoResponse = { + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; + /** + * Successful Response + */ + liveVideoToVideoResponse?: components.LiveVideoToVideoResponse | undefined; +}; + +/** @internal */ +export const GenLiveVideoToVideoResponse$inboundSchema: z.ZodType< + GenLiveVideoToVideoResponse, + z.ZodTypeDef, + unknown +> = z.object({ + ContentType: z.string(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), + LiveVideoToVideoResponse: components.LiveVideoToVideoResponse$inboundSchema + .optional(), +}).transform((v) => { + return remap$(v, { + "ContentType": "contentType", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + "LiveVideoToVideoResponse": "liveVideoToVideoResponse", + }); +}); + +/** @internal */ +export type GenLiveVideoToVideoResponse$Outbound = { + ContentType: string; + StatusCode: number; + RawResponse: never; + LiveVideoToVideoResponse?: + | components.LiveVideoToVideoResponse$Outbound + | undefined; +}; + +/** @internal */ +export const GenLiveVideoToVideoResponse$outboundSchema: z.ZodType< + GenLiveVideoToVideoResponse$Outbound, + z.ZodTypeDef, + GenLiveVideoToVideoResponse +> = z.object({ + contentType: z.string(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), + liveVideoToVideoResponse: components.LiveVideoToVideoResponse$outboundSchema + .optional(), +}).transform((v) => { + return remap$(v, { + contentType: "ContentType", + statusCode: "StatusCode", + rawResponse: "RawResponse", + liveVideoToVideoResponse: "LiveVideoToVideoResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GenLiveVideoToVideoResponse$ { + /** @deprecated use `GenLiveVideoToVideoResponse$inboundSchema` instead. */ + export const inboundSchema = GenLiveVideoToVideoResponse$inboundSchema; + /** @deprecated use `GenLiveVideoToVideoResponse$outboundSchema` instead. */ + export const outboundSchema = GenLiveVideoToVideoResponse$outboundSchema; + /** @deprecated use `GenLiveVideoToVideoResponse$Outbound` instead. */ + export type Outbound = GenLiveVideoToVideoResponse$Outbound; +} diff --git a/src/models/operations/gentexttospeech.ts b/src/models/operations/gentexttospeech.ts new file mode 100644 index 0000000..72586ca --- /dev/null +++ b/src/models/operations/gentexttospeech.ts @@ -0,0 +1,87 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { remap as remap$ } from "../../lib/primitives.js"; +import * as components from "../components/index.js"; + +export type GenTextToSpeechResponse = { + /** + * HTTP response content type for this operation + */ + contentType: string; + /** + * HTTP response status code for this operation + */ + statusCode: number; + /** + * Raw HTTP response; suitable for custom response parsing + */ + rawResponse: Response; + /** + * Successful Response + */ + audioResponse?: components.AudioResponse | undefined; +}; + +/** @internal */ +export const GenTextToSpeechResponse$inboundSchema: z.ZodType< + GenTextToSpeechResponse, + z.ZodTypeDef, + unknown +> = z.object({ + ContentType: z.string(), + StatusCode: z.number().int(), + RawResponse: z.instanceof(Response), + AudioResponse: components.AudioResponse$inboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + "ContentType": "contentType", + "StatusCode": "statusCode", + "RawResponse": "rawResponse", + "AudioResponse": "audioResponse", + }); +}); + +/** @internal */ +export type GenTextToSpeechResponse$Outbound = { + ContentType: string; + StatusCode: number; + RawResponse: never; + AudioResponse?: components.AudioResponse$Outbound | undefined; +}; + +/** @internal */ +export const GenTextToSpeechResponse$outboundSchema: z.ZodType< + GenTextToSpeechResponse$Outbound, + z.ZodTypeDef, + GenTextToSpeechResponse +> = z.object({ + contentType: z.string(), + statusCode: z.number().int(), + rawResponse: z.instanceof(Response).transform(() => { + throw new Error("Response cannot be serialized"); + }), + audioResponse: components.AudioResponse$outboundSchema.optional(), +}).transform((v) => { + return remap$(v, { + contentType: "ContentType", + statusCode: "StatusCode", + rawResponse: "RawResponse", + audioResponse: "AudioResponse", + }); +}); + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace GenTextToSpeechResponse$ { + /** @deprecated use `GenTextToSpeechResponse$inboundSchema` instead. */ + export const inboundSchema = GenTextToSpeechResponse$inboundSchema; + /** @deprecated use `GenTextToSpeechResponse$outboundSchema` instead. */ + export const outboundSchema = GenTextToSpeechResponse$outboundSchema; + /** @deprecated use `GenTextToSpeechResponse$Outbound` instead. */ + export type Outbound = GenTextToSpeechResponse$Outbound; +} diff --git a/src/models/operations/index.ts b/src/models/operations/index.ts index 657fe24..d39e63f 100644 --- a/src/models/operations/index.ts +++ b/src/models/operations/index.ts @@ -6,7 +6,9 @@ export * from "./genaudiototext.js"; export * from "./genimagetoimage.js"; export * from "./genimagetotext.js"; export * from "./genimagetovideo.js"; +export * from "./genlivevideotovideo.js"; export * from "./genllm.js"; export * from "./gensegmentanything2.js"; export * from "./gentexttoimage.js"; +export * from "./gentexttospeech.js"; export * from "./genupscale.js"; diff --git a/src/sdk/generate.ts b/src/sdk/generate.ts index 4fac35a..206746b 100644 --- a/src/sdk/generate.ts +++ b/src/sdk/generate.ts @@ -6,9 +6,11 @@ import { generateAudioToText } from "../funcs/generateAudioToText.js"; import { generateImageToImage } from "../funcs/generateImageToImage.js"; import { generateImageToText } from "../funcs/generateImageToText.js"; import { generateImageToVideo } from "../funcs/generateImageToVideo.js"; +import { generateLiveVideoToVideo } from "../funcs/generateLiveVideoToVideo.js"; import { generateLlm } from "../funcs/generateLlm.js"; import { generateSegmentAnything2 } from "../funcs/generateSegmentAnything2.js"; import { generateTextToImage } from "../funcs/generateTextToImage.js"; +import { generateTextToSpeech } from "../funcs/generateTextToSpeech.js"; import { generateUpscale } from "../funcs/generateUpscale.js"; import { ClientSDK, RequestOptions } from "../lib/sdks.js"; import * as components from "../models/components/index.js"; @@ -151,4 +153,38 @@ export class Generate extends ClientSDK { options, )); } + + /** + * Video To Video + * + * @remarks + * Apply video-like transformations to a provided image. + */ + async liveVideoToVideo( + request: components.LiveVideoToVideoParams, + options?: RequestOptions, + ): Promise { + return unwrapAsync(generateLiveVideoToVideo( + this, + request, + options, + )); + } + + /** + * Text To Speech + * + * @remarks + * Generate a text-to-speech audio file based on the provided text input and speaker description. + */ + async textToSpeech( + request: components.TextToSpeechParams, + options?: RequestOptions, + ): Promise { + return unwrapAsync(generateTextToSpeech( + this, + request, + options, + )); + } }