[Security Assistant] Fixes LangSmith support for specifying configuration via env vars (#180426)

## Summary

With https://github.com/elastic/kibana/pull/180227, LangSmith
configuration (Project & API Key) could no longer be specified using
environment variables when working locally. This fixes that issue, which
was caused by sending `''` for `langSmithProject` and `langSmithApiKey`
instead of `undefined`.

To test, set the below env vars, then start kibana. Be sure to not have
the UI trace options set as shown in
https://github.com/elastic/kibana/pull/180227.


```
# LangChain LangSmith
export LANGCHAIN_TRACING_V2=true
export LANGCHAIN_ENDPOINT="https://api.smith.langchain.com"
export LANGCHAIN_API_KEY="🫣"
export LANGCHAIN_PROJECT="Best Project Ever"
```
This commit is contained in:
Garrett Spong 2024-04-09 18:25:19 -06:00 committed by GitHub
parent 49e9294f69
commit e7401d35c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 5 additions and 3 deletions

View file

@ -80,8 +80,10 @@ export const fetchConnectorExecuteAction = async ({
replacements,
isEnabledKnowledgeBase,
isEnabledRAGAlerts,
langSmithProject: traceOptions?.langSmithProject,
langSmithApiKey: traceOptions?.langSmithApiKey,
langSmithProject:
traceOptions?.langSmithProject === '' ? undefined : traceOptions?.langSmithProject,
langSmithApiKey:
traceOptions?.langSmithApiKey === '' ? undefined : traceOptions?.langSmithApiKey,
...optionalRequestParams,
};

View file

@ -124,7 +124,7 @@ export const getLangSmithTracer = ({
return [];
}
const lcTracer = new LangChainTracer({
projectName: projectName ?? 'default', // Shows as the 'test' run's 'name' in langsmith ui
projectName, // Shows as the 'test' run's 'name' in langsmith ui
exampleId,
client: new Client({ apiKey }),
});