Fix deprecation warning from importlib.resources.read_text (#543)

This commit is contained in:
Albert Villanova del Moral 2025-02-07 15:38:15 +01:00 committed by GitHub
parent ecabb9ea4f
commit ff73f5326e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 2 deletions

View File

@ -648,7 +648,7 @@ class ToolCallingAgent(MultiStepAgent):
**kwargs, **kwargs,
): ):
prompt_templates = prompt_templates or yaml.safe_load( prompt_templates = prompt_templates or yaml.safe_load(
importlib.resources.read_text("smolagents.prompts", "toolcalling_agent.yaml") importlib.resources.files("smolagents.prompts").joinpath("toolcalling_agent.yaml").read_text()
) )
super().__init__( super().__init__(
tools=tools, tools=tools,
@ -781,7 +781,7 @@ class CodeAgent(MultiStepAgent):
self.additional_authorized_imports = additional_authorized_imports if additional_authorized_imports else [] self.additional_authorized_imports = additional_authorized_imports if additional_authorized_imports else []
self.authorized_imports = list(set(BASE_BUILTIN_MODULES) | set(self.additional_authorized_imports)) self.authorized_imports = list(set(BASE_BUILTIN_MODULES) | set(self.additional_authorized_imports))
prompt_templates = prompt_templates or yaml.safe_load( prompt_templates = prompt_templates or yaml.safe_load(
importlib.resources.read_text("smolagents.prompts", "code_agent.yaml") importlib.resources.files("smolagents.prompts").joinpath("code_agent.yaml").read_text()
) )
super().__init__( super().__init__(
tools=tools, tools=tools,