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

specifying commit hash in hub.pull is not working #4289

Closed
CNSeniorious000 opened this issue Feb 5, 2024 · 3 comments · Fixed by #4382
Closed

specifying commit hash in hub.pull is not working #4289

CNSeniorious000 opened this issue Feb 5, 2024 · 3 comments · Fixed by #4382
Assignees
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature

Comments

@CNSeniorious000
Copy link

Description

For example, these two should be different:

import { pull } from "langchain/hub"

await pull("langchain-ai/chain-of-density")
await pull("langchain-ai/chain-of-density:ba34ae10")

But the result is the same.

A simple reproduction

> (await pull("langchain-ai/chain-of-density:ba34ae10")).promptMessages[0].prompt.template === (await pull("langchain-ai/chain-of-density")).promptMessages[0].prompt.template
// true

Note that the python SDK is working, but in the JavaScript SDK it seems specifying a commit hash is useless. I don't know why.

@CNSeniorious000 CNSeniorious000 changed the title specifying commit hash of prompt in hub.pull is not working specifying commit hash in hub.pull is not working Feb 5, 2024
Copy link

dosubot bot commented Feb 5, 2024

🤖

Thank you for bringing this to our attention. Based on the provided context, it seems that the pull function should be able to handle a commit hash if it's provided. However, the actual behavior of the pull function isn't explicitly defined in the provided context.

The commit hash is handled in the fetchRepoFiles method of the GithubRepoLoader class. When fetching the files from a GitHub repository, the commit hash is provided as the ref query parameter in the URL used to fetch the files. Here is the relevant code:

/**
   * Fetches the files from a GitHub repository.
   * If the path denotes a single file, the resulting array contains only one element.
   * @param path The path of the repository to fetch the files from.
   * @returns A promise that resolves to an array of GithubFile instances.
   */
  private async fetchRepoFiles(path: string): Promise<GithubFile[]> {
    const url = `${this.apiUrl}/repos/${this.owner}/${this.repo}/contents/${path}?ref=${this.branch}`;
    return this.caller.call(async () => {
      this.log(`Fetching ${url}`);
      const response = await fetch(url, { headers: this.headers });
      const data = await response.json();
      if (!response.ok) {
        throw new Error(
          `Unable to fetch repository files: ${
            response.status
          } ${JSON.stringify(data)}`
        );
      }

      if (Array.isArray(data)) {
        return data as GithubFile[];
      } else {
        return [data as GithubFile];
      }
    });
  }

In this method, this.branch is used as the ref query parameter. This branch property is set when creating a new instance of GithubRepoLoader and can be a branch name or a commit hash. If a commit hash is provided when creating the GithubRepoLoader instance, it will be used as the ref when fetching the repository files.

However, without the actual implementation of the pull function, it's hard to say why specifying a commit hash doesn't seem to have any effect. It's possible that the pull function doesn't correctly pass the commit hash to the GithubRepoLoader instance, or that there's some other issue.

To help us investigate this further, could you please provide more information about how you're using the pull function? Specifically, it would be helpful to know how you're creating the GithubRepoLoader instance and how you're passing the commit hash to the pull function. Any additional context or code samples would be greatly appreciated.

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added the auto:bug Related to a bug, vulnerability, unexpected error with an existing feature label Feb 5, 2024
@bracesproul
Copy link
Collaborator

Hmm I'm seeing this issue too, not good. Will investigate now!

@bracesproul bracesproul self-assigned this Feb 5, 2024
@bracesproul
Copy link
Collaborator

I've identified a fix and it will be released soon! I'll update you here once we update the langchain package with it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto:bug Related to a bug, vulnerability, unexpected error with an existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants