Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,6 +33,37 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
final_answer = FinalAnswerTool()
|
| 38 |
model = HfApiModel(
|
|
@@ -51,7 +82,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 51 |
|
| 52 |
agent = CodeAgent(
|
| 53 |
model=model,
|
| 54 |
-
tools=[image_search_tool, image_generation_tool, final_answer], # add your tools here (don't remove final_answer)
|
| 55 |
max_steps=6,
|
| 56 |
verbosity_level=1,
|
| 57 |
grammar=None,
|
|
|
|
| 33 |
except Exception as e:
|
| 34 |
return f"Error fetching time for timezone '{timezone}': {str(e)}"
|
| 35 |
|
| 36 |
+
@tool
|
| 37 |
+
def multiply_numbers(num1: int, num2: int) -> intt:
|
| 38 |
+
"""
|
| 39 |
+
Multiplies two integers and returns the result.
|
| 40 |
+
|
| 41 |
+
This function takes two integers `a` and `b`, multiplies them, and returns
|
| 42 |
+
the product. It is designed to be used as a LangChain tool that can be
|
| 43 |
+
called by agents or workflows in the LangChain ecosystem.
|
| 44 |
+
|
| 45 |
+
Parameters:
|
| 46 |
+
----------
|
| 47 |
+
a : int
|
| 48 |
+
The first integer to be multiplied.
|
| 49 |
+
b : int
|
| 50 |
+
The second integer to be multiplied.
|
| 51 |
+
|
| 52 |
+
Returns:
|
| 53 |
+
-------
|
| 54 |
+
int
|
| 55 |
+
The product of `a` and `b`.
|
| 56 |
+
|
| 57 |
+
Example:
|
| 58 |
+
-------
|
| 59 |
+
>>> multiply(3, 4)
|
| 60 |
+
12
|
| 61 |
+
"""
|
| 62 |
+
try:
|
| 63 |
+
result = num1 * num2
|
| 64 |
+
return result
|
| 65 |
+
except Exception as e:
|
| 66 |
+
raise ValueError(f"An error occurred during multiplication: {e}")
|
| 67 |
|
| 68 |
final_answer = FinalAnswerTool()
|
| 69 |
model = HfApiModel(
|
|
|
|
| 82 |
|
| 83 |
agent = CodeAgent(
|
| 84 |
model=model,
|
| 85 |
+
tools=[image_search_tool, image_generation_tool, multiply_numbers, final_answer], # add your tools here (don't remove final_answer)
|
| 86 |
max_steps=6,
|
| 87 |
verbosity_level=1,
|
| 88 |
grammar=None,
|