Spaces:
Running
Running
Update api/data_extractor.py
Browse files- api/data_extractor.py +3 -0
api/data_extractor.py
CHANGED
@@ -86,6 +86,7 @@ Your goal will be to extract information from these images to populate the schem
|
|
86 |
except Exception as e:
|
87 |
raise Exception(f"Error extracting information: {str(e)}")
|
88 |
|
|
|
89 |
def extract_data(images_list_json: Dict[str, List[Any]]):
|
90 |
if not images_list_json or "images_list" not in images_list_json:
|
91 |
raise Exception("Image links not found")
|
@@ -98,6 +99,7 @@ def extract_data(images_list_json: Dict[str, List[Any]]):
|
|
98 |
except Exception as e:
|
99 |
raise Exception(f"An error occurred {e}") from e
|
100 |
|
|
|
101 |
def find_product(product_name: str):
|
102 |
|
103 |
if not product_name:
|
@@ -124,6 +126,7 @@ def find_product(product_name: str):
|
|
124 |
except Exception as e:
|
125 |
raise Exception(f"An error occurred {e}") from e
|
126 |
|
|
|
127 |
def get_product(product_name: str):
|
128 |
if not product_name:
|
129 |
raise Exception("Please provide a valid product name")
|
|
|
86 |
except Exception as e:
|
87 |
raise Exception(f"Error extracting information: {str(e)}")
|
88 |
|
89 |
+
@app.post("/extract-data")
|
90 |
def extract_data(images_list_json: Dict[str, List[Any]]):
|
91 |
if not images_list_json or "images_list" not in images_list_json:
|
92 |
raise Exception("Image links not found")
|
|
|
99 |
except Exception as e:
|
100 |
raise Exception(f"An error occurred {e}") from e
|
101 |
|
102 |
+
@app.get("/find-product")
|
103 |
def find_product(product_name: str):
|
104 |
|
105 |
if not product_name:
|
|
|
126 |
except Exception as e:
|
127 |
raise Exception(f"An error occurred {e}") from e
|
128 |
|
129 |
+
@app.get("/get-product")
|
130 |
def get_product(product_name: str):
|
131 |
if not product_name:
|
132 |
raise Exception("Please provide a valid product name")
|