Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,13 +52,26 @@ 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 |
@tool
|
| 55 |
-
def image_open() -> None:
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
img.show()
|
| 61 |
|
|
|
|
|
|
|
|
|
|
| 62 |
with open("prompts.yaml", 'r') as stream:
|
| 63 |
prompt_templates = yaml.safe_load(stream)
|
| 64 |
|
|
|
|
| 52 |
# Import tool from Hub
|
| 53 |
image_generation_tool = load_tool("agents-course/text-to-image", trust_remote_code=True)
|
| 54 |
@tool
|
| 55 |
+
def image_open(prompt: str) -> None:
|
| 56 |
+
"""Prompta göre görüntü üretir ve resmi açar."""
|
| 57 |
+
# Resmi üret
|
| 58 |
+
result = image_generation_tool(prompt=prompt)
|
| 59 |
+
|
| 60 |
+
# Base64 string al
|
| 61 |
+
img_base64 = result["images"][0]
|
| 62 |
+
|
| 63 |
+
# Base64 → byte
|
| 64 |
+
img_bytes = base64.b64decode(img_base64)
|
| 65 |
+
|
| 66 |
+
# Byte → PIL Image
|
| 67 |
+
img = Image.open(BytesIO(img_bytes))
|
| 68 |
+
|
| 69 |
+
# resmi aç
|
| 70 |
img.show()
|
| 71 |
|
| 72 |
+
return None
|
| 73 |
+
|
| 74 |
+
|
| 75 |
with open("prompts.yaml", 'r') as stream:
|
| 76 |
prompt_templates = yaml.safe_load(stream)
|
| 77 |
|