Skip to content

Latest commit

 

History

History
295 lines (231 loc) · 14.1 KB

File metadata and controls

295 lines (231 loc) · 14.1 KB

Suggest

(Suggest)

Overview

REST APIs for managing LLM OAS suggestions

Available Operations

  • Suggest - Generate suggestions for improving an OpenAPI document.
  • SuggestItems - Generate generic suggestions for a list of items.
  • SuggestOpenAPI - (DEPRECATED) Generate suggestions for improving an OpenAPI document.
  • SuggestOpenAPIRegistry - Generate suggestions for improving an OpenAPI document stored in the registry.

Suggest

Get suggestions from an LLM model for improving an OpenAPI document.

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Suggest.Suggest(ctx, operations.SuggestRequest{
        SuggestRequestBody: shared.SuggestRequestBody{
            Diagnostics: []shared.Diagnostic{
                shared.Diagnostic{
                    Message: "<value>",
                    Path: []string{
                        "/opt/include",
                        "/opt/share",
                    },
                    Type: "<value>",
                },
                shared.Diagnostic{
                    Message: "<value>",
                    Path: []string{

                    },
                    Type: "<value>",
                },
            },
            OasSummary: shared.OASSummary{
                Info: shared.OASInfo{
                    Description: "amid traffic the unfortunately underneath what father lovely out",
                    License: shared.License{},
                    Summary: "<value>",
                    Title: "<value>",
                    Version: "<value>",
                },
                Operations: []shared.OASOperation{
                    shared.OASOperation{
                        Description: "times dull than except",
                        Method: "<value>",
                        OperationID: "<id>",
                        Path: "/mnt",
                        Tags: []string{
                            "<value>",
                            "<value>",
                        },
                    },
                },
            },
            SuggestionType: shared.SuggestRequestBodySuggestionTypeDiagnosticsOnly,
        },
        XSessionID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Schema != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.SuggestRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SuggestResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.SDKError 4XX, 5XX */*

SuggestItems

Generate generic suggestions for a list of items.

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Suggest.SuggestItems(ctx, shared.SuggestItemsRequestBody{
        Items: []string{

        },
        Prompt: "<value>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Strings != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request shared.SuggestItemsRequestBody ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SuggestItemsResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.SDKError 4XX, 5XX */*

SuggestOpenAPI

Get suggestions from an LLM model for improving an OpenAPI document.

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"os"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    content, fileErr := os.Open("example.file")
    if fileErr != nil {
        panic(fileErr)
    }


    res, err := s.Suggest.SuggestOpenAPI(ctx, operations.SuggestOpenAPIRequest{
        RequestBody: operations.SuggestOpenAPIRequestBody{
            Schema: operations.Schema{
                Content: content,
                FileName: "example.file",
            },
        },
        XSessionID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Schema != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.SuggestOpenAPIRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SuggestOpenAPIResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.SDKError 4XX, 5XX */*

SuggestOpenAPIRegistry

Get suggestions from an LLM model for improving an OpenAPI document stored in the registry.

Example Usage

package main

import(
	"context"
	speakeasyclientsdkgo "github.com/speakeasy-api/speakeasy-client-sdk-go/v3"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/shared"
	"github.com/speakeasy-api/speakeasy-client-sdk-go/v3/pkg/models/operations"
	"log"
)

func main() {
    ctx := context.Background()
    
    s := speakeasyclientsdkgo.New(
        speakeasyclientsdkgo.WithSecurity(shared.Security{
            APIKey: speakeasyclientsdkgo.String("<YOUR_API_KEY_HERE>"),
        }),
    )

    res, err := s.Suggest.SuggestOpenAPIRegistry(ctx, operations.SuggestOpenAPIRegistryRequest{
        NamespaceName: "<value>",
        RevisionReference: "<value>",
        XSessionID: "<id>",
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Schema != nil {
        // handle response
    }
}

Parameters

Parameter Type Required Description
ctx context.Context ✔️ The context to use for the request.
request operations.SuggestOpenAPIRegistryRequest ✔️ The request object to use for the request.
opts []operations.Option The options for this request.

Response

*operations.SuggestOpenAPIRegistryResponse, error

Errors

Error Type Status Code Content Type
sdkerrors.SDKError 4XX, 5XX */*