-
Notifications
You must be signed in to change notification settings - Fork 553
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
532a406
commit 4ae1c56
Showing
80 changed files
with
5,159 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
configured_endpoints: 1147 | ||
configured_endpoints: 1158 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// File generated from our OpenAPI spec by Stainless. | ||
|
||
package cloudflare | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/cloudflare/cloudflare-sdk-go/internal/apijson" | ||
"github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig" | ||
"github.com/cloudflare/cloudflare-sdk-go/option" | ||
) | ||
|
||
// AIService contains methods and other services that help with interacting with | ||
// the cloudflare API. Note, unlike clients, this service does not read variables | ||
// from the environment automatically. You should not instantiate this service | ||
// directly, and instead use the [NewAIService] method instead. | ||
type AIService struct { | ||
Options []option.RequestOption | ||
Huggingface *AIHuggingfaceService | ||
Baai *AIBaaiService | ||
OpenAI *AIOpenAIService | ||
Microsoft *AIMicrosoftService | ||
Meta *AIMetaService | ||
Mistral *AIMistralService | ||
} | ||
|
||
// NewAIService generates a new service that applies the given options to each | ||
// request. These options are applied after the parent client's options (if there | ||
// is one), and before any request-specific options. | ||
func NewAIService(opts ...option.RequestOption) (r *AIService) { | ||
r = &AIService{} | ||
r.Options = opts | ||
r.Huggingface = NewAIHuggingfaceService(opts...) | ||
r.Baai = NewAIBaaiService(opts...) | ||
r.OpenAI = NewAIOpenAIService(opts...) | ||
r.Microsoft = NewAIMicrosoftService(opts...) | ||
r.Meta = NewAIMetaService(opts...) | ||
r.Mistral = NewAIMistralService(opts...) | ||
return | ||
} | ||
|
||
// This endpoint provides users with the capability to run specific AI models | ||
// on-demand. | ||
// | ||
// By submitting the required input data, users can receive real-time predictions | ||
// or results generated by the chosen AI model. The endpoint supports various AI | ||
// model types, ensuring flexibility and adaptability for diverse use cases. | ||
func (r *AIService) Run(ctx context.Context, accountIdentifier string, modelName string, body AIRunParams, opts ...option.RequestOption) (res *AIRunResponse, err error) { | ||
opts = append(r.Options[:], opts...) | ||
path := fmt.Sprintf("apiv4/accounts/%s/ai/run/%s", accountIdentifier, modelName) | ||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) | ||
return | ||
} | ||
|
||
type AIRunResponse struct { | ||
Errors []AIRunResponseError `json:"errors,required"` | ||
Messages []string `json:"messages,required"` | ||
Result interface{} `json:"result,required"` | ||
Success bool `json:"success,required"` | ||
JSON aiRunResponseJSON `json:"-"` | ||
} | ||
|
||
// aiRunResponseJSON contains the JSON metadata for the struct [AIRunResponse] | ||
type aiRunResponseJSON struct { | ||
Errors apijson.Field | ||
Messages apijson.Field | ||
Result apijson.Field | ||
Success apijson.Field | ||
raw string | ||
ExtraFields map[string]apijson.Field | ||
} | ||
|
||
func (r *AIRunResponse) UnmarshalJSON(data []byte) (err error) { | ||
return apijson.UnmarshalRoot(data, r) | ||
} | ||
|
||
type AIRunResponseError struct { | ||
Message string `json:"message,required"` | ||
JSON aiRunResponseErrorJSON `json:"-"` | ||
} | ||
|
||
// aiRunResponseErrorJSON contains the JSON metadata for the struct | ||
// [AIRunResponseError] | ||
type aiRunResponseErrorJSON struct { | ||
Message apijson.Field | ||
raw string | ||
ExtraFields map[string]apijson.Field | ||
} | ||
|
||
func (r *AIRunResponseError) UnmarshalJSON(data []byte) (err error) { | ||
return apijson.UnmarshalRoot(data, r) | ||
} | ||
|
||
type AIRunParams struct { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// File generated from our OpenAPI spec by Stainless. | ||
|
||
package cloudflare_test | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os" | ||
"testing" | ||
|
||
"github.com/cloudflare/cloudflare-sdk-go" | ||
"github.com/cloudflare/cloudflare-sdk-go/internal/testutil" | ||
"github.com/cloudflare/cloudflare-sdk-go/option" | ||
) | ||
|
||
func TestAIRun(t *testing.T) { | ||
baseURL := "http://localhost:4010" | ||
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { | ||
baseURL = envURL | ||
} | ||
if !testutil.CheckTestServer(t, baseURL) { | ||
return | ||
} | ||
client := cloudflare.NewClient( | ||
option.WithBaseURL(baseURL), | ||
option.WithAPIKey("my-cloudflare-api-key"), | ||
option.WithEmail("dev@cloudflare.com"), | ||
) | ||
_, err := client.AI.Run( | ||
context.TODO(), | ||
"023e105f4ecef8ad9ca31a8372d0c353", | ||
"string", | ||
cloudflare.AIRunParams{}, | ||
) | ||
if err != nil { | ||
var apierr *cloudflare.Error | ||
if errors.As(err, &apierr) { | ||
t.Log(string(apierr.DumpRequest(true))) | ||
} | ||
t.Fatalf("err should be nil: %s", err.Error()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
// File generated from our OpenAPI spec by Stainless. | ||
|
||
package cloudflare | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"net/http" | ||
|
||
"github.com/cloudflare/cloudflare-sdk-go/internal/apijson" | ||
"github.com/cloudflare/cloudflare-sdk-go/internal/param" | ||
"github.com/cloudflare/cloudflare-sdk-go/internal/requestconfig" | ||
"github.com/cloudflare/cloudflare-sdk-go/option" | ||
) | ||
|
||
// AIBaaiService contains methods and other services that help with interacting | ||
// with the cloudflare API. Note, unlike clients, this service does not read | ||
// variables from the environment automatically. You should not instantiate this | ||
// service directly, and instead use the [NewAIBaaiService] method instead. | ||
type AIBaaiService struct { | ||
Options []option.RequestOption | ||
} | ||
|
||
// NewAIBaaiService generates a new service that applies the given options to each | ||
// request. These options are applied after the parent client's options (if there | ||
// is one), and before any request-specific options. | ||
func NewAIBaaiService(opts ...option.RequestOption) (r *AIBaaiService) { | ||
r = &AIBaaiService{} | ||
r.Options = opts | ||
return | ||
} | ||
|
||
// Execute @cf/baai/bge-base-en-v1.5 model. | ||
func (r *AIBaaiService) BgeBaseEnV1_5(ctx context.Context, accountIdentifier string, body AIBaaiBgeBaseEnV1_5Params, opts ...option.RequestOption) (res *AIBaaiBgeBaseEnV1_5Response, err error) { | ||
opts = append(r.Options[:], opts...) | ||
path := fmt.Sprintf("apiv4/accounts/%s/ai/run/@cf/baai/bge-base-en-v1.5", accountIdentifier) | ||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) | ||
return | ||
} | ||
|
||
// Execute @cf/baai/bge-large-en-v1.5 model. | ||
func (r *AIBaaiService) BgeLargeEnV1_5(ctx context.Context, accountIdentifier string, body AIBaaiBgeLargeEnV1_5Params, opts ...option.RequestOption) (res *AIBaaiBgeLargeEnV1_5Response, err error) { | ||
opts = append(r.Options[:], opts...) | ||
path := fmt.Sprintf("apiv4/accounts/%s/ai/run/@cf/baai/bge-large-en-v1.5", accountIdentifier) | ||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) | ||
return | ||
} | ||
|
||
// Execute @cf/baai/bge-small-en-v1.5 model. | ||
func (r *AIBaaiService) BgeSmallEnV1_5(ctx context.Context, accountIdentifier string, body AIBaaiBgeSmallEnV1_5Params, opts ...option.RequestOption) (res *AIBaaiBgeSmallEnV1_5Response, err error) { | ||
opts = append(r.Options[:], opts...) | ||
path := fmt.Sprintf("apiv4/accounts/%s/ai/run/@cf/baai/bge-small-en-v1.5", accountIdentifier) | ||
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...) | ||
return | ||
} | ||
|
||
type AIBaaiBgeBaseEnV1_5Response struct { | ||
Data [][]float64 `json:"data"` | ||
Shape []float64 `json:"shape"` | ||
JSON aiBaaiBgeBaseEnV1_5ResponseJSON `json:"-"` | ||
} | ||
|
||
// aiBaaiBgeBaseEnV1_5ResponseJSON contains the JSON metadata for the struct | ||
// [AIBaaiBgeBaseEnV1_5Response] | ||
type aiBaaiBgeBaseEnV1_5ResponseJSON struct { | ||
Data apijson.Field | ||
Shape apijson.Field | ||
raw string | ||
ExtraFields map[string]apijson.Field | ||
} | ||
|
||
func (r *AIBaaiBgeBaseEnV1_5Response) UnmarshalJSON(data []byte) (err error) { | ||
return apijson.UnmarshalRoot(data, r) | ||
} | ||
|
||
type AIBaaiBgeLargeEnV1_5Response struct { | ||
Data [][]float64 `json:"data"` | ||
Shape []float64 `json:"shape"` | ||
JSON aiBaaiBgeLargeEnV1_5ResponseJSON `json:"-"` | ||
} | ||
|
||
// aiBaaiBgeLargeEnV1_5ResponseJSON contains the JSON metadata for the struct | ||
// [AIBaaiBgeLargeEnV1_5Response] | ||
type aiBaaiBgeLargeEnV1_5ResponseJSON struct { | ||
Data apijson.Field | ||
Shape apijson.Field | ||
raw string | ||
ExtraFields map[string]apijson.Field | ||
} | ||
|
||
func (r *AIBaaiBgeLargeEnV1_5Response) UnmarshalJSON(data []byte) (err error) { | ||
return apijson.UnmarshalRoot(data, r) | ||
} | ||
|
||
type AIBaaiBgeSmallEnV1_5Response struct { | ||
Data [][]float64 `json:"data"` | ||
Shape []float64 `json:"shape"` | ||
JSON aiBaaiBgeSmallEnV1_5ResponseJSON `json:"-"` | ||
} | ||
|
||
// aiBaaiBgeSmallEnV1_5ResponseJSON contains the JSON metadata for the struct | ||
// [AIBaaiBgeSmallEnV1_5Response] | ||
type aiBaaiBgeSmallEnV1_5ResponseJSON struct { | ||
Data apijson.Field | ||
Shape apijson.Field | ||
raw string | ||
ExtraFields map[string]apijson.Field | ||
} | ||
|
||
func (r *AIBaaiBgeSmallEnV1_5Response) UnmarshalJSON(data []byte) (err error) { | ||
return apijson.UnmarshalRoot(data, r) | ||
} | ||
|
||
type AIBaaiBgeBaseEnV1_5Params struct { | ||
Text param.Field[AIBaaiBgeBaseEnV1_5ParamsText] `json:"text,required"` | ||
} | ||
|
||
func (r AIBaaiBgeBaseEnV1_5Params) MarshalJSON() (data []byte, err error) { | ||
return apijson.MarshalRoot(r) | ||
} | ||
|
||
// Satisfied by [shared.UnionString], [AIBaaiBgeBaseEnV1_5ParamsTextObject]. | ||
type AIBaaiBgeBaseEnV1_5ParamsText interface { | ||
ImplementsAIBaaiBgeBaseEnV1_5ParamsText() | ||
} | ||
|
||
type AIBaaiBgeLargeEnV1_5Params struct { | ||
Text param.Field[AIBaaiBgeLargeEnV1_5ParamsText] `json:"text,required"` | ||
} | ||
|
||
func (r AIBaaiBgeLargeEnV1_5Params) MarshalJSON() (data []byte, err error) { | ||
return apijson.MarshalRoot(r) | ||
} | ||
|
||
// Satisfied by [shared.UnionString], [AIBaaiBgeLargeEnV1_5ParamsTextObject]. | ||
type AIBaaiBgeLargeEnV1_5ParamsText interface { | ||
ImplementsAIBaaiBgeLargeEnV1_5ParamsText() | ||
} | ||
|
||
type AIBaaiBgeSmallEnV1_5Params struct { | ||
Text param.Field[AIBaaiBgeSmallEnV1_5ParamsText] `json:"text,required"` | ||
} | ||
|
||
func (r AIBaaiBgeSmallEnV1_5Params) MarshalJSON() (data []byte, err error) { | ||
return apijson.MarshalRoot(r) | ||
} | ||
|
||
// Satisfied by [shared.UnionString], [AIBaaiBgeSmallEnV1_5ParamsTextObject]. | ||
type AIBaaiBgeSmallEnV1_5ParamsText interface { | ||
ImplementsAIBaaiBgeSmallEnV1_5ParamsText() | ||
} |
Oops, something went wrong.