Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: add Stringer methods to custom types #11

Merged
merged 1 commit into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/cohere/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ var (

func init() {
flag.StringVar(&input, "input", "what is life", "input data")
flag.StringVar(&model, "model", string(cohere.EnglishV3), "model name")
flag.StringVar(&truncate, "truncate", string(cohere.NoneTrunc), "truncate type")
flag.StringVar(&inputType, "input-type", string(cohere.ClusteringInput), "input type")
flag.StringVar(&model, "model", cohere.EnglishV3.String(), "model name")
flag.StringVar(&truncate, "truncate", cohere.NoneTrunc.String(), "truncate type")
flag.StringVar(&inputType, "input-type", cohere.ClusteringInput.String(), "input type")
}

func main() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/openai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ var (

func init() {
flag.StringVar(&input, "input", "what is life", "input data")
flag.StringVar(&model, "model", string(openai.TextAdaV2), "model name")
flag.StringVar(&encoding, "encoding", string(openai.EncodingFloat), "encoding format")
flag.StringVar(&model, "model", openai.TextAdaV2.String(), "model name")
flag.StringVar(&encoding, "encoding", openai.EncodingFloat.String(), "encoding format")
}

func main() {
Expand Down
4 changes: 2 additions & 2 deletions cmd/vertexai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ var (

func init() {
flag.StringVar(&input, "input", "what is life", "input data")
flag.StringVar(&model, "model", string(vertexai.EmbedGeckoV2), "model name")
flag.StringVar(&model, "model", vertexai.EmbedGeckoV2.String(), "model name")
flag.BoolVar(&truncate, "truncate", false, "truncate type")
flag.StringVar(&taskType, "task-type", string(vertexai.RetrQueryTask), "task type")
flag.StringVar(&taskType, "task-type", vertexai.RetrQueryTask.String(), "task type")
flag.StringVar(&title, "title", "", "title: only relevant for retrival document tasks")
}

Expand Down
15 changes: 15 additions & 0 deletions cohere/cohere.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const (
MultiLingV2 Model = "embed-multilingual-v2.0"
)

// String implements stringer.
func (m Model) String() string {
return string(m)
}

// InputType is an embedding input type.
type InputType string

Expand All @@ -23,6 +28,11 @@ const (
ClusteringInput InputType = "clustering"
)

// String implements stringer.
func (i InputType) String() string {
return string(i)
}

// Truncate controls input truncating.
// It controls how the API handles inputs
// longer than the maximum token length (recommended: <512)
Expand All @@ -33,3 +43,8 @@ const (
EndTrunc Truncate = "END"
NoneTrunc Truncate = "NONE"
)

// String implements stringer.
func (t Truncate) String() string {
return string(t)
}
10 changes: 10 additions & 0 deletions openai/openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ const (
TextAdaV2 Model = "text-embedding-ada-002"
)

// String implements stringer.
func (m Model) String() string {
return string(m)
}

// EncodingFormat for embedding API requests.
type EncodingFormat string

Expand All @@ -16,3 +21,8 @@ const (
// encoded as base64 string
EncodingBase64 EncodingFormat = "base64"
)

// String implements stringer.
func (f EncodingFormat) String() string {
return string(f)
}
10 changes: 10 additions & 0 deletions vertexai/vertexai.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ const (
EmbedMultiGecko Model = "multimodalembedding@001"
)

// String implements stringer.
func (m Model) String() string {
return string(m)
}

// TaskType is embedding task type.
// It can be used to improve the embedding quality
// when targeting a specific task.
Expand All @@ -27,3 +32,8 @@ const (
ClassificationTask TaskType = "CLASSIFICATION"
ClusteringTask TaskType = "CLUSTERING"
)

// String implements stringer.
func (t TaskType) String() string {
return string(t)
}
Loading