Spaces:
Runtime error
Runtime error
Commit
·
80f27e2
1
Parent(s):
8cc9c71
task: refine designer prompt
Browse files- analyze_designs.py +8 -10
analyze_designs.py
CHANGED
@@ -59,8 +59,9 @@ async def analyze_screenshot(design_id: str, design_path: Path):
|
|
59 |
"categories": ["category1", "category2"],
|
60 |
"visual_characteristics": ["characteristic1", "characteristic2"]
|
61 |
}
|
62 |
-
|
63 |
Categories should only refer to categories of design styling.
|
|
|
64 |
"""
|
65 |
},
|
66 |
{
|
@@ -89,19 +90,11 @@ async def analyze_screenshot(design_id: str, design_path: Path):
|
|
89 |
],
|
90 |
max_tokens=1000
|
91 |
)
|
92 |
-
|
93 |
-
# Print the response content for debugging
|
94 |
-
response_content = response.choices[0].message.content.strip()
|
95 |
-
|
96 |
# Ensure the response is not empty
|
97 |
if not response_content:
|
98 |
print(f"Empty response for design {design_id}")
|
99 |
return design_id, None, None
|
100 |
|
101 |
-
# Log the type and length of the response content
|
102 |
-
print(f"Type of response content: {type(response_content)}")
|
103 |
-
print(f"Length of response content: {len(response_content)}")
|
104 |
-
|
105 |
# Extract JSON content from markdown code block
|
106 |
if "```json" in response_content:
|
107 |
# Remove the ```json prefix and ``` suffix
|
@@ -111,7 +104,9 @@ async def analyze_screenshot(design_id: str, design_path: Path):
|
|
111 |
try:
|
112 |
print(f"Cleaned response for design {design_id}: {response_content}")
|
113 |
analysis = json.loads(response_content)
|
114 |
-
print("
|
|
|
|
|
115 |
|
116 |
# Update metadata with all fields
|
117 |
metadata.update(analysis)
|
@@ -147,6 +142,9 @@ async def main():
|
|
147 |
|
148 |
print(f"Found {len(design_dirs)} designs to analyze")
|
149 |
|
|
|
|
|
|
|
150 |
# Analyze all designs
|
151 |
tasks = []
|
152 |
for design_dir in design_dirs:
|
|
|
59 |
"categories": ["category1", "category2"],
|
60 |
"visual_characteristics": ["characteristic1", "characteristic2"]
|
61 |
}
|
62 |
+
Provide 4-6 categories and 4-6 visual characteristics.
|
63 |
Categories should only refer to categories of design styling.
|
64 |
+
This data will be consumed by another LLM, so provide enough categories and visual characteristics to explain the design.
|
65 |
"""
|
66 |
},
|
67 |
{
|
|
|
90 |
],
|
91 |
max_tokens=1000
|
92 |
)
|
|
|
|
|
|
|
|
|
93 |
# Ensure the response is not empty
|
94 |
if not response_content:
|
95 |
print(f"Empty response for design {design_id}")
|
96 |
return design_id, None, None
|
97 |
|
|
|
|
|
|
|
|
|
98 |
# Extract JSON content from markdown code block
|
99 |
if "```json" in response_content:
|
100 |
# Remove the ```json prefix and ``` suffix
|
|
|
104 |
try:
|
105 |
print(f"Cleaned response for design {design_id}: {response_content}")
|
106 |
analysis = json.loads(response_content)
|
107 |
+
print(f"Description: {analysis['description']}")
|
108 |
+
print(f"Categories: {analysis['categories']}")
|
109 |
+
print(f"Visual Characteristics: {analysis['visual_characteristics']}")
|
110 |
|
111 |
# Update metadata with all fields
|
112 |
metadata.update(analysis)
|
|
|
142 |
|
143 |
print(f"Found {len(design_dirs)} designs to analyze")
|
144 |
|
145 |
+
# Create list of design IDs to analyze (001-050)
|
146 |
+
design_ids = [f"{i:03d}" for i in range(1, 51)]
|
147 |
+
|
148 |
# Analyze all designs
|
149 |
tasks = []
|
150 |
for design_dir in design_dirs:
|