Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: 0.1.0-alpha.31 #96

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.30"
".": "0.1.0-alpha.31"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Or to pin the version:
<!-- x-release-please-start-version -->

```sh
go get -u 'github.com/openai/[email protected].30'
go get -u 'github.com/openai/[email protected].31'
```

<!-- x-release-please-end -->
Expand Down
2 changes: 2 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Params Types:

Response Types:

- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileContent">FileContent</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileDeleted">FileDeleted</a>
- <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileObject">FileObject</a>

Expand All @@ -100,6 +101,7 @@ Methods:
- <code title="get /files">client.Files.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileService.List">List</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, query <a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileListParams">FileListParams</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go/packages/pagination">pagination</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go/packages/pagination#Page">Page</a>[<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileObject">FileObject</a>], <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="delete /files/{file_id}">client.Files.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileService.Delete">Delete</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileDeleted">FileDeleted</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /files/{file_id}/content">client.Files.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileService.Content">Content</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>) (http.Response, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>
- <code title="get /files/{file_id}/content">client.Files.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileService.GetContent">GetContent</a>(ctx <a href="https://pkg.go.dev/context">context</a>.<a href="https://pkg.go.dev/context#Context">Context</a>, fileID <a href="https://pkg.go.dev/builtin#string">string</a>) (<a href="https://pkg.go.dev/github.com/openai/openai-go">openai</a>.<a href="https://pkg.go.dev/github.com/openai/openai-go#FileContent">FileContent</a>, <a href="https://pkg.go.dev/builtin#error">error</a>)</code>

# Images

Expand Down
22 changes: 11 additions & 11 deletions betathread.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -229,7 +229,7 @@ func init() {
"",
apijson.UnionVariant{
TypeFilter: gjson.String,
Type: reflect.TypeOf(AssistantToolChoiceOptionString("")),
Type: reflect.TypeOf(AssistantToolChoiceOptionBehavior("")),
},
apijson.UnionVariant{
TypeFilter: gjson.JSON,
Expand All @@ -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
Expand All @@ -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()
}
Expand Down
2 changes: 1 addition & 1 deletion betathread_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"}),
Expand Down
2 changes: 1 addition & 1 deletion betathreadrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
16 changes: 16 additions & 0 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
22 changes: 22 additions & 0 deletions file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
2 changes: 1 addition & 1 deletion internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading