peterkros commited on
Commit
a19be54
·
verified ·
1 Parent(s): 59718f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -7
app.py CHANGED
@@ -6,9 +6,6 @@ from sklearn.feature_extraction.text import CountVectorizer
6
  import numpy as np
7
  from sentence_transformers import SentenceTransformer
8
 
9
-
10
-
11
-
12
  # Retrieve the token from environment variables
13
  huggingface_token = os.getenv('LLAMA_ACCES_TOKEN')
14
 
@@ -16,8 +13,6 @@ huggingface_token = os.getenv('LLAMA_ACCES_TOKEN')
16
  tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-chat-hf", token=huggingface_token)
17
  model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-chat-hf", token=huggingface_token)
18
 
19
-
20
-
21
  # Function to load bad words from a file
22
  def load_bad_words(filepath):
23
  with open(filepath, 'r', encoding='utf-8') as file:
@@ -30,8 +25,7 @@ bad_words = load_bad_words('badwords.txt') # Adjust the path to your bad words
30
  topics_list = ['Aviation', 'Science', 'Education', 'Air Force Pilot', 'Space Exploration', 'Technology']
31
 
32
  #Load BerTopic model
33
- embedding_model = SentenceTransformer('all-MiniLM-L6-v2')
34
- topic_model = BERTopic.load("MaartenGr/BERTopic_Wikipedia", embedding_model=embedding_model)
35
 
36
  def is_inappropriate_or_offtopic(message, selected_topics):
37
  # Assume bad_words loading and check_content function are defined here
 
6
  import numpy as np
7
  from sentence_transformers import SentenceTransformer
8
 
 
 
 
9
  # Retrieve the token from environment variables
10
  huggingface_token = os.getenv('LLAMA_ACCES_TOKEN')
11
 
 
13
  tokenizer = AutoTokenizer.from_pretrained("meta-llama/Llama-2-7b-chat-hf", token=huggingface_token)
14
  model = AutoModelForCausalLM.from_pretrained("meta-llama/Llama-2-7b-chat-hf", token=huggingface_token)
15
 
 
 
16
  # Function to load bad words from a file
17
  def load_bad_words(filepath):
18
  with open(filepath, 'r', encoding='utf-8') as file:
 
25
  topics_list = ['Aviation', 'Science', 'Education', 'Air Force Pilot', 'Space Exploration', 'Technology']
26
 
27
  #Load BerTopic model
28
+ topic_model = BERTopic.load("MaartenGr/BERTopic_Wikipedia")
 
29
 
30
  def is_inappropriate_or_offtopic(message, selected_topics):
31
  # Assume bad_words loading and check_content function are defined here