-
Notifications
You must be signed in to change notification settings - Fork 0
/
inferencepipelinedata.go
309 lines (276 loc) · 14.4 KB
/
inferencepipelinedata.go
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
package openlayer
import (
"context"
"errors"
"fmt"
"net/http"
"github.com/openlayer-ai/openlayer-go/internal/apijson"
"github.com/openlayer-ai/openlayer-go/internal/param"
"github.com/openlayer-ai/openlayer-go/internal/requestconfig"
"github.com/openlayer-ai/openlayer-go/option"
)
// InferencePipelineDataService contains methods and other services that help with
// interacting with the openlayer 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 [NewInferencePipelineDataService] method instead.
type InferencePipelineDataService struct {
Options []option.RequestOption
}
// NewInferencePipelineDataService 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 NewInferencePipelineDataService(opts ...option.RequestOption) (r *InferencePipelineDataService) {
r = &InferencePipelineDataService{}
r.Options = opts
return
}
// Publish an inference data point to an inference pipeline.
func (r *InferencePipelineDataService) Stream(ctx context.Context, inferencePipelineID string, body InferencePipelineDataStreamParams, opts ...option.RequestOption) (res *InferencePipelineDataStreamResponse, err error) {
opts = append(r.Options[:], opts...)
if inferencePipelineID == "" {
err = errors.New("missing required inferencePipelineId parameter")
return
}
path := fmt.Sprintf("inference-pipelines/%s/data-stream", inferencePipelineID)
err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &res, opts...)
return
}
type InferencePipelineDataStreamResponse struct {
Success InferencePipelineDataStreamResponseSuccess `json:"success,required"`
JSON inferencePipelineDataStreamResponseJSON `json:"-"`
}
// inferencePipelineDataStreamResponseJSON contains the JSON metadata for the
// struct [InferencePipelineDataStreamResponse]
type inferencePipelineDataStreamResponseJSON struct {
Success apijson.Field
raw string
ExtraFields map[string]apijson.Field
}
func (r *InferencePipelineDataStreamResponse) UnmarshalJSON(data []byte) (err error) {
return apijson.UnmarshalRoot(data, r)
}
func (r inferencePipelineDataStreamResponseJSON) RawJSON() string {
return r.raw
}
type InferencePipelineDataStreamResponseSuccess bool
const (
InferencePipelineDataStreamResponseSuccessTrue InferencePipelineDataStreamResponseSuccess = true
)
func (r InferencePipelineDataStreamResponseSuccess) IsKnown() bool {
switch r {
case InferencePipelineDataStreamResponseSuccessTrue:
return true
}
return false
}
type InferencePipelineDataStreamParams struct {
// Configuration for the data stream. Depends on your **Openlayer project task
// type**.
Config param.Field[InferencePipelineDataStreamParamsConfigUnion] `json:"config,required"`
// A list of inference data points with inputs and outputs
Rows param.Field[[]map[string]interface{}] `json:"rows,required"`
}
func (r InferencePipelineDataStreamParams) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
// Configuration for the data stream. Depends on your **Openlayer project task
// type**.
type InferencePipelineDataStreamParamsConfig struct {
CategoricalFeatureNames param.Field[interface{}] `json:"categoricalFeatureNames"`
ClassNames param.Field[interface{}] `json:"classNames"`
// Name of the column with the context retrieved. Applies to RAG use cases.
// Providing the context enables RAG-specific metrics.
ContextColumnName param.Field[string] `json:"contextColumnName"`
// Name of the column with the cost associated with each row.
CostColumnName param.Field[string] `json:"costColumnName"`
FeatureNames param.Field[interface{}] `json:"featureNames"`
// Name of the column with the ground truths.
GroundTruthColumnName param.Field[string] `json:"groundTruthColumnName"`
// Name of the column with the inference ids. This is useful if you want to update
// rows at a later point in time. If not provided, a unique id is generated by
// Openlayer.
InferenceIDColumnName param.Field[string] `json:"inferenceIdColumnName"`
InputVariableNames param.Field[interface{}] `json:"inputVariableNames"`
// Name of the column with the labels. The data in this column must be
// **zero-indexed integers**, matching the list provided in `classNames`.
LabelColumnName param.Field[string] `json:"labelColumnName"`
// Name of the column with the latencies.
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
Metadata param.Field[interface{}] `json:"metadata"`
// Name of the column with the total number of tokens.
NumOfTokenColumnName param.Field[string] `json:"numOfTokenColumnName"`
// Name of the column with the model outputs.
OutputColumnName param.Field[string] `json:"outputColumnName"`
// Name of the column with the model's predictions as **zero-indexed integers**.
PredictionsColumnName param.Field[string] `json:"predictionsColumnName"`
// Name of the column with the model's predictions as **lists of class
// probabilities**.
PredictionScoresColumnName param.Field[string] `json:"predictionScoresColumnName"`
Prompt param.Field[interface{}] `json:"prompt"`
// Name of the column with the questions. Applies to RAG use cases. Providing the
// question enables RAG-specific metrics.
QuestionColumnName param.Field[string] `json:"questionColumnName"`
// Name of the column with the targets (ground truth values).
TargetColumnName param.Field[string] `json:"targetColumnName"`
// Name of the column with the text data.
TextColumnName param.Field[string] `json:"textColumnName"`
// Name of the column with the timestamps. Timestamps must be in UNIX sec format.
// If not provided, the upload timestamp is used.
TimestampColumnName param.Field[string] `json:"timestampColumnName"`
}
func (r InferencePipelineDataStreamParamsConfig) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r InferencePipelineDataStreamParamsConfig) implementsInferencePipelineDataStreamParamsConfigUnion() {
}
// Configuration for the data stream. Depends on your **Openlayer project task
// type**.
//
// Satisfied by [InferencePipelineDataStreamParamsConfigLlmData],
// [InferencePipelineDataStreamParamsConfigTabularClassificationData],
// [InferencePipelineDataStreamParamsConfigTabularRegressionData],
// [InferencePipelineDataStreamParamsConfigTextClassificationData],
// [InferencePipelineDataStreamParamsConfig].
type InferencePipelineDataStreamParamsConfigUnion interface {
implementsInferencePipelineDataStreamParamsConfigUnion()
}
type InferencePipelineDataStreamParamsConfigLlmData struct {
// Name of the column with the model outputs.
OutputColumnName param.Field[string] `json:"outputColumnName,required"`
// Name of the column with the context retrieved. Applies to RAG use cases.
// Providing the context enables RAG-specific metrics.
ContextColumnName param.Field[string] `json:"contextColumnName"`
// Name of the column with the cost associated with each row.
CostColumnName param.Field[string] `json:"costColumnName"`
// Name of the column with the ground truths.
GroundTruthColumnName param.Field[string] `json:"groundTruthColumnName"`
// Name of the column with the inference ids. This is useful if you want to update
// rows at a later point in time. If not provided, a unique id is generated by
// Openlayer.
InferenceIDColumnName param.Field[string] `json:"inferenceIdColumnName"`
// Array of input variable names. Each input variable should be a dataset column.
InputVariableNames param.Field[[]string] `json:"inputVariableNames"`
// Name of the column with the latencies.
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
// Object with metadata.
Metadata param.Field[interface{}] `json:"metadata"`
// Name of the column with the total number of tokens.
NumOfTokenColumnName param.Field[string] `json:"numOfTokenColumnName"`
// Prompt for the LLM.
Prompt param.Field[[]InferencePipelineDataStreamParamsConfigLlmDataPrompt] `json:"prompt"`
// Name of the column with the questions. Applies to RAG use cases. Providing the
// question enables RAG-specific metrics.
QuestionColumnName param.Field[string] `json:"questionColumnName"`
// Name of the column with the timestamps. Timestamps must be in UNIX sec format.
// If not provided, the upload timestamp is used.
TimestampColumnName param.Field[string] `json:"timestampColumnName"`
}
func (r InferencePipelineDataStreamParamsConfigLlmData) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r InferencePipelineDataStreamParamsConfigLlmData) implementsInferencePipelineDataStreamParamsConfigUnion() {
}
type InferencePipelineDataStreamParamsConfigLlmDataPrompt struct {
// Content of the prompt.
Content param.Field[string] `json:"content"`
// Role of the prompt.
Role param.Field[string] `json:"role"`
}
func (r InferencePipelineDataStreamParamsConfigLlmDataPrompt) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
type InferencePipelineDataStreamParamsConfigTabularClassificationData struct {
// List of class names indexed by label integer in the dataset. E.g. ["Retained",
// "Exited"] when 0, 1 are in your label column.
ClassNames param.Field[[]string] `json:"classNames,required"`
// Array with the names of all categorical features in the dataset. E.g. ["Age",
// "Geography"].
CategoricalFeatureNames param.Field[[]string] `json:"categoricalFeatureNames"`
// Array with all input feature names.
FeatureNames param.Field[[]string] `json:"featureNames"`
// Name of the column with the inference ids. This is useful if you want to update
// rows at a later point in time. If not provided, a unique id is generated by
// Openlayer.
InferenceIDColumnName param.Field[string] `json:"inferenceIdColumnName"`
// Name of the column with the labels. The data in this column must be
// **zero-indexed integers**, matching the list provided in `classNames`.
LabelColumnName param.Field[string] `json:"labelColumnName"`
// Name of the column with the latencies.
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
// Object with metadata.
Metadata param.Field[interface{}] `json:"metadata"`
// Name of the column with the model's predictions as **zero-indexed integers**.
PredictionsColumnName param.Field[string] `json:"predictionsColumnName"`
// Name of the column with the model's predictions as **lists of class
// probabilities**.
PredictionScoresColumnName param.Field[string] `json:"predictionScoresColumnName"`
// Name of the column with the timestamps. Timestamps must be in UNIX sec format.
// If not provided, the upload timestamp is used.
TimestampColumnName param.Field[string] `json:"timestampColumnName"`
}
func (r InferencePipelineDataStreamParamsConfigTabularClassificationData) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r InferencePipelineDataStreamParamsConfigTabularClassificationData) implementsInferencePipelineDataStreamParamsConfigUnion() {
}
type InferencePipelineDataStreamParamsConfigTabularRegressionData struct {
// Array with the names of all categorical features in the dataset. E.g. ["Gender",
// "Geography"].
CategoricalFeatureNames param.Field[[]string] `json:"categoricalFeatureNames"`
// Array with all input feature names.
FeatureNames param.Field[[]string] `json:"featureNames"`
// Name of the column with the inference ids. This is useful if you want to update
// rows at a later point in time. If not provided, a unique id is generated by
// Openlayer.
InferenceIDColumnName param.Field[string] `json:"inferenceIdColumnName"`
// Name of the column with the latencies.
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
// Object with metadata.
Metadata param.Field[interface{}] `json:"metadata"`
// Name of the column with the model's predictions.
PredictionsColumnName param.Field[string] `json:"predictionsColumnName"`
// Name of the column with the targets (ground truth values).
TargetColumnName param.Field[string] `json:"targetColumnName"`
// Name of the column with the timestamps. Timestamps must be in UNIX sec format.
// If not provided, the upload timestamp is used.
TimestampColumnName param.Field[string] `json:"timestampColumnName"`
}
func (r InferencePipelineDataStreamParamsConfigTabularRegressionData) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r InferencePipelineDataStreamParamsConfigTabularRegressionData) implementsInferencePipelineDataStreamParamsConfigUnion() {
}
type InferencePipelineDataStreamParamsConfigTextClassificationData struct {
// List of class names indexed by label integer in the dataset. E.g. ["Retained",
// "Exited"] when 0, 1 are in your label column.
ClassNames param.Field[[]string] `json:"classNames,required"`
// Name of the column with the inference ids. This is useful if you want to update
// rows at a later point in time. If not provided, a unique id is generated by
// Openlayer.
InferenceIDColumnName param.Field[string] `json:"inferenceIdColumnName"`
// Name of the column with the labels. The data in this column must be
// **zero-indexed integers**, matching the list provided in `classNames`.
LabelColumnName param.Field[string] `json:"labelColumnName"`
// Name of the column with the latencies.
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
// Object with metadata.
Metadata param.Field[interface{}] `json:"metadata"`
// Name of the column with the model's predictions as **zero-indexed integers**.
PredictionsColumnName param.Field[string] `json:"predictionsColumnName"`
// Name of the column with the model's predictions as **lists of class
// probabilities**.
PredictionScoresColumnName param.Field[string] `json:"predictionScoresColumnName"`
// Name of the column with the text data.
TextColumnName param.Field[string] `json:"textColumnName"`
// Name of the column with the timestamps. Timestamps must be in UNIX sec format.
// If not provided, the upload timestamp is used.
TimestampColumnName param.Field[string] `json:"timestampColumnName"`
}
func (r InferencePipelineDataStreamParamsConfigTextClassificationData) MarshalJSON() (data []byte, err error) {
return apijson.MarshalRoot(r)
}
func (r InferencePipelineDataStreamParamsConfigTextClassificationData) implementsInferencePipelineDataStreamParamsConfigUnion() {
}