Untitled
unknown
plain_text
17 days ago
876 B
7
Indexable
Never
import gpt4o_json import perplexity_api from pydantic import BaseModel, ValidationError, model_validator class Product(BaseModel): Camera_type: str Optics_structure: str Optical_design: str Lens_material: str Aperture_size: str Focal_length: str Brand: str Price: str Release_date: str Manufacturer: str gathered_data = preparation.create_empty_instance(Product) while check_empty_values(gathered_data): perplexity_response = perplexity_api.ask_perplexity(product_name, gathered_data) new_data = gpt4o_json.extract_data(Product, perplexity_response) # Update only the empty fields in gathered_data for key in check_empty_values(gathered_data): if key in new_data and new_data[key]: # Check if new_data has a non-empty value for the key gathered_data[key] = new_data[key]
Leave a Comment