mirror of
https://github.com/openai/openai-go.git
synced 2026-04-01 09:07:22 +09:00
131 lines
3.4 KiB
Go
131 lines
3.4 KiB
Go
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
|
|
package openai_test
|
|
|
|
import (
|
|
"context"
|
|
"errors"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/openai/openai-go/v3"
|
|
"github.com/openai/openai-go/v3/internal/testutil"
|
|
"github.com/openai/openai-go/v3/option"
|
|
)
|
|
|
|
func TestFineTuningCheckpointPermissionNew(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 := openai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.FineTuning.Checkpoints.Permissions.New(
|
|
context.TODO(),
|
|
"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd",
|
|
openai.FineTuningCheckpointPermissionNewParams{
|
|
ProjectIDs: []string{"string"},
|
|
},
|
|
)
|
|
if err != nil {
|
|
var apierr *openai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestFineTuningCheckpointPermissionGetWithOptionalParams(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 := openai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.FineTuning.Checkpoints.Permissions.Get(
|
|
context.TODO(),
|
|
"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
|
|
openai.FineTuningCheckpointPermissionGetParams{
|
|
After: openai.String("after"),
|
|
Limit: openai.Int(0),
|
|
Order: openai.FineTuningCheckpointPermissionGetParamsOrderAscending,
|
|
ProjectID: openai.String("project_id"),
|
|
},
|
|
)
|
|
if err != nil {
|
|
var apierr *openai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestFineTuningCheckpointPermissionListWithOptionalParams(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 := openai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.FineTuning.Checkpoints.Permissions.List(
|
|
context.TODO(),
|
|
"ft-AF1WoRqd3aJAHsqc9NY7iL8F",
|
|
openai.FineTuningCheckpointPermissionListParams{
|
|
After: openai.String("after"),
|
|
Limit: openai.Int(0),
|
|
Order: openai.FineTuningCheckpointPermissionListParamsOrderAscending,
|
|
ProjectID: openai.String("project_id"),
|
|
},
|
|
)
|
|
if err != nil {
|
|
var apierr *openai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|
|
|
|
func TestFineTuningCheckpointPermissionDelete(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 := openai.NewClient(
|
|
option.WithBaseURL(baseURL),
|
|
option.WithAPIKey("My API Key"),
|
|
)
|
|
_, err := client.FineTuning.Checkpoints.Permissions.Delete(
|
|
context.TODO(),
|
|
"ft:gpt-4o-mini-2024-07-18:org:weather:B7R9VjQd",
|
|
"cp_zc4Q7MP6XxulcVzj4MZdwsAB",
|
|
)
|
|
if err != nil {
|
|
var apierr *openai.Error
|
|
if errors.As(err, &apierr) {
|
|
t.Log(string(apierr.DumpRequest(true)))
|
|
}
|
|
t.Fatalf("err should be nil: %s", err.Error())
|
|
}
|
|
}
|