From 5d8d540a7c292baeab8d6bc4a61ae85a196652b7 Mon Sep 17 00:00:00 2001 From: Maddy Adams Date: Thu, 1 Aug 2024 14:05:28 -0700 Subject: [PATCH] feat: use langsmith sdk for prompts functionality instead of langchainhub --- langchain/src/hub.ts | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/langchain/src/hub.ts b/langchain/src/hub.ts index ac2f958b08a6..e038ebea03f9 100644 --- a/langchain/src/hub.ts +++ b/langchain/src/hub.ts @@ -1,4 +1,4 @@ -import { Client, ClientConfiguration, HubPushOptions } from "langchainhub"; +import { Client } from "langsmith"; import { Runnable } from "@langchain/core/runnables"; import { load } from "./load/index.js"; @@ -13,10 +13,26 @@ import { load } from "./load/index.js"; export async function push( repoFullName: string, runnable: Runnable, - options?: HubPushOptions & ClientConfiguration + options?: { + apiKey?: string; + apiUrl?: string; + parentCommitHash?: string; + newRepoIsPublic?: boolean; + newRepoDescription?: string; + readme?: string; + tags?: string[]; + } ) { const client = new Client(options); - return client.push(repoFullName, JSON.stringify(runnable), options); + const payloadOptions = { + object: runnable, + parentCommitHash: options?.parentCommitHash, + isPublic: options?.newRepoIsPublic, + description: options?.newRepoDescription, + readme: options?.readme, + tags: options?.tags, + }; + return client.pushPrompt(repoFullName, payloadOptions); } /** @@ -27,9 +43,11 @@ export async function push( */ export async function pull( ownerRepoCommit: string, - options?: ClientConfiguration + options?: { apiKey?: string; apiUrl?: string; includeModel?: boolean } ) { const client = new Client(options); - const result = await client.pull(ownerRepoCommit); + const result = await client._pullPrompt(ownerRepoCommit, { + includeModel: options?.includeModel, + }); return load(result); }