fix(frontend): separate mock and default LangGraph clients (#1504)
Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
parent
4e14405284
commit
a99b01cda6
|
|
@ -30,8 +30,15 @@ function createCompatibleClient(isMock?: boolean): LangGraphClient {
|
|||
return client;
|
||||
}
|
||||
|
||||
let _singleton: LangGraphClient | null = null;
|
||||
const _clients = new Map<string, LangGraphClient>();
|
||||
export function getAPIClient(isMock?: boolean): LangGraphClient {
|
||||
_singleton ??= createCompatibleClient(isMock);
|
||||
return _singleton;
|
||||
const cacheKey = isMock ? "mock" : "default";
|
||||
let client = _clients.get(cacheKey);
|
||||
|
||||
if (!client) {
|
||||
client = createCompatibleClient(isMock);
|
||||
_clients.set(cacheKey, client);
|
||||
}
|
||||
|
||||
return client;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue