优化ai初始化逻辑
This commit is contained in:
31
internal/infra/ai/no_ai.go
Normal file
31
internal/infra/ai/no_ai.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package ai
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/logs"
|
||||
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
|
||||
)
|
||||
|
||||
var NoneAIError = errors.New("当前没有配置AI, 暂不支持此功能")
|
||||
|
||||
type NoneAI struct {
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func NewNoneAI(ctx context.Context) AI {
|
||||
return &NoneAI{
|
||||
ctx: ctx,
|
||||
}
|
||||
}
|
||||
|
||||
func (n *NoneAI) GenerateReview(ctx context.Context, prompt string) (string, error) {
|
||||
logger := logs.TraceLogger(ctx, n.ctx, "GenerateReview")
|
||||
logger.Warnf("当前没有配置AI, 无法处理AI请求, 消息: %s", prompt)
|
||||
return "", NoneAIError
|
||||
}
|
||||
|
||||
func (n *NoneAI) AIModel() models.AIModel {
|
||||
return models.AI_MODEL_NONE
|
||||
}
|
||||
Reference in New Issue
Block a user