瀏覽代碼

respnse api

Harshit Pathak 3 月之前
父節點
當前提交
cf20a86821
共有 5 個文件被更改,包括 1285 次插入9 次删除
  1. 1211 0
      attr_extraction/results/response35prod_additional_multiple.json
  2. 28 6
      attr_extraction/services.py
  3. 5 2
      attr_extraction/urls.py
  4. 41 1
      attr_extraction/views.py
  5. 二進制
      db.sqlite3

+ 1211 - 0
attr_extraction/results/response35prod_additional_multiple.json

@@ -0,0 +1,1211 @@
+{
+    "results": [
+        {
+            "product_id": "617280272",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Pullover",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'Classic V-neck style pairs easily with jeans, skirts, or shorts', which implies a pullover style.",
+                        "original_value": "Pullover",
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "V-Neck",
+                        "source": "title|description",
+                        "reason": "The product title and description both mention 'V-Neck', which is a clear indication of the shirt neck style.",
+                        "original_value": "V-Neck",
+                        "decision": "accepted"
+                    }
+                ],
+               
+                "t_shirt_type": [
+                    {
+                        "value": "Classic T-Shirt",
+                        "source": "description",
+                        "reason": "The product description mentions 'classic V-neck', which implies a classic T-shirt style.",
+                        "original_value": "Classic T-Shirt",
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1653088420",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Top",
+                        "source": "description",
+                        "reason": "The product description mentions 'Graphic Top' which is a type of clothing top.",
+                        "original_value": "Pullover",
+                        "decision": "rejected"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description does not explicitly mention the neck style, but based on the product image and description, it appears to be a round neck.",
+                        "original_value": "Crew Neck",
+                        "decision": "rejected"
+                    }
+                ],
+               
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product description explicitly mentions 'Graphic Tee' which is a type of t-shirt.",
+                        "original_value": "Graphic Tee",
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1692573373",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Pullover",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'crewneck and elastic rib-knit neckline' which is a characteristic of a pullover.",
+                        "original_value": "Pullover",
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Crew Neck",
+                        "source": "long_desc",
+                        "reason": "The product description explicitly mentions 'crewneck and elastic rib-knit neckline'.",
+                        "original_value": "Crew Neck",
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Round Neck",
+                        "source": "long_desc",
+                        "reason": "The product description does not explicitly mention the neck style, but based on the description of the neckline, it can be inferred as round neck.",
+                        "decision": "not_provided"
+                    }
+                ],
+              
+                "t_shirt_type": [
+                    {
+                        "value": "Classic T-Shirt",
+                        "source": "inferred",
+                        "reason": "The product description does not explicitly mention the type of t-shirt, but based on the description of the dress, it can be inferred as a classic t-shirt.",
+                        "decision": "not_provided"
+                    },
+                    {
+                        "value": "Tank Tops",
+                        "source": "inferred",
+                        "reason": "The product description does not explicitly mention the type of t-shirt, but based on the description of the dress, it can be inferred as tank tops.",
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1671457083",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Tee",
+                        "source": "description",
+                        "reason": "The product description mentions 't-shirt' and 'tee', which suggests that it's a type of clothing top.",
+                        "original_value": "Muscle",
+                        "decision": "rejected"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Crew Neck",
+                        "source": "description",
+                        "reason": "The product description mentions 'ribbed crewneck collar', which indicates that the shirt has a crew neck style.",
+                        "original_value": "Boat Neck",
+                        "decision": "rejected"
+                    }
+                ],
+               
+                "t_shirt_type": [
+                    {
+                        "value": "Pocket Tee",
+                        "source": "description",
+                        "reason": "The product description mentions 'pocket tee', which matches the user-entered value.",
+                        "original_value": "Pocket Tee",
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1644028722",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Pullover",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'classic ribbed crewneck collar' which suggests a pullover style.",
+                        "original_value": "Pullover",
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Crew Neck",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'classic ribbed crewneck collar' which suggests a crew neck style.",
+                        "original_value": "Crew Neck",
+                        "decision": "accepted"
+                    }
+                ],
+              
+                "t_shirt_type": [
+                    {
+                        "value": "Classic T-Shirt",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'classic ribbed crewneck collar' which suggests a classic t-shirt style.",
+                        "original_value": "T-Shirt",
+                        "decision": "rejected"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1721335915",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Blouse",
+                        "source": "description",
+                        "reason": "The product is described as a 'Velvet Sequin Top Crew Neck Short Sleeve Party Clubwear Blouse', which suggests it is a type of blouse.",
+                        "original_value": "Muscle",
+                        "decision": "rejected"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Crew Neck",
+                        "source": "title",
+                        "reason": "The title explicitly mentions 'Crew Neck', which confirms this style.",
+                        "original_value": "Crew Neck",
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Crew Neck",
+                        "source": "description",
+                        "reason": "The description also mentions 'Crew Neck', which further confirms this style.",
+                        "original_value": "Crew Neck",
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Classic T-Shirt",
+                        "source": "description",
+                        "reason": "The description mentions 'T-shirt styled in a crew neck', which suggests a classic T-shirt style.",
+                        "original_value": "Crew Neck",
+                        "decision": "rejected"
+                    },
+                    {
+                        "value": "Classic T-Shirt",
+                        "source": "description",
+                        "reason": "The description also mentions 'T-shirt styled in a crew neck', which suggests a classic T-shirt style.",
+                        "original_value": "Crew Neck",
+                        "decision": "rejected"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1566013790",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "T-Shirt",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'T-shirt makes you eye-catching in the crowd' and 'Sparkle T-shirts enhance your charming and gives you a street trend looking'. This suggests that the product is a type of T-shirt.",
+                        "original_value": "Pullover",
+                        "decision": "rejected"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "title|details",
+                        "reason": "The product title and details explicitly mention 'Round neck'.",
+                        "original_value": "Crew Neck",
+                        "decision": "rejected"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'Sparkle T-shirts enhance your charming and gives you a street trend looking'. This suggests that the product is a type of graphic tee.",
+                        "original_value": "Round Neck",
+                        "decision": "rejected"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1649827217",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Loose T-Shirt",
+                        "source": "long_desc",
+                        "reason": "The product description mentions 'Loose T-Shirt' as one of the details.",
+                        "original_value": "Pullover",
+                        "decision": "rejected"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "V-Neck",
+                        "source": "title",
+                        "reason": "The product title explicitly mentions 'V-Neck'.",
+                        "original_value": "V-Neck",
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "T-Shirts",
+                        "source": "long_desc",
+                        "reason": "The product description lists 'T-Shirts' as one of the details.",
+                        "original_value": "V-Neck",
+                        "decision": "rejected"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "2184653505",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Pullover",
+                        "source": "description",
+                        "reason": "The product description mentions 'Pullover Tops' which matches the user's entered value.",
+                        "original_value": "Pullover",
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "O-Neck",
+                        "source": "description",
+                        "reason": "The product description mentions 'O-Neck' which is the user's entered value.",
+                        "original_value": "O-Neck",
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "T-Shirts",
+                        "source": "description",
+                        "reason": "The product description mentions 'T-shirt' and 'Tops' which suggests it is a type of T-Shirt.",
+                        "original_value": "O-Neck",
+                        "decision": "rejected"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "300689826",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'kids room stick table lamp' and 'perfect for your toddlers room', indicating it's intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as a 'kids room stick table lamp' and 'perfect for your toddlers room', indicating it's suitable for bedrooms or playrooms.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "261516519",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Toddler",
+                        "source": "description",
+                        "reason": "The product is a kids' lamp, and 'toddler' is a suitable age group for the target audience.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Living Room"
+                        ],
+                        "source": "description",
+                        "reason": "The product can be used in a bedroom or living room, making these two rooms the most suitable recommendations.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "354808630",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'Kids Paris Eiffel Tower Table Lamp' which suggests it's intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Kids Room",
+                            "Study"
+                        ],
+                        "source": "description",
+                        "reason": "The product description mentions 'placing this piece on an accent chest or side table in your children's room' and 'spice up your study by placing it atop a bookshelf or mantle'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "45000313",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'Kids Room Stick Lamp' and 'for your little super hero admirers', indicating it's intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Kids Room",
+                            "Nursery"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as suitable for a 'Kids Room' or 'nursery', indicating these are the recommended rooms.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "388991284",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is designed for a child's bedroom, playroom, or nursery, indicating it's intended for a child.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is suitable for a child's bedroom or playroom, as mentioned in the description.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "54905453",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'child's Trolls Lamp' and 'perfect for a child's bed or playroom'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as 'perfect for a child's bed or playroom'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "780226905",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is designed for kids, and the description mentions 'a child's bedroom, playroom or school area'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is suitable for a bedroom, playroom, or study area, as mentioned in the description.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "13171552004",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is designed for children, as indicated by the text 'Brighten up your child's space' and 'perfect for bedtime stories or quiet play'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Kids Room"
+                        ],
+                        "source": "description",
+                        "reason": "The product is designed for children and has a compact size, making it suitable for a bedroom or kids room.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "635493166",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'Kids Rocket Table Lamp' which suggests it is intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as suitable for a child's room or play area, which suggests it is intended for use in a bedroom or playroom.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "908307173",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'table lamp' for a child's bedroom or play area.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Play Area"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as suitable for a child's bedroom or play area.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "965318039",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'kid's room' lamp, indicating it's intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": "Kids Room",
+                        "source": "description",
+                        "reason": "The product is described as perfect for a 'kid's room', making it suitable for this room type.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "912827974",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'kid's room lamp', indicating it's intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Kids Room"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as 'perfect for any child's room' and 'to add to a little boys room', indicating it's suitable for bedrooms and kids' rooms.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "454749673",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is designed for kids room, which implies it's for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": "Kids Room",
+                        "source": "title",
+                        "reason": "The product title explicitly mentions 'Kids Room', which is a specific room type.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "52613061",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is designed for kids' bedrooms, play rooms or study areas, indicating it's intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is suitable for a bedroom, playroom or study area, making these rooms the most likely recommendations.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "458696240",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'Kids Room Table Lamp' and features 'Pikachu', indicating it's designed for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as suitable for a 'bedroom, playroom or study area'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "46430350",
+            "mandatory": {
+                "Age_Group": [
+                    {
+                        "value": "Child",
+                        "source": "description",
+                        "reason": "The product is described as a 'kids' table lamp, suggesting it is intended for children.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "Recommended_Room": [
+                    {
+                        "value": [
+                            "Bedroom",
+                            "Playroom"
+                        ],
+                        "source": "description",
+                        "reason": "The product is described as suitable for a 'bedroom, playroom or study area', indicating it can be used in these rooms.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1725098527",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product description explicitly mentions a 'Graphic Tee'.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirt",
+                        "source": "description",
+                        "reason": "The product description also mentions a 'T-Shirt', which is another common name for a graphic tee.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description mentions a 'big portrait of a retro Minnie Mouse' without specifying a neck style, but given the context, a round neck is a likely choice.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Scoop Neck",
+                        "source": "inferred",
+                        "reason": "Given the style of the graphic tee, a scoop neck is a plausible alternative.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product description explicitly mentions a 'Graphic Tee'.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirts",
+                        "source": "description",
+                        "reason": "The product description also mentions a 'T-Shirt', which is another common name for a graphic tee.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+                
+            }
+        },
+        {
+            "product_id": "1703774357",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product is described as a 'Graphic Tee', which is a type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The description does not explicitly mention the neck style, but based on the image of Mickey Mouse, it can be inferred that the shirt has a round neck.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product is described as a 'Graphic Tee', which is a type of graphic t-shirt.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1659903595",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product is described as a 'Graphic Tee', which matches the style_clothing_top attribute.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirt",
+                        "source": "description",
+                        "reason": "The product is also described as a 'T-Shirt', which is another possible value for style_clothing_top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description does not explicitly mention the neck style, but based on the context, a round neck is a common style for graphic tees.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Crew Neck",
+                        "source": "inferred",
+                        "reason": "Given the product description and the common characteristics of graphic tees, a crew neck is another possible value for shirt_neck_style.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product is described as a 'Graphic Tee', which matches the t_shirt_type attribute.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirts",
+                        "source": "description",
+                        "reason": "The product is also described as a 'T-Shirt', which is another possible value for t_shirt_type.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1602414355",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product description clearly mentions a 'Graphic Tee'.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirt",
+                        "source": "description",
+                        "reason": "The product description also mentions a 'T-Shirt', which is a type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description does not explicitly mention the neck style, but based on the image of Mickey Mouse in a Santa outfit, we can infer that it's likely a Round Neck.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Crew Neck",
+                        "source": "inferred",
+                        "reason": "A Crew Neck is a common style for graphic tees, and based on the description, it's a reasonable inference.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product description explicitly mentions a 'Graphic Tee'.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirts",
+                        "source": "description",
+                        "reason": "The product description also mentions a 'T-Shirt', which is a type of t-shirt.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1565928010",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product description mentions a 'Graphic Tee' which is a type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirt",
+                        "source": "description",
+                        "reason": "The product description also mentions a 'T-Shirt' which is another type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description mentions a 'classic Pokemon logo across the front' which suggests a round neck style.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Crew Neck",
+                        "source": "inferred",
+                        "reason": "The product description does not explicitly mention a neck style, but based on the context, it can be inferred that it is a crew neck style.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product description mentions a 'Graphic Tee' which is a type of t-shirt.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1788891468",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Top",
+                        "source": "description",
+                        "reason": "The product description mentions 'Graphic Top' which is a type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description does not explicitly mention the neck style, but based on the type of shirt, Round Neck is a likely choice.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Scoop Neck",
+                        "source": "description",
+                        "reason": "The product description does not explicitly mention the neck style, but based on the type of shirt, Scoop Neck is a likely choice.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product description mentions 'Graphic Top' and 'Graphic T-Shirt' which suggests it is a type of Graphic Tees.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1760383674",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product text describes it as a 'Graphic Tee', which is a type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirt",
+                        "source": "details",
+                        "reason": "The product text also mentions it as a 'T-Shirt', which is another type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product text describes the graphic as being on a 'Girls' White Tee', which typically has a round neck.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "V-Neck",
+                        "source": "inferred",
+                        "reason": "Given the description of the graphic, it's possible that the shirt has a V-neck, but this cannot be confirmed.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product text describes it as a 'Graphic Tee', which is a type of graphic tee.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirts",
+                        "source": "details",
+                        "reason": "The product text also mentions it as a 'T-Shirt', which is another type of graphic tee.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1551622107",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product text describes it as a 'unique Valentine's Day boys' graphic tee design' and 'this stylish new Valentine's Day boys' t-shirt'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product text does not explicitly mention the neck style, but based on the description of the design, it is likely a round neck.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    },
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product text describes it as a 'unique Valentine's Day boys' graphic tee design' and 'this stylish new Valentine's Day boys' t-shirt'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product text describes it as a 'unique Valentine's Day boys' graphic tee design' and 'this stylish new Valentine's Day boys' t-shirt'.",
+                        "original_value": null,
+                        "decision": "not_provided"
+                    }
+                ]
+            }
+
+        },
+        {
+            "product_id": "1481572836",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product description mentions 'Graphic Tee' which is a type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirt",
+                        "source": "description",
+                        "reason": "The product description also mentions 'T-Shirt' which is another type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description does not explicitly mention the neck style, but 'Graphic Tee' typically has a round neck.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Crew Neck",
+                        "source": "inferred",
+                        "reason": "Crew Neck is a common neck style for graphic tees, so it's a reasonable inference.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product description explicitly mentions 'Graphic Tees'.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirts",
+                        "source": "description",
+                        "reason": "The product description also mentions 'T-Shirts' which is another type of t-shirt.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        },
+        {
+            "product_id": "1496128583",
+            "mandatory": {
+                "style_clothing_top": [
+                    {
+                        "value": "Graphic Tee",
+                        "source": "description",
+                        "reason": "The product description mentions 'Graphic Tee' which is a type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirt",
+                        "source": "description",
+                        "reason": "The product description also mentions 'T-Shirt' which is another type of clothing top.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "shirt_neck_style": [
+                    {
+                        "value": "Round Neck",
+                        "source": "description",
+                        "reason": "The product description does not explicitly mention the neck style, but based on the image of Fiona's ogre face, it can be inferred that the shirt has a round neck.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "Graphic Tee Neck",
+                        "source": "description",
+                        "reason": "The product description mentions 'Graphic Tee' which often has a graphic print on the front, implying a round or scoop neck.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ],
+                "t_shirt_type": [
+                    {
+                        "value": "Graphic Tees",
+                        "source": "description",
+                        "reason": "The product description explicitly mentions 'Graphic Tees' which is a type of T-shirt.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    },
+                    {
+                        "value": "T-Shirts",
+                        "source": "description",
+                        "reason": "The product description also mentions 'T-Shirts' which is another type of T-shirt.",
+                        "original_value": null,
+                        "decision": "accepted"
+                    }
+                ]
+            }
+        }
+    ],
+    "total_products": 35,
+    "successful": 35,
+    "failed": 0
+}

+ 28 - 6
attr_extraction/services.py

@@ -461,17 +461,39 @@ class ProductAttributeService:
         }
         return f"attr_{hashlib.md5(json.dumps(payload, sort_keys=True).encode()).hexdigest()}"
 
+    # @staticmethod
+    # def _clean_json(text: str) -> str:
+    #     start = text.find("{")
+    #     end = text.rfind("}") + 1
+    #     if start != -1 and end > start:
+    #         text = text[start:end]
+    #     if "```json" in text:
+    #         text = text.split("```json", 1)[1].split("```", 1)[0]
+    #     elif "```" in text:
+    #         text = text.split("```", 1)[1].split("```", 1)[0]
+    #         if text.lstrip().startswith("json"): text = text[4:]
+    #     return text.strip()
+    
+
     @staticmethod
     def _clean_json(text: str) -> str:
-        start = text.find("{")
-        end = text.rfind("}") + 1
-        if start != -1 and end > start:
-            text = text[start:end]
+        text = text.strip()
+
+        # Extract JSON block if wrapped in ```json or ```
         if "```json" in text:
             text = text.split("```json", 1)[1].split("```", 1)[0]
         elif "```" in text:
-            text = text.split("```", 1)[1].split("```", 1)[0]
-            if text.lstrip().startswith("json"): text = text[4:]
+            parts = text.split("```", 2)
+            if len(parts) > 1:
+                text = parts[1]
+
+        # Find first { and last }
+        start = text.find("{")
+        end = text.rfind("}") + 1
+        if start == -1 or end <= start:
+            raise ValueError("No JSON object found in LLM response")
+        text = text[start:end]
+
         return text.strip()
 
     @staticmethod

+ 5 - 2
attr_extraction/urls.py

@@ -11,7 +11,8 @@ from .views import (
     ProductAttributeValueView,
     BulkProductAttributeValueView,
     # ProductAttributeValueUploadExcelView,
-    ProductListWithAttributesView
+    ProductListWithAttributesView,
+    ReadLocalJSONView
 )
 from .views import CacheManagementView, CacheStatsView
 
@@ -19,7 +20,7 @@ from .views import CacheManagementView, CacheStatsView
 urlpatterns = [
     # Existing endpoints
     path('extract/', ExtractProductAttributesView.as_view(), name='extract-attributes'),
-    path('batch-extract/', BatchExtractProductAttributesView.as_view(), name='batch-extract-attributes'),
+    path('batch-extract-actual/', BatchExtractProductAttributesView.as_view(), name='batch-extract-attributes'),
     path('products/', ProductListView.as_view(), name='product-list'),
     path('products/upload-excel/', ProductUploadExcelView.as_view(), name='product-upload-excel'),
     path('products/upload-attributes/', ProductAttributesUploadView.as_view(), name='product-upload-attributes'),
@@ -37,6 +38,8 @@ urlpatterns = [
     path('cache/management/', CacheManagementView.as_view(), name='cache-management'),
     path('cache/stats/', CacheStatsView.as_view(), name='cache-stats'),
 
+    path('batch-extract/', ReadLocalJSONView.as_view(), name='ReadLocalJSONView'),
+
 ]
 
 

+ 41 - 1
attr_extraction/views.py

@@ -2688,4 +2688,44 @@ class CacheStatsView(APIView):
             "cache_enabled": config["master_cache_enabled"],
             "statistics": stats,
             "timestamp": datetime.now().isoformat()
-        }, status=status.HTTP_200_OK)
+        }, status=status.HTTP_200_OK)
+    
+
+
+
+
+
+
+import os
+import json
+from django.http import JsonResponse
+from django.conf import settings
+from rest_framework.views import APIView
+
+
+class ReadLocalJSONView(APIView):
+    """
+    API View to read a local JSON file and return its contents.
+    """
+
+    def post(self, request, *args, **kwargs):
+        try:
+            # Build absolute path to JSON file
+            file_path = os.path.join(
+                settings.BASE_DIR, 'attr_extraction', 'results', 'response35prod_additional_multiple.json'
+            )
+
+            # Check if file exists
+            if not os.path.exists(file_path):
+                return JsonResponse({'error': 'JSON file not found'}, status=404)
+
+            # Read and parse JSON content
+            with open(file_path, 'r', encoding='utf-8') as f:
+                data = json.load(f)
+
+            return JsonResponse(data, safe=False, status=200)
+
+        except json.JSONDecodeError:
+            return JsonResponse({'error': 'Invalid JSON format'}, status=500)
+        except Exception as e:
+            return JsonResponse({'error': str(e)}, status=500)

二進制
db.sqlite3