Skip to content

Commit

Permalink
Apply to metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblee93 committed Jan 10, 2025
1 parent e03d734 commit ade4dcb
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions langchain/src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,18 @@ export async function pull<T extends Runnable>(
includeModel: options?.includeModel,
});

const prompt = await load<T>(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<T>(JSON.stringify(promptObject.manifest));
}

0 comments on commit ade4dcb

Please sign in to comment.