From ade4dcb9c38baf4fbc80bf39ca085c9f07130381 Mon Sep 17 00:00:00 2001 From: jacoblee93 Date: Fri, 10 Jan 2025 13:14:26 -0800 Subject: [PATCH] Apply to metadata --- langchain/src/hub.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/langchain/src/hub.ts b/langchain/src/hub.ts index b1e4b8b5e9d1..1ad631030778 100644 --- a/langchain/src/hub.ts +++ b/langchain/src/hub.ts @@ -55,12 +55,18 @@ export async function pull( includeModel: options?.includeModel, }); - const prompt = await load(JSON.stringify(promptObject.manifest)); - return prompt.withConfig({ - metadata: { - lc_hub_owner: promptObject.owner, - lc_hub_repo: promptObject.repo, - lc_hub_commit_hash: promptObject.commit_hash, - }, - }); + if (promptObject.manifest.kwargs?.metadata === undefined) { + promptObject.manifest.kwargs = { + ...promptObject.manifest.kwargs, + metadata: {}, + }; + } + + promptObject.manifest.kwargs.metadata = { + ...promptObject.manifest.kwargs.metadata, + lc_hub_owner: promptObject.owner, + lc_hub_repo: promptObject.repo, + lc_hub_commit_hash: promptObject.commit_hash, + }; + return load(JSON.stringify(promptObject.manifest)); }