From 96e527e2642f800821634598542d269272d7a5f8 Mon Sep 17 00:00:00 2001 From: ChaoLiu Date: Tue, 19 Aug 2025 15:17:50 +0800 Subject: [PATCH] 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 --- store/workspace_setting.go | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/store/workspace_setting.go b/store/workspace_setting.go index f2457d4d1..b48c3a981 100644 --- a/store/workspace_setting.go +++ b/store/workspace_setting.go @@ -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, - }, } }