|
160 | 160 | "\n", |
161 | 161 | "We use the `CodeAgent`, which is `transformers.agents`' main agent class: an agent that writes actions in code and can iterate on previous output according to the ReAct framework.\n", |
162 | 162 | "\n", |
163 | | - "The `llm_engine` is the LLM that powers the agent system. `HfApiModel` allows you to call LLMs using Hugging Face's Inference API, either via Serverless or Dedicated endpoint, but you could also use any proprietary API: check out [this other cookbook](agent_change_llm) to learn how to adapt it." |
| 163 | + "The `llm_engine` is the LLM that powers the agent system. `InferenceClientModel` allows you to call LLMs using Hugging Face's Inference API, either via Serverless or Dedicated endpoint, but you could also use any proprietary API: check out [this other cookbook](agent_change_llm) to learn how to adapt it." |
164 | 164 | ] |
165 | 165 | }, |
166 | 166 | { |
|
169 | 169 | "metadata": {}, |
170 | 170 | "outputs": [], |
171 | 171 | "source": [ |
172 | | - "from smolagents import CodeAgent, HfApiModel\n", |
| 172 | + "from smolagents import CodeAgent, InferenceClientModel\n", |
173 | 173 | "\n", |
174 | 174 | "agent = CodeAgent(\n", |
175 | 175 | " tools=[sql_engine],\n", |
176 | | - " model=HfApiModel(\"meta-llama/Meta-Llama-3-8B-Instruct\"),\n", |
| 176 | + " model=InferenceClientModel(\"meta-llama/Meta-Llama-3-8B-Instruct\"),\n", |
177 | 177 | ")" |
178 | 178 | ] |
179 | 179 | }, |
|
189 | 189 | "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n", |
190 | 190 | "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">Can you give me the name of the client who got the most expensive receipt?</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n", |
191 | 191 | "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n", |
192 | | - "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ HfApiModel - meta-llama/Meta-Llama-3-8B-Instruct ──────────────────────────────────────────────────────────────╯</span>\n", |
| 192 | + "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ InferenceClientModel - meta-llama/Meta-Llama-3-8B-Instruct ──────────────────────────────────────────────────────────────╯</span>\n", |
193 | 193 | "</pre>\n" |
194 | 194 | ], |
195 | 195 | "text/plain": [ |
196 | 196 | "\u001b[38;2;212;183;2m╭─\u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[1;38;2;212;183;2mNew run\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╮\u001b[0m\n", |
197 | 197 | "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n", |
198 | 198 | "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mCan you give me the name of the client who got the most expensive receipt?\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n", |
199 | 199 | "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n", |
200 | | - "\u001b[38;2;212;183;2m╰─\u001b[0m\u001b[38;2;212;183;2m HfApiModel - meta-llama/Meta-Llama-3-8B-Instruct \u001b[0m\u001b[38;2;212;183;2m─────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n" |
| 200 | + "\u001b[38;2;212;183;2m╰─\u001b[0m\u001b[38;2;212;183;2m InferenceClientModel - meta-llama/Meta-Llama-3-8B-Instruct \u001b[0m\u001b[38;2;212;183;2m─────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n" |
201 | 201 | ] |
202 | 202 | }, |
203 | 203 | "metadata": {}, |
|
396 | 396 | "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n", |
397 | 397 | "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"font-weight: bold\">Which waiter got more total money from tips?</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n", |
398 | 398 | "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span> <span style=\"color: #d4b702; text-decoration-color: #d4b702\">│</span>\n", |
399 | | - "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ HfApiModel - Qwen/Qwen2.5-72B-Instruct ────────────────────────────────────────────────────────────────────────╯</span>\n", |
| 399 | + "<span style=\"color: #d4b702; text-decoration-color: #d4b702\">╰─ InferenceClientModel - Qwen/Qwen2.5-72B-Instruct ────────────────────────────────────────────────────────────────────────╯</span>\n", |
400 | 400 | "</pre>\n" |
401 | 401 | ], |
402 | 402 | "text/plain": [ |
403 | 403 | "\u001b[38;2;212;183;2m╭─\u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[1;38;2;212;183;2mNew run\u001b[0m\u001b[38;2;212;183;2m \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╮\u001b[0m\n", |
404 | 404 | "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n", |
405 | 405 | "\u001b[38;2;212;183;2m│\u001b[0m \u001b[1mWhich waiter got more total money from tips?\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n", |
406 | 406 | "\u001b[38;2;212;183;2m│\u001b[0m \u001b[38;2;212;183;2m│\u001b[0m\n", |
407 | | - "\u001b[38;2;212;183;2m╰─\u001b[0m\u001b[38;2;212;183;2m HfApiModel - Qwen/Qwen2.5-72B-Instruct \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n" |
| 407 | + "\u001b[38;2;212;183;2m╰─\u001b[0m\u001b[38;2;212;183;2m InferenceClientModel - Qwen/Qwen2.5-72B-Instruct \u001b[0m\u001b[38;2;212;183;2m───────────────────────────────────────────────────────────────────────\u001b[0m\u001b[38;2;212;183;2m─╯\u001b[0m\n" |
408 | 408 | ] |
409 | 409 | }, |
410 | 410 | "metadata": {}, |
|
740 | 740 | "\n", |
741 | 741 | "agent = CodeAgent(\n", |
742 | 742 | " tools=[sql_engine],\n", |
743 | | - " model=HfApiModel(\"Qwen/Qwen2.5-72B-Instruct\"),\n", |
| 743 | + " model=InferenceClientModel(\"Qwen/Qwen2.5-72B-Instruct\"),\n", |
744 | 744 | ")\n", |
745 | 745 | "\n", |
746 | 746 | "agent.run(\"Which waiter got more total money from tips?\")" |
|
0 commit comments