Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,6 +19,21 @@ def my_custom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@tool
|
| 23 |
def convert_to_binary(number: int) -> str:
|
| 24 |
"""
|
|
@@ -54,9 +69,12 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 54 |
|
| 55 |
final_answer = FinalAnswerTool()
|
| 56 |
|
| 57 |
-
|
| 58 |
websearch=DuckDuckGoSearchTool()
|
| 59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 61 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 62 |
|
|
@@ -68,12 +86,10 @@ custom_role_conversions=None,
|
|
| 68 |
)
|
| 69 |
|
| 70 |
|
| 71 |
-
# Import tool from Hub
|
| 72 |
-
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 73 |
-
|
| 74 |
with open("prompts.yaml", 'r') as stream:
|
| 75 |
prompt_templates = yaml.safe_load(stream)
|
| 76 |
-
|
|
|
|
| 77 |
agent = CodeAgent(
|
| 78 |
model=model,
|
| 79 |
tools=[final_answer, convert_to_binary, get_current_time_in_timezone, image_generation_tool,websearch], ## add your tools here (don't remove final answer)
|
|
|
|
| 19 |
return "What magic will you build ?"
|
| 20 |
|
| 21 |
|
| 22 |
+
@tool
|
| 23 |
+
def word_counter(text: str, unique: bool) -> int:
|
| 24 |
+
"""Counts words in a given text.
|
| 25 |
+
|
| 26 |
+
Args:
|
| 27 |
+
text: The input text to analyze.
|
| 28 |
+
unique: If True, counts only unique words.
|
| 29 |
+
|
| 30 |
+
Returns:
|
| 31 |
+
The total word count or unique word count.
|
| 32 |
+
"""
|
| 33 |
+
words = text.split()
|
| 34 |
+
return len(set(words)) if unique else len(words)
|
| 35 |
+
|
| 36 |
+
|
| 37 |
@tool
|
| 38 |
def convert_to_binary(number: int) -> str:
|
| 39 |
"""
|
|
|
|
| 69 |
|
| 70 |
final_answer = FinalAnswerTool()
|
| 71 |
|
|
|
|
| 72 |
websearch=DuckDuckGoSearchTool()
|
| 73 |
|
| 74 |
+
# Import tool from Hub
|
| 75 |
+
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
# If the agent does not answer, the model is overloaded, please use another model or the following Hugging Face Endpoint that also contains qwen2.5 coder:
|
| 79 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
| 80 |
|
|
|
|
| 86 |
)
|
| 87 |
|
| 88 |
|
|
|
|
|
|
|
|
|
|
| 89 |
with open("prompts.yaml", 'r') as stream:
|
| 90 |
prompt_templates = yaml.safe_load(stream)
|
| 91 |
+
|
| 92 |
+
|
| 93 |
agent = CodeAgent(
|
| 94 |
model=model,
|
| 95 |
tools=[final_answer, convert_to_binary, get_current_time_in_timezone, image_generation_tool,websearch], ## add your tools here (don't remove final answer)
|