acecalisto3 commited on
Commit
063e8eb
1 Parent(s): d1685e2

Update agent.py

Browse files
Files changed (1) hide show
  1. agent.py +11 -9
agent.py CHANGED
@@ -1,3 +1,5 @@
 
 
1
  import os
2
  import time
3
  import hashlib
@@ -55,7 +57,7 @@ def monitor_urls(storage_location, urls, scrape_interval, content_type, selector
55
  current_content = driver.page_source
56
 
57
  current_hash = hashlib.md5(str(current_content).encode('utf-8')).hexdigest()
58
- if current_hash != previous_hashes[url]:
59
  previous_hashes[url] = current_hash
60
  date_time_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
61
  HISTORY.append(f"Change detected at {url} on {date_time_str}")
@@ -69,6 +71,14 @@ def monitor_urls(storage_location, urls, scrape_interval, content_type, selector
69
  except Exception as e:
70
  logging.error(f"Error starting ChromeDriver: {e}")
71
 
 
 
 
 
 
 
 
 
72
  # Function to start scraping
73
  def start_scraping(storage_location, urls, scrape_interval, content_type, selector=None):
74
  global CURRENT_TASK, HISTORY
@@ -127,14 +137,6 @@ def display_csv(storage_location, url):
127
  else:
128
  return "No data available."
129
 
130
- # Define the chat response function using the Mistral model
131
- def respond(message, history, system_message, max_tokens, temperature, top_p):
132
- model = AutoModelForSeq2SeqLM.from_pretrained_model("mistralai/Mixtral-8x7B-Instruct-v0.1")
133
- tokenizer = AutoTokenizer.from_pretrained_model("mistralai/Mixtral-8x7B-Instruct-v0.1")
134
- pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
135
- response = pipe(f"User: {message}\nHistory: {history}\nSystem: {system_message}", max_length=max_tokens, temperature=temperature, top_p=top_p)[0]
136
- return response
137
-
138
  # Function to generate RSS feed for a given URL
139
  def generate_rss_feed(storage_location, url):
140
  hostname = urlparse(url).hostname
 
1
+ # agent.py
2
+
3
  import os
4
  import time
5
  import hashlib
 
57
  current_content = driver.page_source
58
 
59
  current_hash = hashlib.md5(str(current_content).encode('utf-8')).hexdigest()
60
+ if current_hash!= previous_hashes[url]:
61
  previous_hashes[url] = current_hash
62
  date_time_str = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
63
  HISTORY.append(f"Change detected at {url} on {date_time_str}")
 
71
  except Exception as e:
72
  logging.error(f"Error starting ChromeDriver: {e}")
73
 
74
+ # Function to define the chat response function using the Mistral model
75
+ def respond(message, history, system_message, max_tokens, temperature, top_p):
76
+ model = AutoModelForSeq2SeqLM.from_pretrained_model("mistralai/Mixtral-8x7B-Instruct-v0.1")
77
+ tokenizer = AutoTokenizer.from_pretrained_model("mistralai/Mixtral-8x7B-Instruct-v0.1")
78
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
79
+ response = pipe(f"User: {message}\nHistory: {history}\nSystem: {system_message}", max_length=max_tokens, temperature=temperature, top_p=top_p)[0]
80
+ return response
81
+
82
  # Function to start scraping
83
  def start_scraping(storage_location, urls, scrape_interval, content_type, selector=None):
84
  global CURRENT_TASK, HISTORY
 
137
  else:
138
  return "No data available."
139
 
 
 
 
 
 
 
 
 
140
  # Function to generate RSS feed for a given URL
141
  def generate_rss_feed(storage_location, url):
142
  hostname = urlparse(url).hostname