Skip to content

Commit

Permalink
feat: add method convert str to embedding model enum
Browse files Browse the repository at this point in the history
  • Loading branch information
dingwenjiang committed Sep 29, 2023
1 parent 0d5256f commit d55b3d9
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion embeddings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,19 @@ import (
// to generate Embedding vectors.
type EmbeddingModel int

func ConvertStr2EmbeddingModel(modelName string) EmbeddingModel {
if val, ok := stringToEnum[modelName]; ok {
return val
}
return Unknown
}

// String implements the fmt.Stringer interface.
func (e EmbeddingModel) String() string {
return enumToString[e]
if val, ok := enumToString[e]; ok {
return val
}
return "Unknown"
}

// MarshalText implements the encoding.TextMarshaler interface.
Expand Down

0 comments on commit d55b3d9

Please sign in to comment.