Spaces:
Sleeping
Sleeping
Download src/storage/quotation_template.py from gouriikarus3d/Catalog-AI: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/spaces/gouriikarus3d/Catalog-AI/resolve/main/src/storage/quotation_template.py
- Command line
-
hf download hf://spaces/gouriikarus3d/Catalog-AI/src/storage/quotation_template.py
-
curl -L -o quotation_template.py https://huggingface.co/spaces/gouriikarus3d/Catalog-AI/resolve/main/src/storage/quotation_template.py
1.21 kB
| import json | |
| from typing import Dict | |
| class QuotationTemplate: | |
| """Generate quotation template JSON.""" | |
| def to_json_string(catalog: Dict) -> str: | |
| template = { | |
| "instructions": "Select options to generate quotations", | |
| "products": {} | |
| } | |
| for product_id, product in catalog.items(): | |
| template["products"][product_id] = { | |
| "product_name": product["product_name"], | |
| "base_price": product.get("base_price"), | |
| "url": product["url"], | |
| "customizations": {} | |
| } | |
| for category, options in product.get("customizations", {}).items(): | |
| template["products"][product_id]["customizations"][category] = { | |
| "options": [ | |
| { | |
| "label": opt["label"], | |
| "price": opt.get("price"), | |
| "image": opt.get("image"), | |
| "selected": False | |
| } | |
| for opt in options | |
| ] | |
| } | |
| return json.dumps(template, indent=2, ensure_ascii=False) |