openai/openai-go
Publicmirrored from https://github.com/openai/openai-goAvailable
responses/inputitem_test.go
46lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | package responses_test |
| 4 | |
| 5 | import ( |
| 6 | "context" |
| 7 | "errors" |
| 8 | "os" |
| 9 | "testing" |
| 10 | |
| 11 | "github.com/openai/openai-go" |
| 12 | "github.com/openai/openai-go/internal/testutil" |
| 13 | "github.com/openai/openai-go/option" |
| 14 | "github.com/openai/openai-go/responses" |
| 15 | ) |
| 16 | |
| 17 | func TestInputItemListWithOptionalParams(t *testing.T) { |
| 18 | baseURL := "http://localhost:4010" |
| 19 | if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { |
| 20 | baseURL = envURL |
| 21 | } |
| 22 | if !testutil.CheckTestServer(t, baseURL) { |
| 23 | return |
| 24 | } |
| 25 | client := openai.NewClient( |
| 26 | option.WithBaseURL(baseURL), |
| 27 | option.WithAPIKey("My API Key"), |
| 28 | ) |
| 29 | _, err := client.Responses.InputItems.List( |
| 30 | context.TODO(), |
| 31 | "response_id", |
| 32 | responses.InputItemListParams{ |
| 33 | After: openai.String("after"), |
| 34 | Before: openai.String("before"), |
| 35 | Limit: openai.Int(0), |
| 36 | Order: responses.InputItemListParamsOrderAsc, |
| 37 | }, |
| 38 | ) |
| 39 | if err != nil { |
| 40 | var apierr *openai.Error |
| 41 | if errors.As(err, &apierr) { |
| 42 | t.Log(string(apierr.DumpRequest(true))) |
| 43 | } |
| 44 | t.Fatalf("err should be nil: %s", err.Error()) |
| 45 | } |
| 46 | } |
| 47 | |