


import unittest

from transformers import load_tool
from transformers.tools.agent_types import AGENT_TYPE_MAPPING

from .test_tools_common import ToolTesterMixin, output_types






class    UpperCamelCase    (						unittest.TestCase  ,					UpperCamelCase__   ):


   '''simple docstring'''







   def 						UpperCamelCase     (   self						):
        lowercase_				:List[Any]       			=				load_tool('''translation'''						)
        self.tool.setup()
        lowercase_				:Any       			=				load_tool('''translation'''      ,							remote=__A						)
   def 						UpperCamelCase     (   self						):
        lowercase_				:int       			=				self.tool('''Hey, what\'s up?'''      ,							src_lang='''English'''      ,							tgt_lang='''French'''						)
        self.assertEqual(__A      ,							'''- Hé, comment ça va?'''						)
   def 						UpperCamelCase     (   self						):
        lowercase_				:Union[str, Any]       			=				self.remote_tool('''Hey, what\'s up?'''      ,							src_lang='''English'''      ,							tgt_lang='''French'''						)
        self.assertEqual(__A      ,							'''- Hé, comment ça va?'''						)
   def 						UpperCamelCase     (   self						):
        lowercase_				:Union[str, Any]       			=				self.tool(text='''Hey, what\'s up?'''      ,							src_lang='''English'''      ,							tgt_lang='''French'''						)
        self.assertEqual(__A      ,							'''- Hé, comment ça va?'''						)
   def 						UpperCamelCase     (   self						):
        lowercase_				:Dict       			=				self.remote_tool(text='''Hey, what\'s up?'''      ,							src_lang='''English'''      ,							tgt_lang='''French'''						)
        self.assertEqual(__A      ,							'''- Hé, comment ça va?'''						)
   def 						UpperCamelCase     (   self						):
        lowercase_				:Optional[int]       			=				['''Hey, what\'s up?''', '''English''', '''Spanish''']
        lowercase_				:List[Any]       			=				self.tool(*__A						)

        # There is a single output
        if len(self.tool.outputs						) == 1:
             lowercase_				:List[str]       			=				[outputs]

        self.assertListEqual(output_types(__A						)      ,							self.tool.outputs						)
   def 						UpperCamelCase     (   self						):
        lowercase_				:Optional[Any]       			=				['''Hey, what\'s up?''', '''English''', '''Spanish''']
        lowercase_				:Any       			=				self.tool(*__A						)

        if not isinstance(__A      ,							__A						):
             lowercase_				:int       			=				[outputs]

        self.assertEqual(len(__A						)      ,							len(self.tool.outputs						)						)

        for output, output_type in zip(__A      ,							self.tool.outputs						):
             lowercase_				:Union[str, Any]       			=				AGENT_TYPE_MAPPING[output_type]
             self.assertTrue(isinstance(__A      ,							__A						)						)




   def 						UpperCamelCase     (   self						):
        lowercase_				:List[str]       			=				['''Hey, what\'s up?''', '''English''', '''Spanish''']

        lowercase_				:str       			=				[]

        for _input, input_type in zip(__A      ,							self.tool.inputs						):
             if isinstance(__A      ,							__A						):
                  _inputs.append([AGENT_TYPE_MAPPING[_input_type](_input						) for _input_type in input_type]						)
             else:
                  _inputs.append(AGENT_TYPE_MAPPING[input_type](_input						)						)

        # Should not raise an error
        lowercase_				:List[str]       			=				self.tool(*__A						)

        if not isinstance(__A      ,							__A						):
             lowercase_				:Dict       			=				[outputs]

        self.assertEqual(len(__A						)      ,							len(self.tool.outputs						)						)








import unittest

from transformers import is_torch_available, load_tool

from .test_tools_common import ToolTesterMixin


if is_torch_available():
	import torch




class      UpperCamelCase_				(   unittest.TestCase ,     UpperCamelCase__			):


							def    _snake_case     (							self			:Dict						)      ->      Union[str, Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					load_tool("""speech-to-text"""						)
									self.tool.setup()


							def    _snake_case     (							self			:str						)      ->      Union[str, Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.tool(torch.ones(3000						)						)
									self.assertEqual(__A							, """ you"""						)


							def    _snake_case     (							self			:Union[str, Any]						)      ->      Union[str, Any]:



									"""simple docstring"""



									SCREAMING_SNAKE_CASE__								=					self.tool(audio=torch.ones(3000						)						)
									self.assertEqual(__A							, """ you"""						)