🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
feat(ui): in api key .env show actual base_url and show .env in new api key modal (#10359)
Marc Klingenfee68b6c690b
diff --git a/web/src/features/public-api/components/ApiKeyList.tsx b/web/src/features/public-api/components/ApiKeyList.tsxindex b5335bf379..9723f6b960 100644--- a/web/src/features/public-api/components/ApiKeyList.tsx+++ b/web/src/features/public-api/components/ApiKeyList.tsx@@ -29,23 +29,21 @@ import { TrashIcon } from "lucide-react";import { useState } from "react";import { Alert, AlertDescription, AlertTitle } from "@/src/components/ui/alert";import { startCase } from "lodash";+import { useLangfuseEnvCode } from "@/src/features/public-api/hooks/useLangfuseEnvCode";type ApiKeyScope = "project" | "organization";type ApiKeyEntity = { id: string; note: string | null };export function ApiKeyList(props: { entityId: string; scope: ApiKeyScope }) {const { entityId, scope } = props;+ const envCode = useLangfuseEnvCode();+if (!entityId) {throw new Error(`${scope}Id is required for ApiKeyList with scope ${scope}`,);}- const envCode = `LANGFUSE_SECRET_KEY = "sk-lf-..."-LANGFUSE_PUBLIC_KEY = "pk-lf-..."-LANGFUSE_BASE_URL = "https://cloud.langfuse.com" # 🇪🇺 EU region-# LANGFUSE_BASE_URL = "https://us.cloud.langfuse.com" # 🇺🇸 US region`;-const hasProjectAccess = useHasProjectAccess({projectId: props.entityId,scope: "apiKeys:CUD",diff --git a/web/src/features/public-api/components/CreateApiKeyButton.tsx b/web/src/features/public-api/components/CreateApiKeyButton.tsxindex b121107dd4..3bb018969b 100644--- a/web/src/features/public-api/components/CreateApiKeyButton.tsx+++ b/web/src/features/public-api/components/CreateApiKeyButton.tsx@@ -15,9 +15,8 @@ import { CodeView } from "@/src/components/ui/CodeJsonViewer";import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";import { useHasOrganizationAccess } from "@/src/features/rbac/utils/checkOrganizationAccess";import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";-import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";-import { env } from "@/src/env.mjs";import { Input } from "@/src/components/ui/input";+import { useLangfuseEnvCode } from "@/src/features/public-api/hooks/useLangfuseEnvCode";import { Label } from "@/src/components/ui/label";import { cn } from "@/src/utils/tailwind";import { SubHeader } from "@/src/components/layouts/header";@@ -167,7 +166,8 @@ export const ApiKeyRender = ({generatedKeys?: { secretKey: string; publicKey: string };className?: string;}) => {- const uiCustomization = useUiCustomization();+ const envCode = useLangfuseEnvCode(generatedKeys);+return (<div className={cn("space-y-6", className)}><div>@@ -189,11 +189,8 @@ export const ApiKeyRender = ({/></div><div>- <SubHeader title="Host" />- <CodeView- content={`${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`}- className="mt-2"- />+ <SubHeader title=".env" />+ <CodeView content={envCode} className="mt-2" /></div></div>);diff --git a/web/src/features/public-api/hooks/useLangfuseEnvCode.ts b/web/src/features/public-api/hooks/useLangfuseEnvCode.tsnew file mode 100644index 0000000000..9ec94b10dc--- /dev/null+++ b/web/src/features/public-api/hooks/useLangfuseEnvCode.ts@@ -0,0 +1,20 @@+import { useUiCustomization } from "@/src/ee/features/ui-customization/useUiCustomization";+import { env } from "@/src/env.mjs";++export function useLangfuseEnvCode(keys?: {+ secretKey: string;+ publicKey: string;+}): string {+ const uiCustomization = useUiCustomization();+ const baseUrl = `${uiCustomization?.hostname ?? window.origin}${env.NEXT_PUBLIC_BASE_PATH ?? ""}`;++ if (keys) {+ return `LANGFUSE_SECRET_KEY = "${keys.secretKey}"+LANGFUSE_PUBLIC_KEY = "${keys.publicKey}"+LANGFUSE_BASE_URL = "${baseUrl}"`;+ }++ return `LANGFUSE_SECRET_KEY = "sk-lf-..."+LANGFUSE_PUBLIC_KEY = "pk-lf-..."+LANGFUSE_BASE_URL = "${baseUrl}"`;+}