Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	Update new tool in app.py
Browse files
    	
        app.py
    CHANGED
    
    | @@ -9,15 +9,31 @@ from Gradio_UI import GradioUI | |
| 9 |  | 
| 10 | 
             
            # Below is an example of a tool that does nothing. Amaze us with your creativity !
         | 
| 11 | 
             
            @tool
         | 
| 12 | 
            -
            def my_custom_tool( | 
| 13 | 
             
                #Keep this format for the description / args / args description but feel free to modify the tool
         | 
| 14 | 
            -
                """A tool that  | 
| 15 | 
             
                Args:
         | 
| 16 | 
            -
                     | 
| 17 | 
            -
                    arg2: the second argument
         | 
| 18 | 
             
                """
         | 
|  | |
| 19 | 
             
                return "What magic will you build ?"
         | 
| 20 |  | 
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
|  | |
| 21 | 
             
            @tool
         | 
| 22 | 
             
            def get_current_time_in_timezone(timezone: str) -> str:
         | 
| 23 | 
             
                """A tool that fetches the current local time in a specified timezone.
         | 
| @@ -55,7 +71,7 @@ with open("prompts.yaml", 'r') as stream: | |
| 55 |  | 
| 56 | 
             
            agent = CodeAgent(
         | 
| 57 | 
             
                model=model,
         | 
| 58 | 
            -
                tools=[final_answer, get_current_time_in_timezone], ## add your tools here (don't remove final answer)
         | 
| 59 | 
             
                max_steps=6,
         | 
| 60 | 
             
                verbosity_level=1,
         | 
| 61 | 
             
                grammar=None,
         | 
|  | |
| 9 |  | 
| 10 | 
             
            # Below is an example of a tool that does nothing. Amaze us with your creativity !
         | 
| 11 | 
             
            @tool
         | 
| 12 | 
            +
            def my_custom_tool(timezone:str)-> str: #it's import to specify the return type
         | 
| 13 | 
             
                #Keep this format for the description / args / args description but feel free to modify the tool
         | 
| 14 | 
            +
                """A tool that gets the current weather in a specified timezone.
         | 
| 15 | 
             
                Args:
         | 
| 16 | 
            +
                    timezone: A string representing a valid timezone (e.g., 'America/New_York').
         | 
|  | |
| 17 | 
             
                """
         | 
| 18 | 
            +
                
         | 
| 19 | 
             
                return "What magic will you build ?"
         | 
| 20 |  | 
| 21 | 
            +
            @tool
         | 
| 22 | 
            +
            def calculate(operation:str, a:float, b:float) -> float:
         | 
| 23 | 
            +
                """A tool that performs basic calculations between two variables.
         | 
| 24 | 
            +
                Args:
         | 
| 25 | 
            +
                    operation: Four basic types of calculations: add, subtract, multiply, and divide
         | 
| 26 | 
            +
                    a: The first variable.
         | 
| 27 | 
            +
                    b: The second variable.
         | 
| 28 | 
            +
                """
         | 
| 29 | 
            +
                operations = {
         | 
| 30 | 
            +
                    "add": a + b,
         | 
| 31 | 
            +
                    "subtract": a - b,
         | 
| 32 | 
            +
                    "multiply": a * b,
         | 
| 33 | 
            +
                    "divide": a / b if b != 0 else "Error: Cannot divide by zero."
         | 
| 34 | 
            +
                }
         | 
| 35 | 
            +
                return operations.get(operation, f"Unknown operation: {operation}")
         | 
| 36 | 
            +
             | 
| 37 | 
             
            @tool
         | 
| 38 | 
             
            def get_current_time_in_timezone(timezone: str) -> str:
         | 
| 39 | 
             
                """A tool that fetches the current local time in a specified timezone.
         | 
|  | |
| 71 |  | 
| 72 | 
             
            agent = CodeAgent(
         | 
| 73 | 
             
                model=model,
         | 
| 74 | 
            +
                tools=[final_answer, get_current_time_in_timezone, calculate], ## add your tools here (don't remove final answer)
         | 
| 75 | 
             
                max_steps=6,
         | 
| 76 | 
             
                verbosity_level=1,
         | 
| 77 | 
             
                grammar=None,
         | 
 
			
