langchainhub
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -22,3 +22,3 @@ import { getEnvironmentVariable } from "./utils/env.js"; | ||
if (!ownerRepo.includes("/")) { | ||
throw new Error(`Invalid identifier ${identifier}. Identifier must be in the format of 'owner/repo:commit' or 'owner/repo'.`); | ||
return ["-", ownerRepo, commit]; | ||
} | ||
@@ -237,6 +237,18 @@ const [owner, repo] = ownerRepo.split("/"); | ||
async push(repoFullName, manifestJson, options) { | ||
const { parentCommitHash = "latest", newRepoIsPublic = true, newRepoDescription = "", } = options ?? {}; | ||
let repo; | ||
const { parentCommitHash = "latest", newRepoIsPublic = false, newRepoDescription = "", } = options ?? {}; | ||
const settings = await this.getSettings(); | ||
if (newRepoIsPublic && !settings.tenant_handle) { | ||
throw new Error(` | ||
Cannot create public prompt without first creating a LangChain Hub handle. | ||
You can add a handle by creating a public prompt at: | ||
https://smith.langchain.com/prompts | ||
This is a workspace-level handle and will be associated with all of your workspace's public prompts in the LangChain Hub. | ||
`); | ||
} | ||
const [owner, repoHandle, _] = parseOwnerRepoCommit(repoFullName); | ||
const fullRepo = `${owner}/${repoHandle}`; | ||
try { | ||
repo = await this.getRepo(repoFullName); | ||
await this.getRepo(fullRepo); | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -248,10 +260,6 @@ } | ||
} | ||
const info = parseOwnerRepoCommit(repoFullName); | ||
const owner = info[0]; | ||
repo = info[1]; | ||
const res = await this.getSettings(); | ||
if (res.tenant_handle !== owner) { | ||
throw new Error(`Tenant "${res.tenant_handle}" is not the owner of repo "${repoFullName}".`); | ||
if (settings.tenant_handle && owner !== '-' && settings.tenant_handle !== owner) { | ||
throw new Error(`Tenant "${settings.tenant_handle}" is not the owner of repo "${repoFullName}".`); | ||
} | ||
await this.createRepo(repo, { | ||
await this.createRepo(repoHandle, { | ||
description: newRepoDescription, | ||
@@ -262,5 +270,5 @@ isPublic: newRepoIsPublic, | ||
const resolvedParentCommitHash = parentCommitHash === "latest" | ||
? await this._getLatestCommitHash(repoFullName) | ||
? await this._getLatestCommitHash(fullRepo) | ||
: parentCommitHash; | ||
const res = await fetch(`${this.apiUrl}/commits/${repoFullName}`, { | ||
const res = await fetch(`${this.apiUrl}/commits/${fullRepo}`, { | ||
method: "POST", | ||
@@ -285,3 +293,3 @@ headers: this._getHeaders("POST"), | ||
const shortHash = commitHash.slice(0, 8); | ||
return `${this._hostUrl}/hub/${repoFullName}/${shortHash}`; | ||
return `${this._hostUrl}/prompts/${repoHandle}/${shortHash}?organizationId=${settings.id}`; | ||
} | ||
@@ -288,0 +296,0 @@ async pull(ownerRepoCommit) { |
{ | ||
"name": "langchainhub", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Client library for connecting to the LangChain Hub.", | ||
"author": "LangChain", | ||
"license": "MIT", | ||
"packageManager": "yarn@3.5.1", | ||
"packageManager": "yarn@1.22.9", | ||
"type": "module", | ||
@@ -9,0 +9,0 @@ "main": "./dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35047
766