@langchain/langgraph-sdk
Version:
Client library for interacting with the LangGraph API
29 lines (28 loc) • 985 B
JavaScript
const require_base = require("../base.cjs");
//#region src/client/ui-internal/index.ts
var UiClient = class UiClient extends require_base.BaseClient {
static promiseCache = {};
static getOrCached(key, fn) {
if (UiClient.promiseCache[key] != null) return UiClient.promiseCache[key];
const promise = fn();
UiClient.promiseCache[key] = promise;
return promise;
}
async getComponent(assistantId, agentName) {
return UiClient.getOrCached(`${this.apiUrl}-${assistantId}-${agentName}`, async () => {
let [url, init] = this.prepareFetchOptions(`/ui/${require_base.encodePathSegment(assistantId)}`, {
headers: {
Accept: "text/html",
"Content-Type": "application/json"
},
method: "POST",
json: { name: agentName }
});
if (this.onRequest != null) init = await this.onRequest(url, init);
return (await this.asyncCaller.fetch(url.toString(), init)).text();
});
}
};
//#endregion
exports.UiClient = UiClient;
//# sourceMappingURL=index.cjs.map