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

community: Skip Login to HuggubgFaceHub when token is not set #21561

Open
wants to merge 25 commits into
base: master
Choose a base branch
from

Conversation

mirkenstein
Copy link
Contributor

@mirkenstein mirkenstein commented May 11, 2024

Thank you for contributing to LangChain!

from langchain_community.llms import HuggingFaceEndpoint

llm = HuggingFaceEndpoint(
    endpoint_url='http://localhost:8080',
    server_kwargs={
        "headers": {"Content-Type": "application/json"}
    }
)
resp = llm.invoke("Tell me a joke")
print(resp)

Also tested against HF Endpoints

from langchain_community.llms import HuggingFaceEndpoint
huggingfacehub_api_token = "hf_xyz"
repo_id = "mistralai/Mistral-7B-Instruct-v0.2"
llm = HuggingFaceEndpoint(
   huggingfacehub_api_token=huggingfacehub_api_token,
   repo_id=repo_id,
)
resp = llm.invoke("Tell me a joke")
print(resp)

Additional guidelines:

  • Make sure optional dependencies are imported within a function.
  • Please do not add dependencies to pyproject.toml files (even optional ones) unless they are required for unit tests.
  • Most PRs should not touch more than one package.
  • Changes should be backwards compatible.
  • If you are adding something to community, do not re-import it in langchain.

If no one reviews your PR within a few days, please @-mention one of baskaryan, efriis, eyurtsev, hwchase17.

Copy link

vercel bot commented May 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview May 31, 2024 3:53pm

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. 🔌: huggingface Primarily related to HuggingFace integrations 🤖:improvement Medium size change to existing code to handle new use-cases labels May 11, 2024
@nwmoon
Copy link

nwmoon commented May 13, 2024

it is necessary function !!

@mirkenstein
Copy link
Contributor Author

Mentioning @mspronesti and @hwchase17 since you were the reviewers on my other HuggingFace PR #21282

@mirkenstein
Copy link
Contributor Author

@eyurtsev

…skip_login' into feature/HuggingFaceEndpoint_hfhub_skip_login

# Conflicts:
#	libs/community/langchain_community/llms/huggingface_endpoint.py
@dosubot dosubot bot removed the size:S This PR changes 10-29 lines, ignoring generated files. label May 20, 2024
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label May 20, 2024
@efriis efriis self-assigned this May 20, 2024
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels May 20, 2024
@mirkenstein
Copy link
Contributor Author

There is a new official library released from Huggning Face
https://huggingface.co/blog/langchain
The new library still has the same issue.

Here is the deprecation warning when using the current community library.

LangChainDeprecationWarning: The class `HuggingFaceEndpoint` was deprecated in LangChain 0.0.37 and will be removed in 0.3. An updated version of the class exists in the from langchain-huggingface package and should be used instead. To use it run `pip install -U from langchain-huggingface` and import as `from from langchain_huggingface import llms import HuggingFaceEndpoint`.
  warn_deprecated(

@mirkenstein mirkenstein changed the title Skip Login for custom endpoint_url in HuggingFaceEndpoint community: Skip Login for custom endpoint_url in HuggingFaceEndpoint May 21, 2024
@mirkenstein
Copy link
Contributor Author

There is a new official library released from Huggning Face https://huggingface.co/blog/langchain The new library still has the same issue.

Here is the deprecation warning when using the current community library.

LangChainDeprecationWarning: The class `HuggingFaceEndpoint` was deprecated in LangChain 0.0.37 and will be removed in 0.3. An updated version of the class exists in the from langchain-huggingface package and should be used instead. To use it run `pip install -U from langchain-huggingface` and import as `from from langchain_huggingface import llms import HuggingFaceEndpoint`.
  warn_deprecated(

The current library is not deprecated yet and it looks like it will be around for quite some time. We can make this change also in the new langchain-huggingface https://github.com/langchain-ai/langchain/blob/master/libs/partners/huggingface/langchain_huggingface/llms/huggingface_endpoint.py as soon as this one gets merged.

@matthewgrossman
Copy link

@mirkenstein Any reason to not just bundle that change into this PR as well? Would help keep the change unified across both clients, easier to track down the original PR, etc

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels May 30, 2024
@mirkenstein
Copy link
Contributor Author

@mirkenstein Any reason to not just bundle that change into this PR as well? Would help keep the change unified across both clients, easier to track down the original PR, etc

One of the guidelines states that "Most PRs should not touch more than one package"
I applied the same change to the partner library and now the checks are failing at "CI / CI Success (pull_request)" step.

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels May 30, 2024
@mirkenstein
Copy link
Contributor Author

@mirkenstein Any reason to not just bundle that change into this PR as well? Would help keep the change unified across both clients, easier to track down the original PR, etc

One of the guidelines states that "Most PRs should not touch more than one package" I applied the same change to the partner library and now the checks are failing at "CI / CI Success (pull_request)" step.

Created #22365 for the new partner client.

@mirkenstein mirkenstein changed the title community: Skip Login for custom endpoint_url in HuggingFaceEndpoint community: Skip Login to HuggubgFaceHub when token is not set May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔌: huggingface Primarily related to HuggingFace integrations 🤖:improvement Medium size change to existing code to handle new use-cases partner size:S This PR changes 10-29 lines, ignoring generated files. template
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handling huggingfacehub_api_token=None for HuggingFaceEndpoint
6 participants