Spaces:
Sleeping
Sleeping
| aldeco_cmK_info = { | |
| "Product Name": "Aldecoc CMK", | |
| "Product Type (1st level filter option)": "Liquid disinfectant", | |
| "Product Type (2nd level filter option)": ["Bactericidal", "Fungicidal", "Mycobactericidal", "Oocidal", "Parasiticidal", "Virucidal", "Yeasticidal"], | |
| "Chemistry": ["Chlorocresol (CMK)"], | |
| "LBS Industry Categories": ["Equine", "Poultry farms", "Swine farms"], | |
| "LBS Key Diseases/Pathogens": ["Coccidiosis", "Parasites", "Mycobacteria", "Aspergillus"], # regroupe toutes les variations | |
| "Uses": ["Surface & equipment disinfection"], | |
| "Application Methods": ["Spraying (surface)", "Spraying (liquid form)", "Spraying (foam form)"] | |
| } | |
| aldekol_des_ff_info = { | |
| "Product Name": "Aldekol DES FF", | |
| "Product Type (1st level filter option)": "Liquid disinfectant", | |
| "Product Type (2nd level filter option)": ["Bactericidal", "Fungicidal", "Virucidal", "Yeasticidal"], | |
| "Chemistry": ["Glutaraldehyde", "QUATs (ADBAC + DDAC)"], | |
| "LBS Industry Categories": ["Cattle farms", "Hatcheries", "Ruminant farms", "Poultry farms", "Swine farms"], | |
| "LBS Key Diseases/Pathogens": [ | |
| "African swine fever (ASF)", | |
| "Aspergillus", | |
| "Avian influenza (AI)", | |
| "E. coli", | |
| "Enterococcus", | |
| "Foot and mouth disease (FMD)", | |
| "Porcine reproductive and respiratory syndrome (PRRS)", | |
| "Salmonella", | |
| "Swine vesicular disease (SVD)" | |
| ], | |
| "Uses": ["Foot dip", "Vehicle disinfection", "Wheel dip disinfection", "Surface & equipment disinfection"], | |
| "Application Methods": ["Spraying (liquid form)", "Spraying (foam form)", "Cold fogging", "Thermal fogging"] | |
| } | |
| biovx_info = { | |
| "Product Name": "BioVX", | |
| "Product Type (1st level filter option)": "Powder disinfectant", | |
| "Product Type (2nd level filter option)": ["Bactericidal", "Fungicidal", "Sporucidal", "Virucidal", "Yeasticidal"], | |
| "Chemistry": ["KMPS"], | |
| "LBS Industry Categories": ["Poultry farms", "Swine farms", "Cattle farms", "Ruminant farms"], | |
| "LBS Key Diseases/Pathogens": [ | |
| "African swine fever (ASF)", | |
| "Aujeszky’s disease (AD)", | |
| "Classical swine fever (CSF)", | |
| "Foot and mouth disease (FMD)", | |
| "Infectious bursal disease (IBD or Gumboro)", | |
| "Newcastle disease (ND)", | |
| "Porcine parvovirus", | |
| "Swine vesicular disease (SVD)" | |
| ], | |
| "Uses": [ | |
| "Foot dip", | |
| "Vehicle disinfection", | |
| "Surface & equipment disinfection", | |
| "Animal drinking water acidification", | |
| "Animal drinking water disinfection", | |
| "Misting in the presence of animals", | |
| "Pouring", | |
| "Dipping", | |
| "Spraying (liquid form)", | |
| "Misting in presence of animals", | |
| "Dilution (Header tank)", | |
| "Dosing unit (pump)" | |
| ], | |
| "Application Methods": [ | |
| "Pouring", | |
| "Dipping", | |
| "Spraying (liquid form)", | |
| "Misting in presence of animals", | |
| "Dilution (Header tank)", | |
| "Dosing unit (pump)" | |
| ] | |
| } | |
| th5_info = { | |
| "Product Name": "TH5", | |
| "Product Type (1st level filter option)": "Liquid disinfectant", | |
| "Product Type (2nd level filter option)": ["Bactericidal", "Virucidal", "Fungicidal", "Yeasticidal", "Mycobactericidal"], | |
| "Chemistry": ["Glutaraldehyde", "QUATs (ADBAC)"], | |
| "LBS Industry Categories": ["Poultry farms", "Swine farms", "Hatcheries", "Cattle farms", "Ruminant farms"], | |
| "LBS Key Diseases/Pathogens": ["Newcastle disease (ND)", "Necrotic enteritis", "Porcine epidemic diarrhoea (PED)"], | |
| "Uses": [ | |
| "Surface & equipment disinfection", | |
| "Hatching egg disinfection", | |
| "Vehicle disinfection", | |
| "Wheel dip disinfection", | |
| "Foot dip", | |
| "Spraying in the presence of animals", | |
| "Spraying (liquid form)", | |
| "Spraying (foam form)", | |
| "Misting in presence of animals", | |
| "Thermal fogging", | |
| "Cold fogging", | |
| "Dipping", | |
| "Pouring" | |
| ], | |
| "Application Methods": [ | |
| "Spraying in the presence of animals", | |
| "Spraying (liquid form)", | |
| "Spraying (foam form)", | |
| "Misting in presence of animals", | |
| "Thermal fogging", | |
| "Cold fogging", | |
| "Dipping", | |
| "Pouring" | |
| ] | |
| } | |
| virkon_lsp_info = { | |
| "Product Name": "Virkon LSP", | |
| "Product Type (1st level filter option)": ["Powder disinfectant", "Liquid disinfectant"], | |
| "Product Type (2nd level filter option)": [ | |
| "Bactericidal", "Virucidal", "Yeasticidal", "Fungicidal", "Mycobactericidal", "Sporucidal" | |
| ], | |
| "Chemistry": [ | |
| "KMPS", | |
| "Chlorocresol (CMK)", | |
| "Othophenylphenol (OPP)" | |
| ], | |
| "LBS Industry Categories": ["Poultry farms", "Swine farms", "Cattle farms", "Ruminant farms"], | |
| "LBS Key Diseases/Pathogens": [ | |
| "Tilapia lake virus (TiLV)", "Spring viraemia of carp (SVC)", "Infectious pancreatic necrosis (IPN)", | |
| "Yellow head virus (YHV)", "Taura syndrom (TS)", "White spot syndrom virus (WSSV)", | |
| "Enterocytozoon hepatopenaei (EHP)", "Aeromonas hydrophila", "Aeromonas salmonocida", | |
| "Lactococcus garvieae", "Carnobacterium maltaromaticum", "Vibrio harveyi", | |
| "Vibrio parahaemolyticus", "Yersinia ruckeri", "Tomato brown rugose fruit virus (ToBRFV)", | |
| "Agrobacterium radiobacter", "Clavibacter michiganensis ssp. Michiganensis", "Erwinia billingiae" | |
| ], | |
| "Uses": [ | |
| "Surface & equipment disinfection", | |
| "Foot dip", | |
| "Wheel dip disinfection" | |
| ], | |
| "Application Methods": [ | |
| "Spraying (liquid form)", | |
| "Spraying (foam form)", | |
| "Pouring", | |
| "Dipping", | |
| "Thermal fogging" | |
| ] | |
| } | |
| # Définition des contraintes | |
| Product_Type_1 = "Liquid disinfectant" | |
| Product_Type_2 = "Bactericidal" | |
| LBS_Industry_Categories = "Poultry farms" | |
| LBS_Key_Diseases_Pathogens = "Aspergillus" | |
| Uses = "Surface & equipment disinfection" | |
| LBS_Applications = "Spraying (liquid form)" | |
| # Liste de tous les produits | |
| all_products = [ | |
| aldeco_cmK_info, | |
| aldekol_des_ff_info, | |
| biovx_info, | |
| th5_info, | |
| virkon_lsp_info | |
| ] | |
| # Fonction pour vérifier si un produit correspond aux contraintes | |
| def product_matches(product): | |
| # Vérification Product Type 1 | |
| pt1 = product["Product Type (1st level filter option)"] | |
| if isinstance(pt1, list): | |
| if Product_Type_1 not in pt1: | |
| return False | |
| else: | |
| if Product_Type_1 != pt1: | |
| return False | |
| # Vérification Product Type 2 | |
| pt2 = product["Product Type (2nd level filter option)"] | |
| if Product_Type_2 not in pt2: | |
| return False | |
| # Vérification Industry Categories | |
| if LBS_Industry_Categories not in product["LBS Industry Categories"]: | |
| return False | |
| # Vérification Key Diseases/Pathogens | |
| if LBS_Key_Diseases_Pathogens not in product["LBS Key Diseases/Pathogens"]: | |
| return False | |
| # Vérification Uses | |
| if Uses not in product["Uses"]: | |
| return False | |
| # Vérification Applications | |
| if LBS_Applications not in product["Application Methods"]: | |
| return False | |
| return True | |
| # Filtrage des produits | |
| matching_products = [p["Product Name"] for p in all_products if product_matches(p)] | |
| print("Produits correspondants :", matching_products) | |
| elif categorie == "selecteur": | |
| # Extraction des critères depuis la question de l'utilisateur | |
| prompt = f""" | |
| Tu es un assistant virtuel **expert en biosécurité**. | |
| L'utilisateur veut que tu lui proposes un ou plusieurs produits adaptés. | |
| Extrait dans sa question les informations suivantes (mets à null si non trouvé) : | |
| - "Product_Type_1" : "Liquid disinfectant" ou "Powder disinfectant" | |
| - "Product_Type_2" : un élément parmi ["Bactericidal","Fungicidal","Virucidal","Yeasticidal","Mycobactericidal","Sporucidal","Oocidal","Parasiticidal"] | |
| - "LBS_Industry_Categories" : (ex: Poultry farms, Swine farms, Cattle farms, Ruminant farms, Hatcheries, Equine…) | |
| - "LBS_Key_Diseases_Pathogens" : (ex: Aspergillus, ASF, Salmonella…) | |
| - "Uses" : (ex: Surface & equipment disinfection, Foot dip…) | |
| - "LBS_Applications" : (ex: Spraying (liquid form), Foaming, Thermal fogging…) | |
| Question : {message} | |
| Retourne **UNIQUEMENT** un JSON de la forme : | |
| {{ | |
| "Product_Type_1": "Liquid disinfectant", | |
| "Product_Type_2": "Bactericidal", | |
| "LBS_Industry_Categories": "Poultry farms", | |
| "LBS_Key_Diseases_Pathogens": "Aspergillus", | |
| "Uses": "Surface & equipment disinfection", | |
| "LBS_Applications": "Spraying (liquid form)" | |
| }} | |
| """ | |
| criteria_json = llm.complete(prompt).text | |
| try: | |
| criteria = json.loads(criteria_json) | |
| except: | |
| return "Impossible d'interpréter les critères, merci de reformuler votre question." | |
| # Fonction locale de filtrage | |
| def product_matches(product, c): | |
| # Product Type 1 | |
| pt1 = product["Product Type (1st level filter option)"] | |
| if c["Product_Type_1"] and ( | |
| (isinstance(pt1, list) and c["Product_Type_1"] not in pt1) | |
| or (isinstance(pt1, str) and c["Product_Type_1"] != pt1) | |
| ): | |
| return False | |
| # Product Type 2 | |
| if c["Product_Type_2"] and c["Product_Type_2"] not in product["Product Type (2nd level filter option)"]: | |
| return False | |
| # Industry | |
| if c["LBS_Industry_Categories"] and c["LBS_Industry_Categories"] not in product["LBS Industry Categories"]: | |
| return False | |
| # Pathogens | |
| if c["LBS_Key_Diseases_Pathogens"] and c["LBS_Key_Diseases_Pathogens"] not in product["LBS Key Diseases/Pathogens"]: | |
| return False | |
| # Uses | |
| if c["Uses"] and c["Uses"] not in product["Uses"]: | |
| return False | |
| # Applications | |
| if c["LBS_Applications"] and c["LBS_Applications"] not in product["Application Methods"]: | |
| return False | |
| return True | |
| # Recherche des produits correspondants | |
| matches = [p["Product Name"] for p in all_products if product_matches(p, criteria)] | |
| if not matches: | |
| return "Aucun produit ne correspond exactement aux critères donnés." | |
| else: | |
| return f"Produits recommandés : {', '.join(matches)}" | |