Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
aymeric-roucher committed Sep 11, 2024
1 parent 2447e7e commit 98f5463
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/transformers/agents/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from .. import is_torch_available
from ..utils import logging as transformers_logging
from ..utils.import_utils import is_pygments_available
from .agent_types import AgentAudio, AgentImage, AgentText
from .agent_types import AgentAudio, AgentImage
from .default_tools import BASE_PYTHON_TOOLS, FinalAnswerTool, setup_default_tools
from .llm_engine import HfApiEngine, MessageRole
from .prompts import (
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/agents/default_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from ..utils import is_offline_mode
from .python_interpreter import LIST_SAFE_MODULES, evaluate_python_code
from .tools import TOOL_CONFIG_FILE, TOOL_MAPPING, Tool, tool
from .tools import TOOL_CONFIG_FILE, TOOL_MAPPING, Tool


def custom_print(*args):
Expand Down
2 changes: 1 addition & 1 deletion src/transformers/agents/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def download_prompt(prompt_or_repo_id, agent_name, mode="run"):
Action:
{
"action": "image_generator",
"action_input": {"prompt": ""A portrait of John Doe, a 55-year-old man living in Canada.""}
"action_input": {"prompt": "A portrait of John Doe, a 55-year-old man living in Canada."}
}<end_action>
Observation: "image.png"
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/agents/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import requests
from requests.exceptions import RequestException

from .tools import Tool, tool
from .tools import Tool


class DuckDuckGoSearchTool(Tool):
Expand Down Expand Up @@ -50,7 +50,7 @@ class VisitWebpageTool(Tool):
}
}
output_type = "string"

def forward(self, url: str) -> str:
try:
from markdownify import markdownify
Expand Down
3 changes: 2 additions & 1 deletion src/transformers/utils/chat_template_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from packaging import version

from .import_utils import is_jinja_available, is_vision_available, is_torch_available
from .import_utils import is_jinja_available, is_torch_available, is_vision_available


if is_jinja_available():
Expand Down Expand Up @@ -69,6 +69,7 @@ class DocstringParsingException(Exception):

pass


def _get_json_schema_type(param_type: str) -> Dict[str, str]:
type_mapping = {
int: {"type": "integer"},
Expand Down
3 changes: 2 additions & 1 deletion tests/agents/test_final_answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@
import numpy as np
from PIL import Image

from transformers import is_torch_available, load_tool
from transformers import is_torch_available
from transformers.agents.agent_types import AGENT_TYPE_MAPPING
from transformers.agents.default_tools import FinalAnswerTool
from transformers.testing_utils import get_tests_dir, require_torch


if is_torch_available():
import torch

Expand Down
6 changes: 3 additions & 3 deletions tests/agents/test_python_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def test_if_conditions(self):
if char.isalpha():
print('2')"""
state = {}
result = evaluate_python_code(code, BASE_PYTHON_TOOLS, state=state)
evaluate_python_code(code, BASE_PYTHON_TOOLS, state=state)
assert state["print_outputs"] == "2\n"

def test_imports(self):
Expand Down Expand Up @@ -470,7 +470,7 @@ def test_print_output(self):
code = "print('Hello world!')\nprint('Ok no one cares')"
state = {}
result = evaluate_python_code(code, BASE_PYTHON_TOOLS, state=state)
assert result == None
assert result is None
assert state["print_outputs"] == "Hello world!\nOk no one cares\n"

# test print in function
Expand Down Expand Up @@ -594,7 +594,7 @@ def method_that_raises(self):
def test_print(self):
code = "print(min([1, 2, 3]))"
state = {}
result = evaluate_python_code(code, {"min": min, "print": print}, state=state)
evaluate_python_code(code, {"min": min, "print": print}, state=state)
assert state["print_outputs"] == "1\n"

def test_types_as_objects(self):
Expand Down
2 changes: 1 addition & 1 deletion tests/agents/test_tools_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from PIL import Image


AUTHORIZED_TYPES = ["string", "number", "audio", "image", "any"]
AUTHORIZED_TYPES = ["string", "boolean", "integer", "number", "audio", "image", "any"]


def create_inputs(tool_inputs: Dict[str, Dict[Union[str, type], str]]):
Expand Down

0 comments on commit 98f5463

Please sign in to comment.