Spaces:
Sleeping
Sleeping
Download each agent skill as a separate ZIP
Browse files
app.py
CHANGED
|
@@ -30,20 +30,19 @@ structured_json_templates = {
|
|
| 30 |
default_structured_json_template = "Invoice with line items"
|
| 31 |
|
| 32 |
|
| 33 |
-
def download_agentskill(
|
| 34 |
-
|
| 35 |
-
"
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
):
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
return "extract-image-data.zip"
|
| 47 |
|
| 48 |
with gr.Blocks(title="Image Data Extractor") as demo:
|
| 49 |
gr.Markdown(
|
|
@@ -88,15 +87,18 @@ with gr.Blocks(title="Image Data Extractor") as demo:
|
|
| 88 |
"Download the ZIP, extract it, and place its skill folders in your "
|
| 89 |
"project's `.agents/skills/` directory. Agents should read the "
|
| 90 |
"`SKILL.md` and use it whenever a task requires structured extraction "
|
| 91 |
-
"from an image. Keep **Include
|
| 92 |
-
"
|
| 93 |
)
|
| 94 |
-
|
| 95 |
-
label="Include
|
| 96 |
value=True,
|
| 97 |
)
|
| 98 |
download_agentskill_button = gr.Button("Download agent skill")
|
| 99 |
-
download_agentskill_file = gr.File(
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
gr.Examples(
|
| 102 |
examples=[
|
|
@@ -127,7 +129,7 @@ with gr.Blocks(title="Image Data Extractor") as demo:
|
|
| 127 |
|
| 128 |
download_agentskill_button.click(
|
| 129 |
download_agentskill,
|
| 130 |
-
inputs=
|
| 131 |
outputs=download_agentskill_file,
|
| 132 |
api_name="download_agentskill",
|
| 133 |
)
|
|
|
|
| 30 |
default_structured_json_template = "Invoice with line items"
|
| 31 |
|
| 32 |
|
| 33 |
+
def download_agentskill(include_all_skills):
|
| 34 |
+
skill_folders = (
|
| 35 |
+
sorted(path for path in Path(".agents/skills").iterdir() if path.is_dir())
|
| 36 |
+
if include_all_skills
|
| 37 |
+
else [Path(".agents/skills/extract-image-data")]
|
| 38 |
+
)
|
| 39 |
+
for skill_folder in skill_folders:
|
| 40 |
+
with zipfile.ZipFile(
|
| 41 |
+
f"{skill_folder.name}.zip", "w", compression=zipfile.ZIP_DEFLATED
|
| 42 |
+
) as archive:
|
| 43 |
+
for path in skill_folder.rglob("*"):
|
| 44 |
+
archive.write(path, path.relative_to(".agents/skills"))
|
| 45 |
+
return [f"{skill_folder.name}.zip" for skill_folder in skill_folders]
|
|
|
|
| 46 |
|
| 47 |
with gr.Blocks(title="Image Data Extractor") as demo:
|
| 48 |
gr.Markdown(
|
|
|
|
| 87 |
"Download the ZIP, extract it, and place its skill folders in your "
|
| 88 |
"project's `.agents/skills/` directory. Agents should read the "
|
| 89 |
"`SKILL.md` and use it whenever a task requires structured extraction "
|
| 90 |
+
"from an image. Keep **Include All Skills** checked to download every "
|
| 91 |
+
"skill as its own ZIP file."
|
| 92 |
)
|
| 93 |
+
include_all_skills = gr.Checkbox(
|
| 94 |
+
label="Include All Skills",
|
| 95 |
value=True,
|
| 96 |
)
|
| 97 |
download_agentskill_button = gr.Button("Download agent skill")
|
| 98 |
+
download_agentskill_file = gr.File(
|
| 99 |
+
label="Agent skill ZIPs",
|
| 100 |
+
file_count="multiple",
|
| 101 |
+
)
|
| 102 |
|
| 103 |
gr.Examples(
|
| 104 |
examples=[
|
|
|
|
| 129 |
|
| 130 |
download_agentskill_button.click(
|
| 131 |
download_agentskill,
|
| 132 |
+
inputs=include_all_skills,
|
| 133 |
outputs=download_agentskill_file,
|
| 134 |
api_name="download_agentskill",
|
| 135 |
)
|