fix: improve AI settings initialization and local service support

- Add dedicated default constants for tag recommendation config
- Set tag recommendation enabled to false by default instead of following AI enable state
- Remove API key requirement for AI enablement to support local services like Ollama
- Simplify loadAISettingFromEnv by removing redundant tag recommendation setup

Signed-off-by: ChaoLiu <chaoliu719@gmail.com>
This commit is contained in:
ChaoLiu 2025-08-19 15:17:50 +08:00
parent 0443fdc976
commit 96e527e264

View file

@ -213,8 +213,10 @@ func (s *Store) GetWorkspaceStorageSetting(ctx context.Context) (*storepb.Worksp
}
const (
defaultAIEnabled = false
defaultAITimeoutSeconds = int32(15)
defaultAITagRecommandationEnabled = false
defaultAITagRecommandationPrompt = ""
defaultAITagRecommandationRPM = int32(10)
)
func (s *Store) GetWorkspaceAISetting(ctx context.Context) (*storepb.WorkspaceAISetting, error) {
@ -241,9 +243,9 @@ func (s *Store) GetWorkspaceAISetting(ctx context.Context) (*storepb.WorkspaceAI
// Set default tag recommendation config if not configured
if workspaceAISetting.TagRecommendation == nil {
workspaceAISetting.TagRecommendation = &storepb.TagRecommendationConfig{
Enabled: workspaceAISetting.EnableAi,
SystemPrompt: "",
RequestsPerMinute: 10,
Enabled: defaultAITagRecommandationEnabled,
SystemPrompt: defaultAITagRecommandationPrompt,
RequestsPerMinute: defaultAITagRecommandationRPM,
}
}
@ -267,8 +269,7 @@ func loadAISettingFromEnv() *storepb.WorkspaceAISetting {
apiKey := os.Getenv("AI_API_KEY")
model := os.Getenv("AI_MODEL")
// Enable AI if all required fields are provided via environment variables
enableAI := baseURL != "" && apiKey != "" && model != ""
enableAI := baseURL != "" && model != ""
return &storepb.WorkspaceAISetting{
EnableAi: enableAI,
@ -276,11 +277,6 @@ func loadAISettingFromEnv() *storepb.WorkspaceAISetting {
ApiKey: apiKey,
Model: model,
TimeoutSeconds: timeoutSeconds,
TagRecommendation: &storepb.TagRecommendationConfig{
Enabled: enableAI,
SystemPrompt: "",
RequestsPerMinute: 10,
},
}
}