electblake commited on
Commit
1d02976
·
verified ·
1 Parent(s): b721d3c

Download each agent skill as a separate ZIP

Browse files
Files changed (1) hide show
  1. app.py +22 -20
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(include_gradio_skills):
34
- with zipfile.ZipFile(
35
- "extract-image-data.zip", "w", compression=zipfile.ZIP_DEFLATED
36
- ) as archive:
37
- for path in Path(".agents/skills/extract-image-data").rglob("*"):
38
- archive.write(path, path.relative_to(".agents/skills"))
39
- if include_gradio_skills:
40
- for skill_folder in (
41
- Path(".agents/skills/gradio"),
42
- Path(".agents/skills/hf-gradio"),
43
- ):
44
- for path in skill_folder.rglob("*"):
45
- archive.write(path, path.relative_to(".agents/skills"))
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 Gradio Skills** checked to include the "
92
- "supporting `gradio` and `hf-gradio` skills."
93
  )
94
- include_gradio_skills = gr.Checkbox(
95
- label="Include Gradio Skills",
96
  value=True,
97
  )
98
  download_agentskill_button = gr.Button("Download agent skill")
99
- download_agentskill_file = gr.File(label="Agent skill ZIP")
 
 
 
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=include_gradio_skills,
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
  )