NadaAljohani commited on
Commit
af3c0ea
·
verified ·
1 Parent(s): e1e450a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -1,21 +1,20 @@
1
  import gradio as gr
2
- from transformers import pipeline
3
  import random
4
 
5
  # Links for the websites
6
  website_links = {
7
- "Website A": "https://www.jarir.com/sa-en/dp/office-supplies.html?gad_source=1&gclid=Cj0KCQjwiOy1BhDCARIsADGvQnDgDOE5cSZjXQOHsdVQs8Vge-QWL77ocXPBKZ17Op_X7vEF5jwOOekaArlaEALw_wcB&gclsrc=aw.ds#listingContent",
8
- "Website B": "https://www.virginmegastore.sa/en?gad_source=1&gclid=Cj0KCQjwiOy1BhDCARIsADGvQnDpnU5nhgtZ3DiCwPQlPbIfGaTNo7dVBteRI8XQuuSP_HU7B9WieFEaAmuYEALw_wcB",
9
- "Website C": "https://www.extra.com/en-sa?gad_source=1&gclid=Cj0KCQjwiOy1BhDCARIsADGvQnDKIzuV97LBL15A-sg46w429-B0Ch9joJnxWJZMX12lozQRTKJmoA0aAn0hEALw_wcB&gclsrc=aw.ds"
10
  }
11
 
12
  # Function to simulate price generation
13
  def simulate_price(product_name):
14
  # Mock price generation using random values for three different websites
15
  prices = {
16
- "Website A": round(random.uniform(300, 500), 2),
17
- "Website B": round(random.uniform(300, 500), 2),
18
- "Website C": round(random.uniform(300, 500), 2)
19
  }
20
 
21
  # Find the cheapest price
@@ -23,7 +22,7 @@ def simulate_price(product_name):
23
  cheapest_price = prices[cheapest_site]
24
  cheapest_link = website_links[cheapest_site]
25
 
26
- return f"The cheapest price for '{product_name}' is ${cheapest_price:.2f} on {cheapest_site}. You can check it out here: {cheapest_link}"
27
 
28
  # Function to generate and compare prices
29
  def compare_prices(product_name):
@@ -34,7 +33,7 @@ def compare_prices(product_name):
34
  demo = gr.Interface(
35
  fn=compare_prices,
36
  inputs="text",
37
- outputs="text",
38
  title="Price Comparator",
39
  description="Enter the product name to find the cheapest price across simulated websites."
40
  )
 
1
  import gradio as gr
 
2
  import random
3
 
4
  # Links for the websites
5
  website_links = {
6
+ "Jarir": "https://www.jarir.com/sa-en/dp/office-supplies.html?gad_source=1&gclid=Cj0KCQjwiOy1BhDCARIsADGvQnDgDOE5cSZjXQOHsdVQs8Vge-QWL77ocXPBKZ17Op_X7vEF5jwOOekaArlaEALw_wcB&gclsrc=aw.ds#listingContent",
7
+ "Virgin Megastore": "https://www.virginmegastore.sa/en?gad_source=1&gclid=Cj0KCQjwiOy1BhDCARIsADGvQnDpnU5nhgtZ3DiCwPQlPbIfGaTNo7dVBteRI8XQuuSP_HU7B9WieFEaAmuYEALw_wcB",
8
+ "Extra": "https://www.extra.com/en-sa?gad_source=1&gclid=Cj0KCQjwiOy1BhDCARIsADGvQnDKIzuV97LBL15A-sg46w429-B0Ch9joJnxWJZMX12lozQRTKJmoA0aAn0hEALw_wcB&gclsrc=aw.ds"
9
  }
10
 
11
  # Function to simulate price generation
12
  def simulate_price(product_name):
13
  # Mock price generation using random values for three different websites
14
  prices = {
15
+ "Jarir": round(random.uniform(300, 500), 2),
16
+ "Virgin Megastore": round(random.uniform(300, 500), 2),
17
+ "Extra": round(random.uniform(300, 500), 2)
18
  }
19
 
20
  # Find the cheapest price
 
22
  cheapest_price = prices[cheapest_site]
23
  cheapest_link = website_links[cheapest_site]
24
 
25
+ return f"The cheapest price for '{product_name}' is ${cheapest_price:.2f} on {cheapest_site}. [Check it out here]({cheapest_link})."
26
 
27
  # Function to generate and compare prices
28
  def compare_prices(product_name):
 
33
  demo = gr.Interface(
34
  fn=compare_prices,
35
  inputs="text",
36
+ outputs="markdown", # Use "markdown" to allow clickable links
37
  title="Price Comparator",
38
  description="Enter the product name to find the cheapest price across simulated websites."
39
  )