Skip to content

Commit

Permalink
fix(beta): pass beta header by default (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] committed Oct 8, 2024
1 parent 09f9175 commit e0a5caa
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 10 deletions.
6 changes: 5 additions & 1 deletion betaassistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewBetaAssistantService(opts ...option.RequestOption) (r *BetaAssistantServ
// Create an assistant with a model and instructions.
func (r *BetaAssistantService) New(ctx context.Context, body BetaAssistantNewParams, opts ...option.RequestOption) (res *Assistant, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "assistants"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -50,6 +51,7 @@ func (r *BetaAssistantService) New(ctx context.Context, body BetaAssistantNewPar
// Retrieves an assistant.
func (r *BetaAssistantService) Get(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *Assistant, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if assistantID == "" {
err = errors.New("missing required assistant_id parameter")
return
Expand All @@ -62,6 +64,7 @@ func (r *BetaAssistantService) Get(ctx context.Context, assistantID string, opts
// Modifies an assistant.
func (r *BetaAssistantService) Update(ctx context.Context, assistantID string, body BetaAssistantUpdateParams, opts ...option.RequestOption) (res *Assistant, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if assistantID == "" {
err = errors.New("missing required assistant_id parameter")
return
Expand All @@ -75,7 +78,7 @@ func (r *BetaAssistantService) Update(ctx context.Context, assistantID string, b
func (r *BetaAssistantService) List(ctx context.Context, query BetaAssistantListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Assistant], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
path := "assistants"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
Expand All @@ -97,6 +100,7 @@ func (r *BetaAssistantService) ListAutoPaging(ctx context.Context, query BetaAss
// Delete an assistant.
func (r *BetaAssistantService) Delete(ctx context.Context, assistantID string, opts ...option.RequestOption) (res *AssistantDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if assistantID == "" {
err = errors.New("missing required assistant_id parameter")
return
Expand Down
7 changes: 6 additions & 1 deletion betathread.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func NewBetaThreadService(opts ...option.RequestOption) (r *BetaThreadService) {
// Create a thread.
func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "threads"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -52,6 +53,7 @@ func (r *BetaThreadService) New(ctx context.Context, body BetaThreadNewParams, o
// Retrieves a thread.
func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...option.RequestOption) (res *Thread, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -64,6 +66,7 @@ func (r *BetaThreadService) Get(ctx context.Context, threadID string, opts ...op
// Modifies a thread.
func (r *BetaThreadService) Update(ctx context.Context, threadID string, body BetaThreadUpdateParams, opts ...option.RequestOption) (res *Thread, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -76,6 +79,7 @@ func (r *BetaThreadService) Update(ctx context.Context, threadID string, body Be
// Delete a thread.
func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ...option.RequestOption) (res *ThreadDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -88,6 +92,7 @@ func (r *BetaThreadService) Delete(ctx context.Context, threadID string, opts ..
// Create a thread and run it in one request.
func (r *BetaThreadService) NewAndRun(ctx context.Context, body BetaThreadNewAndRunParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "threads/runs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -100,7 +105,7 @@ func (r *BetaThreadService) NewAndRunStreaming(ctx context.Context, body BetaThr
err error
)
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithJSONSet("stream", true)}, opts...)
path := "threads/runs"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &raw, opts...)
return ssestream.NewStream[AssistantStreamEvent](ssestream.NewDecoder(raw), err)
Expand Down
6 changes: 5 additions & 1 deletion betathreadmessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewBetaThreadMessageService(opts ...option.RequestOption) (r *BetaThreadMes
// Create a message.
func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, body BetaThreadMessageNewParams, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -53,6 +54,7 @@ func (r *BetaThreadMessageService) New(ctx context.Context, threadID string, bod
// Retrieve a message.
func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -69,6 +71,7 @@ func (r *BetaThreadMessageService) Get(ctx context.Context, threadID string, mes
// Modifies a message.
func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string, messageID string, body BetaThreadMessageUpdateParams, opts ...option.RequestOption) (res *Message, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -86,7 +89,7 @@ func (r *BetaThreadMessageService) Update(ctx context.Context, threadID string,
func (r *BetaThreadMessageService) List(ctx context.Context, threadID string, query BetaThreadMessageListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Message], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -112,6 +115,7 @@ func (r *BetaThreadMessageService) ListAutoPaging(ctx context.Context, threadID
// Deletes a message.
func (r *BetaThreadMessageService) Delete(ctx context.Context, threadID string, messageID string, opts ...option.RequestOption) (res *MessageDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand Down
11 changes: 8 additions & 3 deletions betathreadrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func NewBetaThreadRunService(opts ...option.RequestOption) (r *BetaThreadRunServ
// Create a run.
func (r *BetaThreadRunService) New(ctx context.Context, threadID string, params BetaThreadRunNewParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -58,7 +59,7 @@ func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string
err error
)
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithJSONSet("stream", true)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -71,6 +72,7 @@ func (r *BetaThreadRunService) NewStreaming(ctx context.Context, threadID string
// Retrieves a run.
func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -87,6 +89,7 @@ func (r *BetaThreadRunService) Get(ctx context.Context, threadID string, runID s
// Modifies a run.
func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runID string, body BetaThreadRunUpdateParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -104,7 +107,7 @@ func (r *BetaThreadRunService) Update(ctx context.Context, threadID string, runI
func (r *BetaThreadRunService) List(ctx context.Context, threadID string, query BetaThreadRunListParams, opts ...option.RequestOption) (res *pagination.CursorPage[Run], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -130,6 +133,7 @@ func (r *BetaThreadRunService) ListAutoPaging(ctx context.Context, threadID stri
// Cancels a run that is `in_progress`.
func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runID string, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -149,6 +153,7 @@ func (r *BetaThreadRunService) Cancel(ctx context.Context, threadID string, runI
// request.
func (r *BetaThreadRunService) SubmitToolOutputs(ctx context.Context, threadID string, runID string, body BetaThreadRunSubmitToolOutputsParams, opts ...option.RequestOption) (res *Run, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -172,7 +177,7 @@ func (r *BetaThreadRunService) SubmitToolOutputsStreaming(ctx context.Context, t
err error
)
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithJSONSet("stream", true)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithJSONSet("stream", true)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand Down
3 changes: 2 additions & 1 deletion betathreadrunstep.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewBetaThreadRunStepService(opts ...option.RequestOption) (r *BetaThreadRun
// Retrieves a run step.
func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, runID string, stepID string, query BetaThreadRunStepGetParams, opts ...option.RequestOption) (res *RunStep, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand All @@ -62,7 +63,7 @@ func (r *BetaThreadRunStepService) Get(ctx context.Context, threadID string, run
func (r *BetaThreadRunStepService) List(ctx context.Context, threadID string, runID string, query BetaThreadRunStepListParams, opts ...option.RequestOption) (res *pagination.CursorPage[RunStep], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if threadID == "" {
err = errors.New("missing required thread_id parameter")
return
Expand Down
6 changes: 5 additions & 1 deletion betavectorstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ func NewBetaVectorStoreService(opts ...option.RequestOption) (r *BetaVectorStore
// Create a vector store.
func (r *BetaVectorStoreService) New(ctx context.Context, body BetaVectorStoreNewParams, opts ...option.RequestOption) (res *VectorStore, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
path := "vector_stores"
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
Expand All @@ -53,6 +54,7 @@ func (r *BetaVectorStoreService) New(ctx context.Context, body BetaVectorStoreNe
// Retrieves a vector store.
func (r *BetaVectorStoreService) Get(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStore, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
Expand All @@ -65,6 +67,7 @@ func (r *BetaVectorStoreService) Get(ctx context.Context, vectorStoreID string,
// Modifies a vector store.
func (r *BetaVectorStoreService) Update(ctx context.Context, vectorStoreID string, body BetaVectorStoreUpdateParams, opts ...option.RequestOption) (res *VectorStore, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
Expand All @@ -78,7 +81,7 @@ func (r *BetaVectorStoreService) Update(ctx context.Context, vectorStoreID strin
func (r *BetaVectorStoreService) List(ctx context.Context, query BetaVectorStoreListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStore], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
path := "vector_stores"
cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...)
if err != nil {
Expand All @@ -100,6 +103,7 @@ func (r *BetaVectorStoreService) ListAutoPaging(ctx context.Context, query BetaV
// Delete a vector store.
func (r *BetaVectorStoreService) Delete(ctx context.Context, vectorStoreID string, opts ...option.RequestOption) (res *VectorStoreDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
Expand Down
5 changes: 4 additions & 1 deletion betavectorstorefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func NewBetaVectorStoreFileService(opts ...option.RequestOption) (r *BetaVectorS
// [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).
func (r *BetaVectorStoreFileService) New(ctx context.Context, vectorStoreID string, body BetaVectorStoreFileNewParams, opts ...option.RequestOption) (res *VectorStoreFile, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
Expand All @@ -53,6 +54,7 @@ func (r *BetaVectorStoreFileService) New(ctx context.Context, vectorStoreID stri
// Retrieves a vector store file.
func (r *BetaVectorStoreFileService) Get(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFile, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
Expand All @@ -70,7 +72,7 @@ func (r *BetaVectorStoreFileService) Get(ctx context.Context, vectorStoreID stri
func (r *BetaVectorStoreFileService) List(ctx context.Context, vectorStoreID string, query BetaVectorStoreFileListParams, opts ...option.RequestOption) (res *pagination.CursorPage[VectorStoreFile], err error) {
var raw *http.Response
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2"), option.WithResponseInto(&raw)}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
Expand Down Expand Up @@ -99,6 +101,7 @@ func (r *BetaVectorStoreFileService) ListAutoPaging(ctx context.Context, vectorS
// endpoint.
func (r *BetaVectorStoreFileService) Delete(ctx context.Context, vectorStoreID string, fileID string, opts ...option.RequestOption) (res *VectorStoreFileDeleted, err error) {
opts = append(r.Options[:], opts...)
opts = append([]option.RequestOption{option.WithHeader("OpenAI-Beta", "assistants=v2")}, opts...)
if vectorStoreID == "" {
err = errors.New("missing required vector_store_id parameter")
return
Expand Down
Loading

0 comments on commit e0a5caa

Please sign in to comment.