added AI auto-generated keywords to customer profile

This commit is contained in:
Mazyar
2026-01-04 13:44:45 +03:30
parent 3381e04e05
commit 8dcda0e031
9 changed files with 435 additions and 48 deletions
+47
View File
@@ -5,6 +5,7 @@ import (
"time"
"tm/pkg/authorization"
"tm/pkg/config"
"tm/pkg/glm"
"tm/pkg/hcaptcha"
"tm/pkg/logger"
"tm/pkg/mongo"
@@ -268,3 +269,49 @@ func InitHCaptchaService(conf config.HCaptchaConfig, log logger.Logger) hcaptcha
return hcaptchaVerifier
}
// InitGLMService initializes the GLM service
func InitGLMService(conf GLMConfig, log logger.Logger) *glm.SDK {
glmSDK, err := glm.New(
&glm.Config{
BaseURL: conf.BaseURL,
APIKey: conf.APIKey,
Timeout: conf.Timeout,
RetryAttempts: conf.RetryAttempts,
RetryDelay: conf.RetryDelay,
EnableLogging: conf.EnableLogging,
UserAgent: conf.UserAgent,
DefaultModel: conf.DefaultModel,
DefaultMaxTokens: conf.DefaultMaxTokens,
DefaultTopP: conf.DefaultTopP,
DefaultTemperature: conf.DefaultTemperature,
DefaultFrequencyPenalty: conf.DefaultFrequencyPenalty,
DefaultPresencePenalty: conf.DefaultPresencePenalty,
EnableStreaming: conf.EnableStreaming,
EnableThinking: conf.EnableThinking,
TranslationOptions: glm.TranslationOption{
Model: conf.TranslateOptions.Model,
MaxTokens: conf.TranslateOptions.MaxTokens,
Temperature: conf.TranslateOptions.Temperature,
FrequencyPenalty: conf.TranslateOptions.FrequencyPenalty,
PresencePenalty: conf.TranslateOptions.PresencePenalty,
TopP: conf.TranslateOptions.TopP,
EnableThinking: conf.TranslateOptions.EnableThinking,
},
}, log)
if err != nil {
log.Error("Failed to initialize GLM SDK", map[string]interface{}{
"error": err.Error(),
})
log.Warn("GLM service will be disabled, keyword generation features will not be available", map[string]interface{}{})
return nil
}
log.Info("GLM SDK initialized successfully", map[string]interface{}{
"base_url": conf.BaseURL,
"timeout": conf.Timeout,
})
return glmSDK
}