Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -37,6 +37,7 @@ def get_current_time_in_timezone(timezone: str) -> str:
|
|
| 37 |
|
| 38 |
|
| 39 |
final_answer = FinalAnswerTool()
|
|
|
|
| 40 |
|
| 41 |
# 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:
|
| 42 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
@@ -52,30 +53,7 @@ custom_role_conversions=None,
|
|
| 52 |
# Import tool from Hub
|
| 53 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 54 |
|
| 55 |
-
@tool
|
| 56 |
-
def image_open(prompt: str) -> None:
|
| 57 |
-
"""Prompta göre görüntü üretir ve resmi açar.
|
| 58 |
-
|
| 59 |
-
Args:
|
| 60 |
-
prompt:Bir prompt alır(örnek:a cat image)
|
| 61 |
-
|
| 62 |
-
"""
|
| 63 |
-
|
| 64 |
-
# Tool’u çağır → zaten bir PIL Image döndürüyor
|
| 65 |
-
img = image_generation_tool(prompt=prompt)
|
| 66 |
-
|
| 67 |
-
# Eğer tool bir dict gibi dönerse ona göre ele alalım
|
| 68 |
-
if isinstance(img, dict) and "images" in img:
|
| 69 |
-
img = img["images"][0] # ama büyük ihtimalle buna gerek kalmaz
|
| 70 |
-
|
| 71 |
-
# Eğer img gerçekten bir PIL.Image ise:
|
| 72 |
-
if hasattr(img, "show"):
|
| 73 |
-
img.show()
|
| 74 |
-
return None
|
| 75 |
|
| 76 |
-
# Eğer hâlâ değilse güvenli bir hata mesajı
|
| 77 |
-
print("image_generation_tool beklenmeyen bir format döndürdü:", type(img))
|
| 78 |
-
return None
|
| 79 |
|
| 80 |
|
| 81 |
with open("prompts.yaml", 'r') as stream:
|
|
@@ -83,7 +61,7 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 83 |
|
| 84 |
agent = CodeAgent(
|
| 85 |
model=model,
|
| 86 |
-
tools=[final_answer,image_generation_tool,get_current_time_in_timezone,
|
| 87 |
max_steps=6,
|
| 88 |
verbosity_level=1,
|
| 89 |
grammar=None,
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
final_answer = FinalAnswerTool()
|
| 40 |
+
do_search=DuckDuckGoSearchTool()
|
| 41 |
|
| 42 |
# 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:
|
| 43 |
# model_id='https://pflgm2locj2t89co.us-east-1.aws.endpoints.huggingface.cloud'
|
|
|
|
| 53 |
# Import tool from Hub
|
| 54 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
|
| 59 |
with open("prompts.yaml", 'r') as stream:
|
|
|
|
| 61 |
|
| 62 |
agent = CodeAgent(
|
| 63 |
model=model,
|
| 64 |
+
tools=[final_answer,image_generation_tool,get_current_time_in_timezone,do_search, ## add your tools here (don't remove final answer)
|
| 65 |
max_steps=6,
|
| 66 |
verbosity_level=1,
|
| 67 |
grammar=None,
|