Skip to content

Commit

Permalink
langchain[minor]: use langsmith sdk for prompts functionality instead…
Browse files Browse the repository at this point in the history
… of langchain hub (langchain-ai#6323)

* feat: use langsmith sdk for prompts functionality instead of langchainhub

* update langsmith version

* yarn install

* deprecate old args

* honor old args

* rm langchainhub dependency

---------

Co-authored-by: Brace Sproul <braceasproul@gmail.com>
  • Loading branch information
madams0013 and bracesproul authored Aug 1, 2024
1 parent f7ceff1 commit ce21b55
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 9 deletions.
3 changes: 1 addition & 2 deletions langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,8 +941,7 @@
"js-tiktoken": "^1.0.12",
"js-yaml": "^4.1.0",
"jsonpointer": "^5.0.1",
"langchainhub": "~0.0.8",
"langsmith": "~0.1.30",
"langsmith": "~0.1.40",
"ml-distance": "^4.0.0",
"openapi-types": "^12.1.3",
"p-retry": "4",
Expand Down
32 changes: 27 additions & 5 deletions langchain/src/hub.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand All @@ -13,10 +13,30 @@ import { load } from "./load/index.js";
export async function push(
repoFullName: string,
runnable: Runnable,
options?: HubPushOptions & ClientConfiguration
options?: {
apiKey?: string;
apiUrl?: string;
parentCommitHash?: string;
/** @deprecated Use isPublic instead. */
newRepoIsPublic?: boolean;
isPublic?: boolean;
/** @deprecated Use description instead. */
newRepoDescription?: string;
description?: 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?.isPublic ?? options?.newRepoIsPublic,
description: options?.description ?? options?.newRepoDescription,
readme: options?.readme,
tags: options?.tags,
};
return client.pushPrompt(repoFullName, payloadOptions);
}

/**
Expand All @@ -27,9 +47,11 @@ export async function push(
*/
export async function pull<T extends Runnable>(
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<T>(result);
}
28 changes: 26 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31545,8 +31545,7 @@ __metadata:
js-yaml: ^4.1.0
jsdom: ^22.1.0
jsonpointer: ^5.0.1
langchainhub: ~0.0.8
langsmith: ~0.1.30
langsmith: ~0.1.40
mammoth: ^1.5.1
ml-distance: ^4.0.0
mongodb: ^5.2.0
Expand Down Expand Up @@ -31809,6 +31808,31 @@ __metadata:
languageName: node
linkType: hard

"langsmith@npm:~0.1.40":
version: 0.1.40
resolution: "langsmith@npm:0.1.40"
dependencies:
"@types/uuid": ^9.0.1
commander: ^10.0.1
p-queue: ^6.6.2
p-retry: 4
semver: ^7.6.3
uuid: ^9.0.0
peerDependencies:
"@langchain/core": "*"
langchain: "*"
openai: "*"
peerDependenciesMeta:
"@langchain/core":
optional: true
langchain:
optional: true
openai:
optional: true
checksum: 8c5bcf5137e93a9a17203fbe21d6a61f45c98fccafc2040d56e9cc15a4ee432456d986adf0e590d8c436b72d18143053ce6e65f021115f1596dd4519ec2805d7
languageName: node
linkType: hard

"language-subtag-registry@npm:^0.3.20, language-subtag-registry@npm:~0.3.2":
version: 0.3.22
resolution: "language-subtag-registry@npm:0.3.22"
Expand Down

0 comments on commit ce21b55

Please sign in to comment.