fix: update template to use InferenceClientModel instead of deprecated HfApiModel
Browse files### Description
This PR updates the `app.py` starter template to use the modern `InferenceClientModel` class instead of the legacy `HfApiModel` class.
### Motivation
As outlined in the core `smolagents` documentation and recent course text materials, `HfApiModel` has been deprecated and phased out in newer releases of the framework. Keeping `HfApiModel` in the base template causes breaking `ImportError` or deprecation runtime warnings for students trying to run their first agents locally or on newer environments.
Aligning this template with the actual course reading material will drastically reduce friction for beginners joining the course!
### Changes
* Swapped `HfApiModel` import to `InferenceClientModel` from `smolagents`.
* Updated the `model` instantiation block to use `InferenceClientModel`.
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
from smolagents import CodeAgent,DuckDuckGoSearchTool,
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
@@ -39,7 +39,7 @@ final_answer = FinalAnswerTool()
|
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 41 |
|
| 42 |
-
model =
|
| 43 |
max_tokens=2096,
|
| 44 |
temperature=0.5,
|
| 45 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|
|
|
|
| 1 |
+
from smolagents import CodeAgent,DuckDuckGoSearchTool,InferenceClientModel,load_tool,tool
|
| 2 |
import datetime
|
| 3 |
import requests
|
| 4 |
import pytz
|
|
|
|
| 39 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 40 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 41 |
|
| 42 |
+
model = InferenceClientModel(
|
| 43 |
max_tokens=2096,
|
| 44 |
temperature=0.5,
|
| 45 |
model_id='Qwen/Qwen2.5-Coder-32B-Instruct',# it is possible that this model may be overloaded
|