acecalisto3 commited on
Commit
b320b58
·
verified ·
1 Parent(s): 25b9363

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -6
app.py CHANGED
@@ -23,8 +23,10 @@ def create_interface():
23
  urls = gr.Textbox(label="URLs (comma separated)")
24
  scrape_interval = gr.Slider(minimum=1, maximum=60, value=5, step=1, label="Scrape Interval (minutes)")
25
  content_type = gr.Radio(choices=["text", "media", "both"], value="text", label="Content Type")
 
26
  start_button = gr.Button("Start Scraping")
27
  csv_output = gr.Textbox(label="CSV Output", interactive=False)
 
28
 
29
  with gr.Column():
30
  chat_history = gr.Chatbot(label="Chat History")
@@ -34,21 +36,21 @@ def create_interface():
34
  """Start scraping callback"""
35
  try:
36
  validated_values = validate_input(values)
37
- start_scraping(validated_values["storage_location"], validated_values["urls"], validated_values["scrape_interval"], validated_values["content_type"])
38
- display_csv(validated_values["storage_location"])
39
  except Exception as e:
40
  print(f"Error: {str(e)}")
41
 
42
- start_button.click(start_scraping_callback, inputs=[storage_location, urls, scrape_interval, content_type], outputs=csv_output)
43
 
44
  def chat_interface_callback(values):
45
  """Chat interface callback"""
46
  try:
47
- chat_interface(values["message"], chat_history, system_message, max_tokens, temperature, top_p, storage_location, urls, scrape_interval, content_type)
48
  except Exception as e:
49
  print(f"Error: {str(e)}")
50
 
51
- message.submit(chat_interface_callback, inputs=[message, chat_history, system_message, max_tokens, temperature, top_p, storage_location, urls, scrape_interval, content_type], outputs=[chat_history, response_box])
52
 
53
  # Add a button to display the RSS feed for a selected URL
54
  with gr.Row():
@@ -59,7 +61,7 @@ def create_interface():
59
  def generate_rss_feed_callback(values):
60
  """Generate RSS feed callback"""
61
  try:
62
- generate_rss_feed(values["selected_url"])
63
  except Exception as e:
64
  print(f"Error: {str(e)}")
65
 
 
23
  urls = gr.Textbox(label="URLs (comma separated)")
24
  scrape_interval = gr.Slider(minimum=1, maximum=60, value=5, step=1, label="Scrape Interval (minutes)")
25
  content_type = gr.Radio(choices=["text", "media", "both"], value="text", label="Content Type")
26
+ selector = gr.Textbox(label="CSS Selector (for media, optional)")
27
  start_button = gr.Button("Start Scraping")
28
  csv_output = gr.Textbox(label="CSV Output", interactive=False)
29
+ status_output = gr.Textbox(label="Status", interactive=False)
30
 
31
  with gr.Column():
32
  chat_history = gr.Chatbot(label="Chat History")
 
36
  """Start scraping callback"""
37
  try:
38
  validated_values = validate_input(values)
39
+ status_output.value = start_scraping(validated_values["storage_location"], validated_values["urls"].split(","), validated_values["scrape_interval"], validated_values["content_type"], validated_values["selector"])
40
+ csv_output.value = display_csv(validated_values["storage_location"], validated_values["urls"].split(",")[0]) # Display CSV for the first URL
41
  except Exception as e:
42
  print(f"Error: {str(e)}")
43
 
44
+ start_button.click(start_scraping_callback, inputs=[storage_location, urls, scrape_interval, content_type, selector], outputs=[csv_output, status_output])
45
 
46
  def chat_interface_callback(values):
47
  """Chat interface callback"""
48
  try:
49
+ chat_interface(values["message"], chat_history, system_message, max_tokens, temperature, top_p, storage_location, urls.split(","), scrape_interval, content_type, selector)
50
  except Exception as e:
51
  print(f"Error: {str(e)}")
52
 
53
+ message.submit(chat_interface_callback, inputs=[message, chat_history, system_message, max_tokens, temperature, top_p, storage_location, urls, scrape_interval, content_type, selector], outputs=[chat_history, response_box])
54
 
55
  # Add a button to display the RSS feed for a selected URL
56
  with gr.Row():
 
61
  def generate_rss_feed_callback(values):
62
  """Generate RSS feed callback"""
63
  try:
64
+ rss_output.value = generate_rss_feed(storage_location, values["selected_url"])
65
  except Exception as e:
66
  print(f"Error: {str(e)}")
67