From 1acb486ec39f9dcc680a434810979e0998ffc03d Mon Sep 17 00:00:00 2001 From: avisab-cx Date: Sun, 8 Sep 2024 12:36:18 +0300 Subject: [PATCH] move urls to binds --- internal/commands/chat-kics.go | 2 -- internal/commands/chat-sast.go | 10 ++++++++-- internal/params/binds.go | 2 ++ internal/params/envs.go | 2 ++ internal/params/keys.go | 2 ++ 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/commands/chat-kics.go b/internal/commands/chat-kics.go index 17cafd3e1..d9af805f8 100644 --- a/internal/commands/chat-kics.go +++ b/internal/commands/chat-kics.go @@ -43,8 +43,6 @@ const FileErrorFormat = "It seems that %s is not available for AI Guided Remedia // chatModel model to use when calling the CheckmarxAI const checkmarxAiChatModel = "gpt-4" -const aiProxyAzureAIRoute = "api/ai-proxy/redirect/externalAzure" -const aiProxyCheckmarxAIRoute = "api/ai-proxy/redirect/azure" const tenantIDClaimKey = "tenant_id" const guidedRemediationFeatureNameKics = "cli-guided-remediation-kics" const guidedRemediationFeatureNameSast = "cli-guided-remediation-sast" diff --git a/internal/commands/chat-sast.go b/internal/commands/chat-sast.go index ed58dc869..b03c4b7dd 100644 --- a/internal/commands/chat-sast.go +++ b/internal/commands/chat-sast.go @@ -96,7 +96,11 @@ func runChatSast( } } -func getSastConversationDetails(cmd *cobra.Command, chatConversationID string, statefulWrapper wrapper.StatefulWrapper) (bool, string, uuid.UUID, error, bool) { +func getSastConversationDetails( + cmd *cobra.Command, + chatConversationID string, + statefulWrapper wrapper.StatefulWrapper, +) (bool, string, uuid.UUID, error, bool) { newConversation := false var userInput string if chatConversationID == "" { @@ -119,7 +123,7 @@ func getSastConversationDetails(cmd *cobra.Command, chatConversationID string, s return newConversation, userInput, id, nil, false } -func buildSastMessages(cmd *cobra.Command, newConversation bool, scanResultsFile string, sastResultID string, sourceDir string, id uuid.UUID, userInput string) ([]message.Message, error, bool) { +func buildSastMessages(cmd *cobra.Command, newConversation bool, scanResultsFile, sastResultID, sourceDir string, id uuid.UUID, userInput string) ([]message.Message, error, bool) { var newMessages []message.Message if newConversation { systemPrompt, userPrompt, e := sastchat.BuildPrompt(scanResultsFile, sastResultID, sourceDir) @@ -150,10 +154,12 @@ func CreateStatefulWrapper(cmd *cobra.Command, azureAiEnabled, checkmarxAiEnable customerToken, _ = wrappers.GetAccessToken() if azureAiEnabled { + aiProxyAzureAIRoute := viper.GetString(params.AiProxyAzureAiRouteKey) aiProxyEndPoint, _ := wrappers.GetURL(aiProxyAzureAIRoute, customerToken) model, _ := GetAzureAiModel(tenantConfigurationResponses) statefulWrapper, _ = wrapper.NewStatefulWrapperNew(conn, aiProxyEndPoint, customerToken, model, dropLen, 0) } else if checkmarxAiEnabled { + aiProxyCheckmarxAIRoute := viper.GetString(params.AiProxyCheckmarxAiRouteKey) aiProxyEndPoint, _ := wrappers.GetURL(aiProxyCheckmarxAIRoute, customerToken) model := checkmarxAiChatModel statefulWrapper, _ = wrapper.NewStatefulWrapperNew(conn, aiProxyEndPoint, customerToken, model, dropLen, 0) diff --git a/internal/params/binds.go b/internal/params/binds.go index 5f4b3131b..def15d806 100644 --- a/internal/params/binds.go +++ b/internal/params/binds.go @@ -63,4 +63,6 @@ var EnvVarsBinds = []struct { {AccessManagementPathKey, AccessManagementPathEnv, "api/access-management"}, {ByorPathKey, ByorPathEnv, "api/byor"}, {VorpalPortKey, VorpalPortEnv, ""}, + {AiProxyAzureAiRouteKey, AiProxyAzureAiRouteEnv, "api/ai-proxy/redirect/externalAzure"}, + {AiProxyCheckmarxAiRouteKey, AiProxyCheckmarxAiRouteEnv, "api/ai-proxy/redirect/azure"}, } diff --git a/internal/params/envs.go b/internal/params/envs.go index a776100f2..c355a85c4 100644 --- a/internal/params/envs.go +++ b/internal/params/envs.go @@ -62,4 +62,6 @@ const ( ByorPathEnv = "CX_BYOR_PATH" IgnoreProxyEnv = "CX_IGNORE_PROXY" VorpalPortEnv = "CX_VORPAL_PORT" + AiProxyAzureAiRouteEnv = "CX_AIPROXY_AZUREAI_ROUTE" + AiProxyCheckmarxAiRouteEnv = "CX_AIPROXY_CHECKMARXAI_ROUTE" ) diff --git a/internal/params/keys.go b/internal/params/keys.go index 8dcb84e95..613951282 100644 --- a/internal/params/keys.go +++ b/internal/params/keys.go @@ -62,4 +62,6 @@ var ( AccessManagementPathKey = strings.ToLower(AccessManagementPathEnv) ByorPathKey = strings.ToLower(ByorPathEnv) VorpalPortKey = strings.ToLower(VorpalPortEnv) + AiProxyAzureAiRouteKey = strings.ToLower(AiProxyAzureAiRouteEnv) + AiProxyCheckmarxAiRouteKey = strings.ToLower(AiProxyCheckmarxAiRouteEnv) )