import gradio as gr # 🔗 Learn more about integrating Wishfinity's Add-to-Wishlist functionality: # Visit: https://info.wishfinity.com/button # Example product database PRODUCTS = { "headphones": [ { "name": "Sony WH-1000XM5", "description": "Industry-leading noise canceling wireless headphones.", "price": "$328.00", "image": "https://m.media-amazon.com/images/I/61eeHPRFQ9L._AC_SL1500_.jpg", "url": "https://www.amazon.com/Sony-WH-1000XM5-Headphones-Hands-Free-WH1000XM5/dp/B0BXYCS74H/" }, { "name": "Bose QuietComfort 45", "description": "Premium comfort and superior noise canceling.", "price": "$166.00", "image": "https://m.media-amazon.com/images/I/51smLBpimbL._AC_SL1347_.jpg", "url": "https://www.amazon.com/Bose-QuietComfort-Bluetooth-Cancelling-Headphones/dp/B09HL9MQ64/" } ] } def recommend_product(query): """ Simulated AI product recommendation function. Developers can replace this with their own AI-powered product discovery logic. """ key = "headphones" if "headphone" in query.lower() else None if key and key in PRODUCTS: products = PRODUCTS[key] response = "
" # Divider above first product for product in products: # ----- Wishfinity +W Integration (Extract this for use in your own AI project) ----- wishfinity_url = f"https://wishfinity.com/add?url={product['url']}" icon_url = "https://wishfinity.com/assets/imgs/Wishfinity-Button-Small.svg" save_to_wishlist = ( f"" f" Save to Wishlist" ) # ----------------------------------------------------------------------------------- response += f"
" response += f"{product['name']}

" response += f"📝 {product['description']}

" response += f"💲 {product['price']}

" response += f" \n" response += f"
" response += save_to_wishlist response += f"|" response += f"🛒 Visit Product" response += f"
" response += f"
" response += f"
" # Adjusted spacing for separator line return response return "Sorry, I couldn't find matching products. Try searching for 'headphones'.\n\n**Note:** This is an example setup. Developers can replace the recommendation logic with their own AI model and integrate the 'Save to Wishlist' button into their existing AI applications." iface = gr.Interface( fn=recommend_product, inputs="text", outputs="markdown", title="Add Wishlist Integration to AI-Powered Product Discovery", description="In this demo, enter the example product-related query 'Best wireless headphones' to represent your AI-powered recommendations. Users click 'Save to Wishlist' to save products for later.\n\n**Note:** This is an example setup. Developers can modify the recommendation logic to fit their AI use cases." ) iface.launch()