Skip to content
Merged
Changes from all 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
38 changes: 38 additions & 0 deletions src/snippets/chat-model-tabs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,43 @@
model = ChatBedrock(model="anthropic.claude-3-5-sonnet-20240620-v1:0")
```
</CodeGroup>

<Tab title="HuggingFace">
👉 Read the [HuggingFace chat model integration docs](/oss/python/integrations/chat/huggingface/)

```shell
pip install -U "langchain[huggingface]"
```

<CodeGroup>
```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)
```
</CodeGroup>
</Tab>
</Tab>
</Tabs>