Documentation ¶
Index ¶
- Constants
- func GetLangMap() map[string]string
- func RegistLanguage(langCode, langName string)
- func Translate(text, To, Token string, opt ...Option) (string, error)
- func TranslateWithConfig(text, To, Token string, cfg *TranslationConfig) (string, error)
- type Detected
- type Option
- func WithCtx(Ctx context.Context) Option
- func WithDebug() Option
- func WithFrequencyPenalty(FrequencyPenalty float32) Option
- func WithFrom(From string) Option
- func WithMaxTokens(MaxTokens int) Option
- func WithModel(Model string) Option
- func WithPresencePenalty(PresencePenalty float32) Option
- func WithTemperature(Temperature float32) Option
- func WithTopP(TopP float32) Option
- type Translated
- type TranslationConfig
Constants ¶
View Source
const ( DefaultMaxTokens = 1000 DefaultTemperature = 0.0 DefaultTopP = 1.0 DefaultPresencePenalty = 1.0 DefaultFrequencyPenalty = 1.0 GPT3Dot5Turbo0301 = gpt3.GPT3Dot5Turbo0301 GPT3Dot5Turbo = gpt3.GPT3Dot5Turbo )
Variables ¶
This section is empty.
Functions ¶
func GetLangMap ¶
func RegistLanguage ¶
func RegistLanguage(langCode, langName string)
func TranslateWithConfig ¶
func TranslateWithConfig(text, To, Token string, cfg *TranslationConfig) (string, error)
Types ¶
type Detected ¶
type Detected struct { Lang string `json:"lang"` // detected language Confidence float64 `json:"confidence"` // the confidence of detection result (0.00 to 1.00) }
Detected represents language detection result
type Option ¶
type Option func(*TranslationConfig)
func WithFrequencyPenalty ¶
func WithMaxTokens ¶
func WithPresencePenalty ¶
func WithTemperature ¶
type Translated ¶
type Translated struct { // Detected Detected `json:"detected"` Text string `json:"text"` // translated text }
type TranslationConfig ¶
type TranslationConfig struct { Ctx context.Context Debug bool Model string // GPT3Dot5Turbo0301,GPT3Dot5Turbo MaxTokens int Temperature float32 // 0-2, 越高越随机 TopP float32 // 0-1,0.1表示仅考虑包含最高前10%概率质量的令牌,推荐1.0 PresencePenalty float32 // 介于-2.0和2.0之间的数字。正值会根据新标记到目前为止是否出现在文本中来惩罚它们,从而增加模型谈论新主题的可能性。 FrequencyPenalty float32 // 介于-2.0和2.0之间的数字。正值会根据新符号在文本中的现有频率来惩罚它们,从而降低模型逐字重复同一行的可能性。 From, SelectedWords string }
func DefaultConfig ¶
func DefaultConfig() *TranslationConfig
Click to show internal directories.
Click to hide internal directories.