UNPKG

@langchain/langgraph-sdk

Version:

Client library for interacting with the LangGraph API

29 lines (28 loc) • 965 B
import { BaseClient, encodePathSegment } from "../base.js"; //#region src/client/ui-internal/index.ts var UiClient = class UiClient extends 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/${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 export { UiClient }; //# sourceMappingURL=index.js.map