()
| 55 | * next to the manually-emitted parent/child RunTree. |
| 56 | */ |
| 57 | export const getLangSmithEnvConfig = (): { apiKey: string; endpoint?: string; projectName?: string } | undefined => { |
| 58 | const tracingFlag = getEnvironmentVariable('LANGSMITH_TRACING') ?? getEnvironmentVariable('LANGCHAIN_TRACING_V2') |
| 59 | if (tracingFlag !== 'true') return undefined |
| 60 | |
| 61 | const apiKey = getEnvironmentVariable('LANGSMITH_API_KEY') ?? getEnvironmentVariable('LANGCHAIN_API_KEY') |
| 62 | if (!apiKey) return undefined |
| 63 | |
| 64 | const endpoint = getEnvironmentVariable('LANGSMITH_ENDPOINT') ?? getEnvironmentVariable('LANGCHAIN_ENDPOINT') |
| 65 | const projectName = getEnvironmentVariable('LANGSMITH_PROJECT') ?? getEnvironmentVariable('LANGCHAIN_PROJECT') |
| 66 | |
| 67 | // the four LangChain tracing-flag env vars are deleted from `process.env`. Flowise owns tracing |
| 68 | // emission from this point on; leaving the flags set would letLangChain's auto-tracer fire on |
| 69 | // every `.invoke()`/`.call()` and produce orphan top-level runs next to the manually-emitted |
| 70 | // parent/child RunTree. |
| 71 | for (const k of LANGCHAIN_TRACING_FLAG_VARS) delete process.env[k] |
| 72 | |
| 73 | return { apiKey, endpoint, projectName } |
| 74 | } |
| 75 | |
| 76 | export const TRACING_ENV_PROVIDERS: TracingEnvProvider[] = [ |
| 77 | { |
no test coverage detected