|
134 | 134 | model = ChatBedrock(model="anthropic.claude-3-5-sonnet-20240620-v1:0") |
135 | 135 | ``` |
136 | 136 | </CodeGroup> |
| 137 | + </Tab> |
| 138 | + <Tab title="HuggingFace"> |
| 139 | + 👉 Read the [HuggingFace chat model integration docs](/oss/python/integrations/chat/huggingface/) |
137 | 140 |
|
138 | | -<Tab title="HuggingFace"> |
139 | | - 👉 Read the [HuggingFace chat model integration docs](/oss/python/integrations/chat/huggingface/) |
140 | | - |
141 | | - ```shell |
142 | | - pip install -U "langchain[huggingface]" |
143 | | - ``` |
| 141 | + ```shell |
| 142 | + pip install -U "langchain[huggingface]" |
| 143 | + ``` |
144 | 144 |
|
145 | | - <CodeGroup> |
146 | | - ```python init_chat_model |
147 | | - import os |
148 | | - from langchain.chat_models import init_chat_model |
| 145 | + <CodeGroup> |
| 146 | + ```python init_chat_model |
| 147 | + import os |
| 148 | + from langchain.chat_models import init_chat_model |
149 | 149 |
|
150 | | - os.environ["HUGGINGFACEHUB_API_TOKEN"] = "hf_..." |
| 150 | + os.environ["HUGGINGFACEHUB_API_TOKEN"] = "hf_..." |
151 | 151 |
|
152 | | - model = init_chat_model( |
153 | | - "microsoft/Phi-3-mini-4k-instruct", |
154 | | - model_provider="huggingface", |
155 | | - temperature=0.7, |
156 | | - max_tokens=1024, |
157 | | - ) |
158 | | - ``` |
| 152 | + model = init_chat_model( |
| 153 | + "microsoft/Phi-3-mini-4k-instruct", |
| 154 | + model_provider="huggingface", |
| 155 | + temperature=0.7, |
| 156 | + max_tokens=1024, |
| 157 | + ) |
| 158 | + ``` |
159 | 159 |
|
160 | | - ```python Model Class |
161 | | - import os |
162 | | - from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint |
| 160 | + ```python Model Class |
| 161 | + import os |
| 162 | + from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint |
163 | 163 |
|
164 | | - os.environ["HUGGINGFACEHUB_API_TOKEN"] = "hf_..." |
| 164 | + os.environ["HUGGINGFACEHUB_API_TOKEN"] = "hf_..." |
165 | 165 |
|
166 | | - llm = HuggingFaceEndpoint( |
167 | | - repo_id="microsoft/Phi-3-mini-4k-instruct", |
168 | | - temperature=0.7, |
169 | | - max_length=1024, |
170 | | - ) |
171 | | - model = ChatHuggingFace(llm=llm) |
172 | | - ``` |
173 | | - </CodeGroup> |
174 | | -</Tab> |
| 166 | + llm = HuggingFaceEndpoint( |
| 167 | + repo_id="microsoft/Phi-3-mini-4k-instruct", |
| 168 | + temperature=0.7, |
| 169 | + max_length=1024, |
| 170 | + ) |
| 171 | + model = ChatHuggingFace(llm=llm) |
| 172 | + ``` |
| 173 | + </CodeGroup> |
175 | 174 | </Tab> |
176 | 175 | </Tabs> |
0 commit comments