Skip to content

Commit

Permalink
chore: rebuild project due to codegen change (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Nov 9, 2024
1 parent 3b63bd4 commit 43b0dae
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 24 deletions.
38 changes: 19 additions & 19 deletions inferencepipelinedata.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ func (r InferencePipelineDataStreamParams) MarshalJSON() (data []byte, err error
// Configuration for the data stream. Depends on your **Openlayer project task
// type**.
type InferencePipelineDataStreamParamsConfig struct {
// Name of the column with the total number of tokens.
NumOfTokenColumnName param.Field[string] `json:"numOfTokenColumnName"`
CategoricalFeatureNames param.Field[interface{}] `json:"categoricalFeatureNames,required"`
ClassNames param.Field[interface{}] `json:"classNames,required"`
FeatureNames param.Field[interface{}] `json:"featureNames,required"`
InputVariableNames param.Field[interface{}] `json:"inputVariableNames,required"`
Metadata param.Field[interface{}] `json:"metadata,required"`
Prompt param.Field[interface{}] `json:"prompt,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"`
Expand All @@ -107,35 +111,31 @@ type InferencePipelineDataStreamParamsConfig struct {
// 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,required"`
// Name of the column with the latencies.
LatencyColumnName param.Field[string] `json:"latencyColumnName"`
Metadata param.Field[interface{}] `json:"metadata,required"`
// Name of the column with the model outputs.
OutputColumnName param.Field[string] `json:"outputColumnName"`
Prompt param.Field[interface{}] `json:"prompt,required"`
// 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"`
CategoricalFeatureNames param.Field[interface{}] `json:"categoricalFeatureNames,required"`
ClassNames param.Field[interface{}] `json:"classNames,required"`
FeatureNames param.Field[interface{}] `json:"featureNames,required"`
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"`
// 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"`
// 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) {
Expand Down
13 changes: 10 additions & 3 deletions internal/apijson/encoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"reflect"
"sort"
"strconv"
"strings"
"sync"
"time"

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

iter := v.MapRange()
for iter.Next() {
var encodedKey []byte
var encodedKeyString string
if iter.Key().Type().Kind() == reflect.String {
encodedKey = []byte(iter.Key().String())
encodedKeyString = iter.Key().String()
} else {
var err error
encodedKey, err = keyEncoder(iter.Key())
encodedKeyBytes, err := keyEncoder(iter.Key())
if err != nil {
return nil, err
}
encodedKeyString = string(encodedKeyBytes)
}
encodedKey := []byte(sjsonReplacer.Replace(encodedKeyString))
pairs = append(pairs, mapPair{key: encodedKey, value: iter.Value()})
}

Expand Down Expand Up @@ -389,3 +392,7 @@ func (e *encoder) newMapEncoder(t reflect.Type) encoderFunc {
return json, nil
}
}

// If we want to set a literal key value into JSON using sjson, we need to make sure it doesn't have
// special characters that sjson interprets as a path.
var sjsonReplacer *strings.Replacer = strings.NewReplacer(".", "\\.", ":", "\\:", "*", "\\*")
5 changes: 3 additions & 2 deletions internal/apijson/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,9 @@ var tests = map[string]struct {
"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))},
"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)},

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

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

0 comments on commit 43b0dae

Please sign in to comment.