diff --git a/src/snippets/chat-model-tabs.mdx b/src/snippets/chat-model-tabs.mdx index 242f395913..a2fc9cae07 100644 --- a/src/snippets/chat-model-tabs.mdx +++ b/src/snippets/chat-model-tabs.mdx @@ -134,5 +134,43 @@ model = ChatBedrock(model="anthropic.claude-3-5-sonnet-20240620-v1:0") ``` + + + 👉 Read the [HuggingFace chat model integration docs](/oss/python/integrations/chat/huggingface/) + + ```shell + pip install -U "langchain[huggingface]" + ``` + + + ```python init_chat_model + import os + from langchain.chat_models import init_chat_model + + os.environ["HUGGINGFACEHUB_API_TOKEN"] = "hf_..." + + model = init_chat_model( + "microsoft/Phi-3-mini-4k-instruct", + model_provider="huggingface", + temperature=0.7, + max_tokens=1024, + ) + ``` + + ```python Model Class + import os + from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint + + os.environ["HUGGINGFACEHUB_API_TOKEN"] = "hf_..." + + llm = HuggingFaceEndpoint( + repo_id="microsoft/Phi-3-mini-4k-instruct", + temperature=0.7, + max_length=1024, + ) + model = ChatHuggingFace(llm=llm) + ``` + +