|
|
package schema |
|
|
|
|
|
import ( |
|
|
"encoding/json" |
|
|
|
|
|
"gopkg.in/yaml.v3" |
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type LogprobsValue struct { |
|
|
Enabled bool |
|
|
} |
|
|
|
|
|
|
|
|
func (l *LogprobsValue) UnmarshalJSON(data []byte) error { |
|
|
|
|
|
var b bool |
|
|
if err := json.Unmarshal(data, &b); err == nil { |
|
|
l.Enabled = b |
|
|
return nil |
|
|
} |
|
|
|
|
|
|
|
|
var n *bool |
|
|
if err := json.Unmarshal(data, &n); err == nil { |
|
|
l.Enabled = false |
|
|
return nil |
|
|
} |
|
|
|
|
|
|
|
|
var i int |
|
|
if err := json.Unmarshal(data, &i); err == nil { |
|
|
l.Enabled = i > 0 |
|
|
return nil |
|
|
} |
|
|
|
|
|
return json.Unmarshal(data, &l.Enabled) |
|
|
} |
|
|
|
|
|
|
|
|
func (l LogprobsValue) MarshalJSON() ([]byte, error) { |
|
|
return json.Marshal(l.Enabled) |
|
|
} |
|
|
|
|
|
|
|
|
func (l *LogprobsValue) UnmarshalYAML(value *yaml.Node) error { |
|
|
switch value.Kind { |
|
|
case yaml.ScalarNode: |
|
|
switch value.Tag { |
|
|
case "!!bool": |
|
|
var b bool |
|
|
if err := value.Decode(&b); err != nil { |
|
|
return err |
|
|
} |
|
|
l.Enabled = b |
|
|
return nil |
|
|
case "!!int": |
|
|
|
|
|
var i int |
|
|
if err := value.Decode(&i); err != nil { |
|
|
return err |
|
|
} |
|
|
l.Enabled = i > 0 |
|
|
return nil |
|
|
case "!!null": |
|
|
l.Enabled = false |
|
|
return nil |
|
|
} |
|
|
} |
|
|
return value.Decode(&l.Enabled) |
|
|
} |
|
|
|
|
|
|
|
|
func (l *LogprobsValue) IsEnabled() bool { |
|
|
return l.Enabled |
|
|
} |
|
|
|
|
|
|
|
|
type PredictionOptions struct { |
|
|
|
|
|
|
|
|
BasicModelRequest `yaml:",inline"` |
|
|
|
|
|
|
|
|
Language string `json:"language,omitempty" yaml:"language,omitempty"` |
|
|
|
|
|
|
|
|
Translate bool `json:"translate,omitempty" yaml:"translate,omitempty"` |
|
|
|
|
|
|
|
|
N int `json:"n,omitempty" yaml:"n,omitempty"` |
|
|
|
|
|
|
|
|
TopP *float64 `json:"top_p,omitempty" yaml:"top_p,omitempty"` |
|
|
TopK *int `json:"top_k,omitempty" yaml:"top_k,omitempty"` |
|
|
Temperature *float64 `json:"temperature,omitempty" yaml:"temperature,omitempty"` |
|
|
Maxtokens *int `json:"max_tokens,omitempty" yaml:"max_tokens,omitempty"` |
|
|
Echo bool `json:"echo,omitempty" yaml:"echo,omitempty"` |
|
|
|
|
|
|
|
|
Batch int `json:"batch,omitempty" yaml:"batch,omitempty"` |
|
|
IgnoreEOS bool `json:"ignore_eos,omitempty" yaml:"ignore_eos,omitempty"` |
|
|
RepeatPenalty float64 `json:"repeat_penalty,omitempty" yaml:"repeat_penalty,omitempty"` |
|
|
|
|
|
RepeatLastN int `json:"repeat_last_n,omitempty" yaml:"repeat_last_n,omitempty"` |
|
|
|
|
|
Keep int `json:"n_keep,omitempty" yaml:"n_keep,omitempty"` |
|
|
|
|
|
FrequencyPenalty float64 `json:"frequency_penalty,omitempty" yaml:"frequency_penalty,omitempty"` |
|
|
PresencePenalty float64 `json:"presence_penalty,omitempty" yaml:"presence_penalty,omitempty"` |
|
|
TFZ *float64 `json:"tfz,omitempty" yaml:"tfz,omitempty"` |
|
|
|
|
|
TypicalP *float64 `json:"typical_p,omitempty" yaml:"typical_p,omitempty"` |
|
|
Seed *int `json:"seed,omitempty" yaml:"seed,omitempty"` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Logprobs LogprobsValue `json:"logprobs,omitempty" yaml:"logprobs,omitempty"` |
|
|
TopLogprobs *int `json:"top_logprobs,omitempty" yaml:"top_logprobs,omitempty"` |
|
|
LogitBias map[string]float64 `json:"logit_bias,omitempty" yaml:"logit_bias,omitempty"` |
|
|
|
|
|
NegativePrompt string `json:"negative_prompt,omitempty" yaml:"negative_prompt,omitempty"` |
|
|
RopeFreqBase float32 `json:"rope_freq_base,omitempty" yaml:"rope_freq_base,omitempty"` |
|
|
RopeFreqScale float32 `json:"rope_freq_scale,omitempty" yaml:"rope_freq_scale,omitempty"` |
|
|
NegativePromptScale float32 `json:"negative_prompt_scale,omitempty" yaml:"negative_prompt_scale,omitempty"` |
|
|
|
|
|
|
|
|
ClipSkip int `json:"clip_skip,omitempty" yaml:"clip_skip,omitempty"` |
|
|
|
|
|
|
|
|
Tokenizer string `json:"tokenizer,omitempty" yaml:"tokenizer,omitempty"` |
|
|
} |
|
|
|