forked from openai/openai-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbetachatkit.go
More file actions
125 lines (110 loc) · 4.41 KB
/
betachatkit.go
File metadata and controls
125 lines (110 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openai
import (
"encoding/json"
"github.com/openai/openai-go/v3/internal/apijson"
"github.com/openai/openai-go/v3/option"
"github.com/openai/openai-go/v3/packages/respjson"
)
// BetaChatKitService contains methods and other services that help with
// interacting with the openai API.
//
// Note, unlike clients, this service does not read variables from the environment
// automatically. You should not instantiate this service directly, and instead use
// the [NewBetaChatKitService] method instead.
type BetaChatKitService struct {
Options []option.RequestOption
Sessions BetaChatKitSessionService
Threads BetaChatKitThreadService
}
// NewBetaChatKitService generates a new service that applies the given options to
// each request. These options are applied after the parent client's options (if
// there is one), and before any request-specific options.
func NewBetaChatKitService(opts ...option.RequestOption) (r BetaChatKitService) {
r = BetaChatKitService{}
r.Options = opts
r.Sessions = NewBetaChatKitSessionService(opts...)
r.Threads = NewBetaChatKitThreadService(opts...)
return
}
// Workflow metadata and state returned for the session.
type ChatKitWorkflow struct {
// Identifier of the workflow backing the session.
ID string `json:"id" api:"required"`
// State variable key-value pairs applied when invoking the workflow. Defaults to
// null when no overrides were provided.
StateVariables map[string]ChatKitWorkflowStateVariableUnion `json:"state_variables" api:"required"`
// Tracing settings applied to the workflow.
Tracing ChatKitWorkflowTracing `json:"tracing" api:"required"`
// Specific workflow version used for the session. Defaults to null when using the
// latest deployment.
Version string `json:"version" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
ID respjson.Field
StateVariables respjson.Field
Tracing respjson.Field
Version respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ChatKitWorkflow) RawJSON() string { return r.JSON.raw }
func (r *ChatKitWorkflow) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// ChatKitWorkflowStateVariableUnion contains all possible properties and values
// from [string], [bool], [float64].
//
// Use the methods beginning with 'As' to cast the union to one of its variants.
//
// If the underlying value is not a json object, one of the following properties
// will be valid: OfString OfBool OfFloat]
type ChatKitWorkflowStateVariableUnion struct {
// This field will be present if the value is a [string] instead of an object.
OfString string `json:",inline"`
// This field will be present if the value is a [bool] instead of an object.
OfBool bool `json:",inline"`
// This field will be present if the value is a [float64] instead of an object.
OfFloat float64 `json:",inline"`
JSON struct {
OfString respjson.Field
OfBool respjson.Field
OfFloat respjson.Field
raw string
} `json:"-"`
}
func (u ChatKitWorkflowStateVariableUnion) AsString() (v string) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ChatKitWorkflowStateVariableUnion) AsBool() (v bool) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
func (u ChatKitWorkflowStateVariableUnion) AsFloat() (v float64) {
apijson.UnmarshalRoot(json.RawMessage(u.JSON.raw), &v)
return
}
// Returns the unmodified JSON received from the API
func (u ChatKitWorkflowStateVariableUnion) RawJSON() string { return u.JSON.raw }
func (r *ChatKitWorkflowStateVariableUnion) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}
// Tracing settings applied to the workflow.
type ChatKitWorkflowTracing struct {
// Indicates whether tracing is enabled.
Enabled bool `json:"enabled" api:"required"`
// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
JSON struct {
Enabled respjson.Field
ExtraFields map[string]respjson.Field
raw string
} `json:"-"`
}
// Returns the unmodified JSON received from the API
func (r ChatKitWorkflowTracing) RawJSON() string { return r.JSON.raw }
func (r *ChatKitWorkflowTracing) UnmarshalJSON(data []byte) error {
return apijson.UnmarshalRoot(data, r)
}