diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 52b3e83..a899ac7 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.30" + ".": "0.1.0-alpha.31" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index e1a430e..0b08725 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 68 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-f9320ebf347140052c7f8b0bc5c7db24f5e367c368c8cb34c3606af4e2b6591b.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b60d5559d5150ecd3b49136064e5e251d832899770ff385b711378389afba370.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a9c6c3..8b91132 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.1.0-alpha.31 (2024-10-23) + +Full Changelog: [v0.1.0-alpha.30...v0.1.0-alpha.31](https://github.com/openai/openai-go/compare/v0.1.0-alpha.30...v0.1.0-alpha.31) + +### Chores + +* **internal:** update spec version ([#95](https://github.com/openai/openai-go/issues/95)) ([0cb6f6a](https://github.com/openai/openai-go/commit/0cb6f6abd428a5bd314902708ab12bc12a1b978f)) + ## 0.1.0-alpha.30 (2024-10-22) Full Changelog: [v0.1.0-alpha.29...v0.1.0-alpha.30](https://github.com/openai/openai-go/compare/v0.1.0-alpha.29...v0.1.0-alpha.30) diff --git a/README.md b/README.md index 325f3d5..99414bd 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Or to pin the version: ```sh -go get -u 'github.com/openai/openai-go@v0.1.0-alpha.30' +go get -u 'github.com/openai/openai-go@v0.1.0-alpha.31' ``` diff --git a/api.md b/api.md index b373184..1bbc889 100644 --- a/api.md +++ b/api.md @@ -90,6 +90,7 @@ Params Types: Response Types: +- openai.FileContent - openai.FileDeleted - openai.FileObject @@ -100,6 +101,7 @@ Methods: - client.Files.List(ctx context.Context, query openai.FileListParams) (pagination.Page[openai.FileObject], error) - client.Files.Delete(ctx context.Context, fileID string) (openai.FileDeleted, error) - client.Files.Content(ctx context.Context, fileID string) (http.Response, error) +- client.Files.GetContent(ctx context.Context, fileID string) (openai.FileContent, error) # Images diff --git a/betathread.go b/betathread.go index 0a22d52..84dba0c 100644 --- a/betathread.go +++ b/betathread.go @@ -218,7 +218,7 @@ func (r AssistantToolChoiceFunctionParam) MarshalJSON() (data []byte, err error) // `{"type": "function", "function": {"name": "my_function"}}` forces the model to // call that tool. // -// Union satisfied by [AssistantToolChoiceOptionString] or [AssistantToolChoice]. +// Union satisfied by [AssistantToolChoiceOptionBehavior] or [AssistantToolChoice]. type AssistantToolChoiceOptionUnion interface { implementsAssistantToolChoiceOptionUnion() } @@ -229,7 +229,7 @@ func init() { "", apijson.UnionVariant{ TypeFilter: gjson.String, - Type: reflect.TypeOf(AssistantToolChoiceOptionString("")), + Type: reflect.TypeOf(AssistantToolChoiceOptionBehavior("")), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, @@ -242,25 +242,25 @@ func init() { // `auto` means the model can pick between generating a message or calling one or // more tools. `required` means the model must call one or more tools before // responding to the user. -type AssistantToolChoiceOptionString string +type AssistantToolChoiceOptionBehavior string const ( - AssistantToolChoiceOptionStringNone AssistantToolChoiceOptionString = "none" - AssistantToolChoiceOptionStringAuto AssistantToolChoiceOptionString = "auto" - AssistantToolChoiceOptionStringRequired AssistantToolChoiceOptionString = "required" + AssistantToolChoiceOptionBehaviorNone AssistantToolChoiceOptionBehavior = "none" + AssistantToolChoiceOptionBehaviorAuto AssistantToolChoiceOptionBehavior = "auto" + AssistantToolChoiceOptionBehaviorRequired AssistantToolChoiceOptionBehavior = "required" ) -func (r AssistantToolChoiceOptionString) IsKnown() bool { +func (r AssistantToolChoiceOptionBehavior) IsKnown() bool { switch r { - case AssistantToolChoiceOptionStringNone, AssistantToolChoiceOptionStringAuto, AssistantToolChoiceOptionStringRequired: + case AssistantToolChoiceOptionBehaviorNone, AssistantToolChoiceOptionBehaviorAuto, AssistantToolChoiceOptionBehaviorRequired: return true } return false } -func (r AssistantToolChoiceOptionString) implementsAssistantToolChoiceOptionUnion() {} +func (r AssistantToolChoiceOptionBehavior) implementsAssistantToolChoiceOptionUnion() {} -func (r AssistantToolChoiceOptionString) implementsAssistantToolChoiceOptionUnionParam() {} +func (r AssistantToolChoiceOptionBehavior) implementsAssistantToolChoiceOptionUnionParam() {} // Controls which (if any) tool is called by the model. `none` means the model will // not call any tools and instead generates a message. `auto` is the default value @@ -270,7 +270,7 @@ func (r AssistantToolChoiceOptionString) implementsAssistantToolChoiceOptionUnio // `{"type": "function", "function": {"name": "my_function"}}` forces the model to // call that tool. // -// Satisfied by [AssistantToolChoiceOptionString], [AssistantToolChoiceParam]. +// Satisfied by [AssistantToolChoiceOptionBehavior], [AssistantToolChoiceParam]. type AssistantToolChoiceOptionUnionParam interface { implementsAssistantToolChoiceOptionUnionParam() } diff --git a/betathread_test.go b/betathread_test.go index 5d6af6b..c7ea2aa 100644 --- a/betathread_test.go +++ b/betathread_test.go @@ -365,7 +365,7 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) { }), }), }), - ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionString(openai.AssistantToolChoiceOptionStringNone)), + ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionBehavior(openai.AssistantToolChoiceOptionBehaviorNone)), ToolResources: openai.F(openai.BetaThreadNewAndRunParamsToolResources{ CodeInterpreter: openai.F(openai.BetaThreadNewAndRunParamsToolResourcesCodeInterpreter{ FileIDs: openai.F([]string{"string", "string", "string"}), diff --git a/betathreadrun_test.go b/betathreadrun_test.go index 50fe858..a136dfd 100644 --- a/betathreadrun_test.go +++ b/betathreadrun_test.go @@ -136,7 +136,7 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) { Model: openai.F(openai.ChatModelGPT4o), ParallelToolCalls: openai.F(true), Temperature: openai.F(1.000000), - ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionString(openai.AssistantToolChoiceOptionStringNone)), + ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionBehavior(openai.AssistantToolChoiceOptionBehaviorNone)), Tools: openai.F([]openai.AssistantToolUnionParam{openai.CodeInterpreterToolParam{ Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter), }, openai.CodeInterpreterToolParam{ diff --git a/file.go b/file.go index 8213011..4f9cd40 100644 --- a/file.go +++ b/file.go @@ -128,6 +128,22 @@ func (r *FileService) Content(ctx context.Context, fileID string, opts ...option return } +// Returns the contents of the specified file. +// +// Deprecated: The `.content()` method should be used instead +func (r *FileService) GetContent(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileContent, err error) { + opts = append(r.Options[:], opts...) + if fileID == "" { + err = errors.New("missing required file_id parameter") + return + } + path := fmt.Sprintf("files/%s/content", fileID) + err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...) + return +} + +type FileContent = string + type FileDeleted struct { ID string `json:"id,required"` Deleted bool `json:"deleted,required"` diff --git a/file_test.go b/file_test.go index 588a561..29293a7 100644 --- a/file_test.go +++ b/file_test.go @@ -143,3 +143,25 @@ func TestFileContent(t *testing.T) { t.Fatalf("return value not %s: %s", "abc", b) } } + +func TestFileGetContent(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.Files.GetContent(context.TODO(), "file_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()) + } +} diff --git a/internal/version.go b/internal/version.go index fe6f633..3cc749b 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "0.1.0-alpha.30" // x-release-please-version +const PackageVersion = "0.1.0-alpha.31" // x-release-please-version