Skip to content

Commit ba37fcc

Browse files
chore(internal): update spec version (#95)
1 parent 8d58dfa commit ba37fcc

File tree

7 files changed

+54
-14
lines changed

7 files changed

+54
-14
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 68
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-f9320ebf347140052c7f8b0bc5c7db24f5e367c368c8cb34c3606af4e2b6591b.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai-b60d5559d5150ecd3b49136064e5e251d832899770ff385b711378389afba370.yml

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ Params Types:
9090

9191
Response Types:
9292

93+
- <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>
9394
- <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>
9495
- <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>
9596

@@ -100,6 +101,7 @@ Methods:
100101
- <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>
101102
- <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>
102103
- <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>
104+
- <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>
103105

104106
# Images
105107

betathread.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func (r AssistantToolChoiceFunctionParam) MarshalJSON() (data []byte, err error)
218218
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
219219
// call that tool.
220220
//
221-
// Union satisfied by [AssistantToolChoiceOptionString] or [AssistantToolChoice].
221+
// Union satisfied by [AssistantToolChoiceOptionBehavior] or [AssistantToolChoice].
222222
type AssistantToolChoiceOptionUnion interface {
223223
implementsAssistantToolChoiceOptionUnion()
224224
}
@@ -229,7 +229,7 @@ func init() {
229229
"",
230230
apijson.UnionVariant{
231231
TypeFilter: gjson.String,
232-
Type: reflect.TypeOf(AssistantToolChoiceOptionString("")),
232+
Type: reflect.TypeOf(AssistantToolChoiceOptionBehavior("")),
233233
},
234234
apijson.UnionVariant{
235235
TypeFilter: gjson.JSON,
@@ -242,25 +242,25 @@ func init() {
242242
// `auto` means the model can pick between generating a message or calling one or
243243
// more tools. `required` means the model must call one or more tools before
244244
// responding to the user.
245-
type AssistantToolChoiceOptionString string
245+
type AssistantToolChoiceOptionBehavior string
246246

247247
const (
248-
AssistantToolChoiceOptionStringNone AssistantToolChoiceOptionString = "none"
249-
AssistantToolChoiceOptionStringAuto AssistantToolChoiceOptionString = "auto"
250-
AssistantToolChoiceOptionStringRequired AssistantToolChoiceOptionString = "required"
248+
AssistantToolChoiceOptionBehaviorNone AssistantToolChoiceOptionBehavior = "none"
249+
AssistantToolChoiceOptionBehaviorAuto AssistantToolChoiceOptionBehavior = "auto"
250+
AssistantToolChoiceOptionBehaviorRequired AssistantToolChoiceOptionBehavior = "required"
251251
)
252252

253-
func (r AssistantToolChoiceOptionString) IsKnown() bool {
253+
func (r AssistantToolChoiceOptionBehavior) IsKnown() bool {
254254
switch r {
255-
case AssistantToolChoiceOptionStringNone, AssistantToolChoiceOptionStringAuto, AssistantToolChoiceOptionStringRequired:
255+
case AssistantToolChoiceOptionBehaviorNone, AssistantToolChoiceOptionBehaviorAuto, AssistantToolChoiceOptionBehaviorRequired:
256256
return true
257257
}
258258
return false
259259
}
260260

261-
func (r AssistantToolChoiceOptionString) implementsAssistantToolChoiceOptionUnion() {}
261+
func (r AssistantToolChoiceOptionBehavior) implementsAssistantToolChoiceOptionUnion() {}
262262

263-
func (r AssistantToolChoiceOptionString) implementsAssistantToolChoiceOptionUnionParam() {}
263+
func (r AssistantToolChoiceOptionBehavior) implementsAssistantToolChoiceOptionUnionParam() {}
264264

265265
// Controls which (if any) tool is called by the model. `none` means the model will
266266
// not call any tools and instead generates a message. `auto` is the default value
@@ -270,7 +270,7 @@ func (r AssistantToolChoiceOptionString) implementsAssistantToolChoiceOptionUnio
270270
// `{"type": "function", "function": {"name": "my_function"}}` forces the model to
271271
// call that tool.
272272
//
273-
// Satisfied by [AssistantToolChoiceOptionString], [AssistantToolChoiceParam].
273+
// Satisfied by [AssistantToolChoiceOptionBehavior], [AssistantToolChoiceParam].
274274
type AssistantToolChoiceOptionUnionParam interface {
275275
implementsAssistantToolChoiceOptionUnionParam()
276276
}

betathread_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,7 @@ func TestBetaThreadNewAndRunWithOptionalParams(t *testing.T) {
365365
}),
366366
}),
367367
}),
368-
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionString(openai.AssistantToolChoiceOptionStringNone)),
368+
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionBehavior(openai.AssistantToolChoiceOptionBehaviorNone)),
369369
ToolResources: openai.F(openai.BetaThreadNewAndRunParamsToolResources{
370370
CodeInterpreter: openai.F(openai.BetaThreadNewAndRunParamsToolResourcesCodeInterpreter{
371371
FileIDs: openai.F([]string{"string", "string", "string"}),

betathreadrun_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func TestBetaThreadRunNewWithOptionalParams(t *testing.T) {
136136
Model: openai.F(openai.ChatModelGPT4o),
137137
ParallelToolCalls: openai.F(true),
138138
Temperature: openai.F(1.000000),
139-
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionString(openai.AssistantToolChoiceOptionStringNone)),
139+
ToolChoice: openai.F[openai.AssistantToolChoiceOptionUnionParam](openai.AssistantToolChoiceOptionBehavior(openai.AssistantToolChoiceOptionBehaviorNone)),
140140
Tools: openai.F([]openai.AssistantToolUnionParam{openai.CodeInterpreterToolParam{
141141
Type: openai.F(openai.CodeInterpreterToolTypeCodeInterpreter),
142142
}, openai.CodeInterpreterToolParam{

file.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,22 @@ func (r *FileService) Content(ctx context.Context, fileID string, opts ...option
128128
return
129129
}
130130

131+
// Returns the contents of the specified file.
132+
//
133+
// Deprecated: The `.content()` method should be used instead
134+
func (r *FileService) GetContent(ctx context.Context, fileID string, opts ...option.RequestOption) (res *FileContent, err error) {
135+
opts = append(r.Options[:], opts...)
136+
if fileID == "" {
137+
err = errors.New("missing required file_id parameter")
138+
return
139+
}
140+
path := fmt.Sprintf("files/%s/content", fileID)
141+
err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &res, opts...)
142+
return
143+
}
144+
145+
type FileContent = string
146+
131147
type FileDeleted struct {
132148
ID string `json:"id,required"`
133149
Deleted bool `json:"deleted,required"`

file_test.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,25 @@ func TestFileContent(t *testing.T) {
143143
t.Fatalf("return value not %s: %s", "abc", b)
144144
}
145145
}
146+
147+
func TestFileGetContent(t *testing.T) {
148+
baseURL := "http://localhost:4010"
149+
if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok {
150+
baseURL = envURL
151+
}
152+
if !testutil.CheckTestServer(t, baseURL) {
153+
return
154+
}
155+
client := openai.NewClient(
156+
option.WithBaseURL(baseURL),
157+
option.WithAPIKey("My API Key"),
158+
)
159+
_, err := client.Files.GetContent(context.TODO(), "file_id")
160+
if err != nil {
161+
var apierr *openai.Error
162+
if errors.As(err, &apierr) {
163+
t.Log(string(apierr.DumpRequest(true)))
164+
}
165+
t.Fatalf("err should be nil: %s", err.Error())
166+
}
167+
}

0 commit comments

Comments
 (0)