From cccbe939400aa5f8488871544afcdbf183079e7f Mon Sep 17 00:00:00 2001 From: nessie Date: Thu, 16 Jan 2025 00:00:44 +0400 Subject: [PATCH 1/5] configurable logging --- api/cmd/helix/serve.go | 17 +++++++---------- api/pkg/config/config.go | 2 ++ 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/api/cmd/helix/serve.go b/api/cmd/helix/serve.go index 0d12edbb..73710760 100644 --- a/api/cmd/helix/serve.go +++ b/api/cmd/helix/serve.go @@ -282,20 +282,17 @@ func serve(cmd *cobra.Command, cfg *config.ServerConfig) error { helixInference := openai.NewInternalHelixServer(cfg, ps, scheduler) - // controllerOpenAIClient, err := createOpenAIClient(cfg, helixInference) - // if err != nil { - // return err - // } - - logStores := []logger.LogStore{ - store, - // TODO: bigquery + var logStores []logger.LogStore + + if !cfg.DisableLLMCallLogging { + logStores = []logger.LogStore{ + store, + // TODO: bigquery + } } providerManager := manager.NewProviderManager(cfg, helixInference, logStores...) - // controllerOpenAIClient = logger.Wrap(cfg, controllerOpenAIClient, logStores...) - dataprepOpenAIClient, err := createDataPrepOpenAIClient(cfg, helixInference) if err != nil { return err diff --git a/api/pkg/config/config.go b/api/pkg/config/config.go index c08c70fc..fab11b54 100644 --- a/api/pkg/config/config.go +++ b/api/pkg/config/config.go @@ -29,6 +29,8 @@ type ServerConfig struct { Apps Apps GPTScript GPTScript Triggers Triggers + + DisableLLMCallLogging bool `envconfig:"DISABLE_LLM_CALL_LOGGING" default:"false"` } func LoadServerConfig() (ServerConfig, error) { From 9b010225bf524dc30abce7e3b3f5ad49b231427b Mon Sep 17 00:00:00 2001 From: nessie Date: Thu, 16 Jan 2025 00:00:57 +0400 Subject: [PATCH 2/5] add config variable --- api/pkg/server/handlers.go | 1 + api/pkg/types/types.go | 1 + 2 files changed, 2 insertions(+) diff --git a/api/pkg/server/handlers.go b/api/pkg/server/handlers.go index 77746249..48d49b52 100644 --- a/api/pkg/server/handlers.go +++ b/api/pkg/server/handlers.go @@ -204,6 +204,7 @@ func (apiServer *HelixAPIServer) getConfig() (types.ServerConfigForFrontend, err RudderStackDataPlaneURL: apiServer.Cfg.Janitor.RudderStackDataPlaneURL, ToolsEnabled: apiServer.Cfg.Tools.Enabled, AppsEnabled: apiServer.Cfg.Apps.Enabled, + DisableLLMCallLogging: apiServer.Cfg.DisableLLMCallLogging, Version: data.GetHelixVersion(), }, nil } diff --git a/api/pkg/types/types.go b/api/pkg/types/types.go index dcf80cc4..8c38870f 100644 --- a/api/pkg/types/types.go +++ b/api/pkg/types/types.go @@ -686,6 +686,7 @@ type ServerConfigForFrontend struct { AppsEnabled bool `json:"apps_enabled"` RudderStackWriteKey string `json:"rudderstack_write_key"` RudderStackDataPlaneURL string `json:"rudderstack_data_plane_url"` + DisableLLMCallLogging bool `json:"disable_llm_call_logging"` Version string `json:"version"` } From 1fc752ab534dbcbdc8583c36e0232ebcc1f0954d Mon Sep 17 00:00:00 2001 From: nessie Date: Thu, 16 Jan 2025 00:07:31 +0400 Subject: [PATCH 3/5] set config --- api/pkg/server/handlers.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/pkg/server/handlers.go b/api/pkg/server/handlers.go index 48d49b52..6388271b 100644 --- a/api/pkg/server/handlers.go +++ b/api/pkg/server/handlers.go @@ -223,11 +223,13 @@ func (apiServer *HelixAPIServer) configJS(res http.ResponseWriter, _ *http.Reque } res.Header().Set("Content-Type", "application/javascript") content := fmt.Sprintf(` +window.DISABLE_LLM_CALL_LOGGING = %t window.HELIX_SENTRY_DSN = "%s" window.HELIX_GOOGLE_ANALYTICS = "%s" window.RUDDERSTACK_WRITE_KEY = "%s" window.RUDDERSTACK_DATA_PLANE_URL = "%s" `, + config.DisableLLMCallLogging, config.SentryDSNFrontend, config.GoogleAnalyticsFrontend, config.RudderStackWriteKey, From 1db4c03fd6c1a24f149eee897bf8b41491ddbcec Mon Sep 17 00:00:00 2001 From: nessie Date: Thu, 16 Jan 2025 00:09:42 +0400 Subject: [PATCH 4/5] show disabled state --- frontend/src/components/app/AppLogsTable.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/app/AppLogsTable.tsx b/frontend/src/components/app/AppLogsTable.tsx index 0f08bb65..904c4441 100644 --- a/frontend/src/components/app/AppLogsTable.tsx +++ b/frontend/src/components/app/AppLogsTable.tsx @@ -22,6 +22,8 @@ interface AppLogsTableProps { appId: string; } +const win = (window as any) + const AppLogsTable: FC = ({ appId }) => { const api = useApi(); const [llmCalls, setLLMCalls] = useState(null); @@ -112,8 +114,13 @@ const AppLogsTable: FC = ({ appId }) => { - {llmCalls.calls.map((call: LLMCall) => ( - + { win.DISABLE_LLM_CALL_LOGGING ? ( + + LLM call logging is disabled by the administrator. + + ) : ( + llmCalls.calls.map((call: LLMCall) => ( + {new Date(call.created).toLocaleString()} {call.session_id} {call.step || 'n/a'} @@ -128,8 +135,9 @@ const AppLogsTable: FC = ({ appId }) => { - - ))} + + )) + )} From 85d8f907506b4c70f2de15cce3b65022714a88f4 Mon Sep 17 00:00:00 2001 From: nessie Date: Thu, 16 Jan 2025 00:09:50 +0400 Subject: [PATCH 5/5] disabled state in the admin page --- .../src/components/dashboard/LLMCallsTable.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/frontend/src/components/dashboard/LLMCallsTable.tsx b/frontend/src/components/dashboard/LLMCallsTable.tsx index c51f30f1..db66344a 100644 --- a/frontend/src/components/dashboard/LLMCallsTable.tsx +++ b/frontend/src/components/dashboard/LLMCallsTable.tsx @@ -30,6 +30,8 @@ const LLMCallsTable: FC = ({ sessionFilter }) => { const [modalContent, setModalContent] = useState(null); const [modalOpen, setModalOpen] = useState(false); + const win = (window as any) + const fetchLLMCalls = async () => { try { const queryParams = new URLSearchParams({ @@ -99,9 +101,14 @@ const LLMCallsTable: FC = ({ sessionFilter }) => { - {llmCalls.calls.map((call: LLMCall) => ( - - {call.id} + { win.DISABLE_LLM_CALL_LOGGING ? ( + + LLM call logging is disabled by the administrator. + + ) : ( + llmCalls.calls.map((call: LLMCall) => ( + + {call.id} {new Date(call.created).toLocaleString()} {call.session_id} {call.interaction_id} @@ -120,8 +127,9 @@ const LLMCallsTable: FC = ({ sessionFilter }) => { - - ))} + + )) + )}