Fix installation with data files (#536)
This commit is contained in:
parent
932298696c
commit
127a042cfb
|
@ -99,6 +99,9 @@ lint.select = ["E", "F", "I", "W"]
|
||||||
known-first-party = ["smolagents"]
|
known-first-party = ["smolagents"]
|
||||||
lines-after-imports = 2
|
lines-after-imports = 2
|
||||||
|
|
||||||
|
[tool.setuptools.package-data]
|
||||||
|
"smolagents.prompts" = ["*.yaml"]
|
||||||
|
|
||||||
[project.scripts]
|
[project.scripts]
|
||||||
smolagent = "smolagents.cli:main"
|
smolagent = "smolagents.cli:main"
|
||||||
webagent = "smolagents.vision_web_browser:main"
|
webagent = "smolagents.vision_web_browser:main"
|
|
@ -25,7 +25,6 @@ from .local_python_executor import *
|
||||||
from .memory import *
|
from .memory import *
|
||||||
from .models import *
|
from .models import *
|
||||||
from .monitoring import *
|
from .monitoring import *
|
||||||
from .prompts import *
|
|
||||||
from .tools import *
|
from .tools import *
|
||||||
from .utils import *
|
from .utils import *
|
||||||
from .cli import *
|
from .cli import *
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
import importlib.resources
|
||||||
import inspect
|
import inspect
|
||||||
import os
|
|
||||||
import re
|
import re
|
||||||
import textwrap
|
import textwrap
|
||||||
import time
|
import time
|
||||||
|
@ -646,9 +646,9 @@ class ToolCallingAgent(MultiStepAgent):
|
||||||
planning_interval: Optional[int] = None,
|
planning_interval: Optional[int] = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
yaml_path = os.path.join(os.path.dirname(__file__), "prompts", "toolcalling_agent.yaml")
|
self.prompt_templates = yaml.safe_load(
|
||||||
with open(yaml_path, "r") as f:
|
importlib.resources.read_text("smolagents.prompts", "toolcalling_agent.yaml")
|
||||||
self.prompt_templates = yaml.safe_load(f)
|
)
|
||||||
super().__init__(
|
super().__init__(
|
||||||
tools=tools,
|
tools=tools,
|
||||||
model=model,
|
model=model,
|
||||||
|
@ -779,9 +779,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))
|
||||||
yaml_path = os.path.join(os.path.dirname(__file__), "prompts", "code_agent.yaml")
|
self.prompt_templates = yaml.safe_load(importlib.resources.read_text("smolagents.prompts", "code_agent.yaml"))
|
||||||
with open(yaml_path, "r") as f:
|
|
||||||
self.prompt_templates = yaml.safe_load(f)
|
|
||||||
super().__init__(
|
super().__init__(
|
||||||
tools=tools,
|
tools=tools,
|
||||||
model=model,
|
model=model,
|
||||||
|
|
|
@ -4,7 +4,7 @@ import subprocess
|
||||||
def test_import_smolagents_without_extras():
|
def test_import_smolagents_without_extras():
|
||||||
# Run the import statement in an isolated virtual environment
|
# Run the import statement in an isolated virtual environment
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
["uv", "run", "--isolated", "-"], input="import smolagents", text=True, capture_output=True
|
["uv", "run", "--isolated", "--no-editable", "-"], input="import smolagents", text=True, capture_output=True
|
||||||
)
|
)
|
||||||
# Check if the import was successful
|
# Check if the import was successful
|
||||||
assert result.returncode == 0, (
|
assert result.returncode == 0, (
|
||||||
|
|
Loading…
Reference in New Issue