From e969561ea0a3615e0582c217ebba8b8d6c610ee1 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:34 +0200 Subject: [PATCH] ci: regenerated with OpenAPI Doc , Speakeasy CLI 1.421.2 (#13) Co-authored-by: speakeasybot --- .speakeasy/gen.lock | 30 +- .speakeasy/gen.yaml | 2 +- .speakeasy/workflow.lock | 12 +- RELEASES.md | 12 +- codeSamples.yaml | 40 ++ docs/models/components/bodygenimagetotext.md | 10 + .../components/bodygenimagetotextimage.md | 9 + docs/models/components/imagetotextresponse.md | 10 + .../operations/genimagetotextresponse.md | 9 + generate.go | 456 +++++++++++------- internal/utils/utils.go | 14 + livepeer.go | 8 +- models/components/bodygenimagetotext.go | 68 +++ models/components/imagetotextresponse.go | 16 + models/operations/genimagetotext.go | 27 ++ 15 files changed, 544 insertions(+), 179 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 models/components/bodygenimagetotext.go create mode 100644 models/components/imagetotextresponse.go create mode 100644 models/operations/genimagetotext.go diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index f627a48..d2fa8c2 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,18 +1,19 @@ lockVersion: 2.0.0 id: 98621ff3-f200-4a5c-9c69-bc1fe845e39c management: - docChecksum: 21334b8071b6c8e28a5dda229ceafd7e - speakeasyVersion: 1.405.6 - generationVersion: 2.428.1 - releaseVersion: 0.4.2 - configChecksum: d3dbfe289ca80fa4bf7e37f2d53d1f2f + docChecksum: a140881cbcff74961991f5dfff13f0a0 + docVersion: 0.0.0 + speakeasyVersion: 1.421.2 + generationVersion: 2.438.15 + releaseVersion: 0.4.3 + configChecksum: c6fd68f564c3f98964f8fd3bc391d9d4 repoURL: https://github.com/livepeer/livepeer-ai-go.git installationURL: https://github.com/livepeer/livepeer-ai-go features: go: additionalDependencies: 0.1.0 constsAndDefaults: 0.1.6 - core: 3.5.12 + core: 3.5.13 defaultEnabledRetries: 0.2.0 envVarSecurityUsage: 0.3.1 globalSecurity: 2.82.10 @@ -31,6 +32,7 @@ generatedFiles: - /models/components/apierror.go - /models/components/bodygenaudiototext.go - /models/components/bodygenimagetoimage.go + - /models/components/bodygenimagetotext.go - /models/components/bodygenimagetovideo.go - /models/components/bodygenllm.go - /models/components/bodygensegmentanything2.go @@ -38,6 +40,7 @@ generatedFiles: - /models/components/chunk.go - /models/components/httpmetadata.go - /models/components/imageresponse.go + - /models/components/imagetotextresponse.go - /models/components/llmresponse.go - /models/components/masksresponse.go - /models/components/media.go @@ -48,6 +51,7 @@ generatedFiles: - /models/components/videoresponse.go - /models/operations/genaudiototext.go - /models/operations/genimagetoimage.go + - /models/operations/genimagetotext.go - /models/operations/genimagetovideo.go - /models/operations/genllm.go - /models/operations/gensegmentanything2.go @@ -61,6 +65,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 @@ -72,6 +78,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 @@ -83,6 +90,7 @@ generatedFiles: - docs/models/components/videoresponse.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 @@ -243,3 +251,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 4126d80..b108573 100644 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -12,7 +12,7 @@ generation: auth: oAuth2ClientCredentialsEnabled: true go: - version: 0.4.2 + version: 0.4.3 additionalDependencies: {} allowUnknownFieldsInWeakUnions: false clientServerStatusCodesAsErrors: true diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 960c860..04fb85a 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,9 +1,9 @@ -speakeasyVersion: 1.405.6 +speakeasyVersion: 1.421.2 sources: livepeerai-OAS: sourceNamespace: livepeerai-oas - sourceRevisionDigest: sha256:ce56b1741c39f98c5d10419ed7aa8c1cf07891fbae7603bffaf06e9d26887f6f - sourceBlobDigest: sha256:1381f76cad0ec28b51d5559fdf87a0b14f39e2946fe25e0c21c0b8b0fe42cf99 + sourceRevisionDigest: sha256:42e3e9a25622d367c70f1f200afa559ec6a2c4d9b65014dd76da56f8e1beb487 + sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f tags: - latest - main @@ -16,10 +16,10 @@ targets: livepeerai-go: source: livepeerai-OAS sourceNamespace: livepeerai-oas - sourceRevisionDigest: sha256:ce56b1741c39f98c5d10419ed7aa8c1cf07891fbae7603bffaf06e9d26887f6f - sourceBlobDigest: sha256:1381f76cad0ec28b51d5559fdf87a0b14f39e2946fe25e0c21c0b8b0fe42cf99 + sourceRevisionDigest: sha256:42e3e9a25622d367c70f1f200afa559ec6a2c4d9b65014dd76da56f8e1beb487 + sourceBlobDigest: sha256:ad0b2e92bea306b60b1929309669cb1c3ca574325bb0ab4a2e44949fc8249a9f codeSamplesNamespace: code-samples-go-livepeerai-go - codeSamplesRevisionDigest: sha256:3d64aa7d5bea2f7f5de1d27ed652fea89c378343d47c113ee35aca504f954ecd + codeSamplesRevisionDigest: sha256:36bfad51481a38664404f8053d44846222f0d7fa53c6f1462a5bd1a1e284bd08 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/RELEASES.md b/RELEASES.md index d3eee2a..254638e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -78,4 +78,14 @@ Based on: ### Generated - [go v0.4.2] . ### Releases -- [Go v0.4.2] https://github.com/livepeer/livepeer-ai-go/releases/tag/v0.4.2 - . \ No newline at end of file +- [Go v0.4.2] https://github.com/livepeer/livepeer-ai-go/releases/tag/v0.4.2 - . + +## 2024-10-25 00:26:22 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.421.2 (2.438.15) https://github.com/speakeasy-api/speakeasy +### Generated +- [go v0.4.3] . +### Releases +- [Go v0.4.3] https://github.com/livepeer/livepeer-ai-go/releases/tag/v0.4.3 - . \ No newline at end of file diff --git a/codeSamples.yaml b/codeSamples.yaml index 4d309b6..61e7f01 100644 --- a/codeSamples.yaml +++ b/codeSamples.yaml @@ -84,6 +84,46 @@ actions: // handle response } } + - target: $["paths"]["/image-to-text"]["post"] + update: + x-codeSamples: + - lang: go + label: genImageToText + source: |- + package main + + import( + livepeeraigo "github.com/livepeer/livepeer-ai-go" + "os" + "context" + "github.com/livepeer/livepeer-ai-go/models/components" + "log" + ) + + func main() { + s := livepeeraigo.New( + livepeeraigo.WithSecurity(""), + ) + + content, fileErr := os.Open("example.file") + if fileErr != nil { + panic(fileErr) + } + + ctx := context.Background() + res, err := s.Generate.ImageToText(ctx, components.BodyGenImageToText{ + Image: components.BodyGenImageToTextImage{ + FileName: "example.file", + Content: content, + }, + }) + if err != nil { + log.Fatal(err) + } + if res.ImageToTextResponse != nil { + // handle response + } + } - 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..786c4c9 --- /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` | **string* | :heavy_minus_sign: | Text prompt(s) to guide transformation. | +| `ModelID` | **string* | :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..bfe894a --- /dev/null +++ b/docs/models/components/bodygenimagetotextimage.md @@ -0,0 +1,9 @@ +# BodyGenImageToTextImage + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `FileName` | *string* | :heavy_check_mark: | N/A | +| `Content` | *any* | :heavy_check_mark: | 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..bfb9d39 --- /dev/null +++ b/docs/models/components/imagetotextresponse.md @@ -0,0 +1,10 @@ +# ImageToTextResponse + +Response model for text generation. + + +## Fields + +| Field | Type | Required | Description | +| ------------------- | ------------------- | ------------------- | ------------------- | +| `Text` | *string* | :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..7877137 --- /dev/null +++ b/docs/models/operations/genimagetotextresponse.md @@ -0,0 +1,9 @@ +# GenImageToTextResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ImageToTextResponse` | [*components.ImageToTextResponse](../../models/components/imagetotextresponse.md) | :heavy_minus_sign: | Successful Response | \ No newline at end of file diff --git a/generate.go b/generate.go index 2c5eb2f..146812c 100644 --- a/generate.go +++ b/generate.go @@ -12,7 +12,6 @@ import ( "github.com/livepeer/livepeer-ai-go/models/components" "github.com/livepeer/livepeer-ai-go/models/operations" "github.com/livepeer/livepeer-ai-go/models/sdkerrors" - "io" "net/http" "net/url" ) @@ -175,21 +174,11 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -201,11 +190,10 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma res.ImageResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: @@ -215,7 +203,7 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -227,17 +215,16 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -249,28 +236,25 @@ func (s *Generate) TextToImage(ctx context.Context, request components.TextToIma return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -426,21 +410,11 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -452,11 +426,10 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI res.ImageResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: @@ -466,7 +439,7 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -478,17 +451,16 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -500,28 +472,25 @@ func (s *Generate) ImageToImage(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -677,21 +646,11 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -703,11 +662,10 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI res.VideoResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: @@ -717,7 +675,7 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -729,17 +687,16 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -751,28 +708,25 @@ func (s *Generate) ImageToVideo(ctx context.Context, request components.BodyGenI return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -928,21 +882,11 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -954,11 +898,10 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal res.ImageResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: @@ -968,7 +911,7 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -980,17 +923,16 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1002,28 +944,25 @@ func (s *Generate) Upscale(ctx context.Context, request components.BodyGenUpscal return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1157,7 +1096,7 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) return nil, err - } else if utils.MatchStatusCodes([]string{"400", "401", "413", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { + } else if utils.MatchStatusCodes([]string{"400", "401", "413", "415", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) if err != nil { return nil, err @@ -1179,21 +1118,11 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1205,11 +1134,10 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu res.TextResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: @@ -1218,10 +1146,12 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu fallthrough case httpRes.StatusCode == 413: fallthrough + case httpRes.StatusCode == 415: + fallthrough case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1233,17 +1163,16 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1255,28 +1184,25 @@ func (s *Generate) AudioToText(ctx context.Context, request components.BodyGenAu return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1432,21 +1358,11 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) - if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) - } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil - } - switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1458,11 +1374,10 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body res.MasksResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: @@ -1472,7 +1387,7 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1484,17 +1399,16 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1506,28 +1420,25 @@ func (s *Generate) SegmentAnything2(ctx context.Context, request components.Body return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } @@ -1683,47 +1594,274 @@ func (s *Generate) Llm(ctx context.Context, request components.BodyGenLLM, opts }, } - getRawBody := func() ([]byte, error) { - rawBody, err := io.ReadAll(httpRes.Body) + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.LLMResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.LLMResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 401: + fallthrough + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.HTTPError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 422: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out sdkerrors.HTTPValidationError + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + fallthrough + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { - return nil, fmt.Errorf("error reading response body: %w", err) + return nil, err } - httpRes.Body.Close() - httpRes.Body = io.NopCloser(bytes.NewBuffer(rawBody)) - return rawBody, nil + return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// ImageToText - Image To Text +// Transform image files to text. +func (s *Generate) ImageToText(ctx context.Context, request components.BodyGenImageToText, opts ...operations.Option) (*operations.GenImageToTextResponse, error) { + hookCtx := hooks.HookContext{ + Context: ctx, + OperationID: "genImageToText", + OAuth2Scopes: []string{}, + SecuritySource: s.sdkConfiguration.Security, + } + + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + baseURL := utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + opURL, err := url.JoinPath(baseURL, "/image-to-text") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "multipart", `request:"mediaType=multipart/form-data"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + req.Header.Set("Content-Type", reqContentType) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil { + copyBody, err := req.GetBody() + if err != nil { + return nil, err + } + req.Body = copyBody + } + + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, backoff.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.sdkConfiguration.Hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "401", "413", "422", "4XX", "500", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.sdkConfiguration.Hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.sdkConfiguration.Hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GenImageToTextResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, } switch { case httpRes.StatusCode == 200: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - var out components.LLMResponse + var out components.ImageToTextResponse if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { return nil, err } - res.LLMResponse = &out + res.ImageToTextResponse = &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 400: fallthrough case httpRes.StatusCode == 401: fallthrough + case httpRes.StatusCode == 413: + fallthrough case httpRes.StatusCode == 500: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1735,17 +1873,16 @@ func (s *Generate) Llm(ctx context.Context, request components.BodyGenLLM, opts return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode == 422: switch { case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } @@ -1757,28 +1894,25 @@ func (s *Generate) Llm(ctx context.Context, request components.BodyGenLLM, opts return nil, &out default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) } case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: fallthrough case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) default: - rawBody, err := getRawBody() + rawBody, err := utils.ConsumeRawBody(httpRes) if err != nil { return nil, err } - return nil, sdkerrors.NewSDKError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) } diff --git a/internal/utils/utils.go b/internal/utils/utils.go index adb2f70..f1ff9e0 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -3,10 +3,12 @@ package utils import ( + "bytes" "context" "fmt" "io" "math/big" + "net/http" "reflect" "regexp" "strconv" @@ -228,3 +230,15 @@ func contains(arr []string, str string) bool { } return false } + +func ConsumeRawBody(res *http.Response) ([]byte, error) { + rawBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + + res.Body.Close() + res.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + return rawBody, nil +} diff --git a/livepeer.go b/livepeer.go index 0151b95..50a6141 100644 --- a/livepeer.go +++ b/livepeer.go @@ -150,10 +150,10 @@ func New(opts ...SDKOption) *Livepeer { sdk := &Livepeer{ sdkConfiguration: sdkConfiguration{ Language: "go", - OpenAPIDocVersion: "", - SDKVersion: "0.4.2", - GenVersion: "2.428.1", - UserAgent: "speakeasy-sdk/go 0.4.2 2.428.1 github.com/livepeer/livepeer-ai-go", + OpenAPIDocVersion: "0.0.0", + SDKVersion: "0.4.3", + GenVersion: "2.438.15", + UserAgent: "speakeasy-sdk/go 0.4.3 2.438.15 0.0.0 github.com/livepeer/livepeer-ai-go", Hooks: hooks.New(), }, } diff --git a/models/components/bodygenimagetotext.go b/models/components/bodygenimagetotext.go new file mode 100644 index 0000000..f92a2a5 --- /dev/null +++ b/models/components/bodygenimagetotext.go @@ -0,0 +1,68 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/livepeer/livepeer-ai-go/internal/utils" +) + +type BodyGenImageToTextImage struct { + FileName string `multipartForm:"name=image"` + // This field accepts []byte data or io.Reader implementations, such as *os.File. + Content any `multipartForm:"content"` +} + +func (o *BodyGenImageToTextImage) GetFileName() string { + if o == nil { + return "" + } + return o.FileName +} + +func (o *BodyGenImageToTextImage) GetContent() any { + if o == nil { + return nil + } + return o.Content +} + +type BodyGenImageToText struct { + // Uploaded image to transform with the pipeline. + Image BodyGenImageToTextImage `multipartForm:"file"` + // Text prompt(s) to guide transformation. + Prompt *string `default:"" multipartForm:"name=prompt"` + // Hugging Face model ID used for transformation. + ModelID *string `default:"" multipartForm:"name=model_id"` +} + +func (b BodyGenImageToText) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(b, "", false) +} + +func (b *BodyGenImageToText) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &b, "", false, false); err != nil { + return err + } + return nil +} + +func (o *BodyGenImageToText) GetImage() BodyGenImageToTextImage { + if o == nil { + return BodyGenImageToTextImage{} + } + return o.Image +} + +func (o *BodyGenImageToText) GetPrompt() *string { + if o == nil { + return nil + } + return o.Prompt +} + +func (o *BodyGenImageToText) GetModelID() *string { + if o == nil { + return nil + } + return o.ModelID +} diff --git a/models/components/imagetotextresponse.go b/models/components/imagetotextresponse.go new file mode 100644 index 0000000..c3d5635 --- /dev/null +++ b/models/components/imagetotextresponse.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +// ImageToTextResponse - Response model for text generation. +type ImageToTextResponse struct { + // The generated text. + Text string `json:"text"` +} + +func (o *ImageToTextResponse) GetText() string { + if o == nil { + return "" + } + return o.Text +} diff --git a/models/operations/genimagetotext.go b/models/operations/genimagetotext.go new file mode 100644 index 0000000..fdf1e07 --- /dev/null +++ b/models/operations/genimagetotext.go @@ -0,0 +1,27 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/livepeer/livepeer-ai-go/models/components" +) + +type GenImageToTextResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Successful Response + ImageToTextResponse *components.ImageToTextResponse +} + +func (o *GenImageToTextResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *GenImageToTextResponse) GetImageToTextResponse() *components.ImageToTextResponse { + if o == nil { + return nil + } + return o.ImageToTextResponse +}