Skip to content

Commit cf1ee49

Browse files
chore: rebuild project due to codegen change (#51)
1 parent 316a827 commit cf1ee49

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

inferencepipelinedata.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,12 @@ func (r InferencePipelineDataStreamParams) MarshalJSON() (data []byte, err error
9595
// Configuration for the data stream. Depends on your **Openlayer project task
9696
// type**.
9797
type InferencePipelineDataStreamParamsConfig struct {
98-
// Name of the column with the total number of tokens.
99-
NumOfTokenColumnName param.Field[string] `json:"numOfTokenColumnName"`
98+
CategoricalFeatureNames param.Field[interface{}] `json:"categoricalFeatureNames,required"`
99+
ClassNames param.Field[interface{}] `json:"classNames,required"`
100+
FeatureNames param.Field[interface{}] `json:"featureNames,required"`
101+
InputVariableNames param.Field[interface{}] `json:"inputVariableNames,required"`
102+
Metadata param.Field[interface{}] `json:"metadata,required"`
103+
Prompt param.Field[interface{}] `json:"prompt,required"`
100104
// Name of the column with the context retrieved. Applies to RAG use cases.
101105
// Providing the context enables RAG-specific metrics.
102106
ContextColumnName param.Field[string] `json:"contextColumnName"`
@@ -107,35 +111,31 @@ type InferencePipelineDataStreamParamsConfig struct {
107111
// Name of the column with the inference ids. This is useful if you want to update
108112
// rows at a later point in time. If not provided, a unique id is generated by
109113
// Openlayer.
110-
InferenceIDColumnName param.Field[string] `json:"inferenceIdColumnName"`
111-
InputVariableNames param.Field[interface{}] `json:"inputVariableNames,required"`
112-
// Name of the column with the latencies.
113-
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
114-
Metadata param.Field[interface{}] `json:"metadata,required"`
115-
// Name of the column with the model outputs.
116-
OutputColumnName param.Field[string] `json:"outputColumnName"`
117-
Prompt param.Field[interface{}] `json:"prompt,required"`
118-
// Name of the column with the questions. Applies to RAG use cases. Providing the
119-
// question enables RAG-specific metrics.
120-
QuestionColumnName param.Field[string] `json:"questionColumnName"`
121-
// Name of the column with the timestamps. Timestamps must be in UNIX sec format.
122-
// If not provided, the upload timestamp is used.
123-
TimestampColumnName param.Field[string] `json:"timestampColumnName"`
124-
CategoricalFeatureNames param.Field[interface{}] `json:"categoricalFeatureNames,required"`
125-
ClassNames param.Field[interface{}] `json:"classNames,required"`
126-
FeatureNames param.Field[interface{}] `json:"featureNames,required"`
114+
InferenceIDColumnName param.Field[string] `json:"inferenceIdColumnName"`
127115
// Name of the column with the labels. The data in this column must be
128116
// **zero-indexed integers**, matching the list provided in `classNames`.
129117
LabelColumnName param.Field[string] `json:"labelColumnName"`
118+
// Name of the column with the latencies.
119+
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
120+
// Name of the column with the total number of tokens.
121+
NumOfTokenColumnName param.Field[string] `json:"numOfTokenColumnName"`
122+
// Name of the column with the model outputs.
123+
OutputColumnName param.Field[string] `json:"outputColumnName"`
130124
// Name of the column with the model's predictions as **zero-indexed integers**.
131125
PredictionsColumnName param.Field[string] `json:"predictionsColumnName"`
132126
// Name of the column with the model's predictions as **lists of class
133127
// probabilities**.
134128
PredictionScoresColumnName param.Field[string] `json:"predictionScoresColumnName"`
129+
// Name of the column with the questions. Applies to RAG use cases. Providing the
130+
// question enables RAG-specific metrics.
131+
QuestionColumnName param.Field[string] `json:"questionColumnName"`
135132
// Name of the column with the targets (ground truth values).
136133
TargetColumnName param.Field[string] `json:"targetColumnName"`
137134
// Name of the column with the text data.
138135
TextColumnName param.Field[string] `json:"textColumnName"`
136+
// Name of the column with the timestamps. Timestamps must be in UNIX sec format.
137+
// If not provided, the upload timestamp is used.
138+
TimestampColumnName param.Field[string] `json:"timestampColumnName"`
139139
}
140140

141141
func (r InferencePipelineDataStreamParamsConfig) MarshalJSON() (data []byte, err error) {

internal/apijson/encoder.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"reflect"
88
"sort"
99
"strconv"
10+
"strings"
1011
"sync"
1112
"time"
1213

@@ -342,16 +343,18 @@ func (e *encoder) encodeMapEntries(json []byte, v reflect.Value) ([]byte, error)
342343

343344
iter := v.MapRange()
344345
for iter.Next() {
345-
var encodedKey []byte
346+
var encodedKeyString string
346347
if iter.Key().Type().Kind() == reflect.String {
347-
encodedKey = []byte(iter.Key().String())
348+
encodedKeyString = iter.Key().String()
348349
} else {
349350
var err error
350-
encodedKey, err = keyEncoder(iter.Key())
351+
encodedKeyBytes, err := keyEncoder(iter.Key())
351352
if err != nil {
352353
return nil, err
353354
}
355+
encodedKeyString = string(encodedKeyBytes)
354356
}
357+
encodedKey := []byte(sjsonReplacer.Replace(encodedKeyString))
355358
pairs = append(pairs, mapPair{key: encodedKey, value: iter.Value()})
356359
}
357360

@@ -389,3 +392,7 @@ func (e *encoder) newMapEncoder(t reflect.Type) encoderFunc {
389392
return json, nil
390393
}
391394
}
395+
396+
// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have
397+
// special characters that sjson interprets as a path.
398+
var sjsonReplacer *strings.Replacer = strings.NewReplacer(".", "\\.", ":", "\\:", "*", "\\*")

internal/apijson/json_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,9 @@ var tests = map[string]struct {
361361
"date_time_missing_timezone_colon_coerce": {`"2007-03-01T13:03:05-1200"`, time.Date(2007, time.March, 1, 13, 3, 5, 0, time.FixedZone("", -12*60*60))},
362362
"date_time_nano_missing_t_coerce": {`"2007-03-01 13:03:05.123456789Z"`, time.Date(2007, time.March, 1, 13, 3, 5, 123456789, time.UTC)},
363363

364-
"map_string": {`{"foo":"bar"}`, map[string]string{"foo": "bar"}},
365-
"map_interface": {`{"a":1,"b":"str","c":false}`, map[string]interface{}{"a": float64(1), "b": "str", "c": false}},
364+
"map_string": {`{"foo":"bar"}`, map[string]string{"foo": "bar"}},
365+
"map_string_with_sjson_path_chars": {`{":a.b.c*:d*-1e.f":"bar"}`, map[string]string{":a.b.c*:d*-1e.f": "bar"}},
366+
"map_interface": {`{"a":1,"b":"str","c":false}`, map[string]interface{}{"a": float64(1), "b": "str", "c": false}},
366367

367368
"primitive_struct": {
368369
`{"a":false,"b":237628372683,"c":654,"d":9999.43,"e":43.76,"f":[1,2,3,4]}`,

0 commit comments

Comments
 (0)