Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

langchain[minor]: use langsmith sdk for prompts functionality instead of langchain hub #6323

Merged
merged 8 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion langchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@
"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;
jacoblee93 marked this conversation as resolved.
Show resolved Hide resolved
/** @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,
description: options?.description,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you still need to respect the old values:

isPublic: options?.isPublic ?? options?.newRepoIsPublic,

readme: options?.readme,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, see above

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);
}
27 changes: 26 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31546,7 +31546,7 @@ __metadata:
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 +31809,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
Loading