Shreyas094 commited on
Commit
096249d
·
verified ·
1 Parent(s): ef2d904

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -3
app.py CHANGED
@@ -25,12 +25,22 @@ from sentence_transformers import SentenceTransformer
25
 
26
  huggingface_token = os.environ.get("HUGGINGFACE_TOKEN")
27
 
28
- # Load spaCy model
29
- nlp = spacy.load("en_core_web_sm")
30
-
31
  # Load SentenceTransformer model
32
  sentence_model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  class EnhancedContextDrivenChatbot:
35
  def __init__(self, history_size=10):
36
  self.history = []
 
25
 
26
  huggingface_token = os.environ.get("HUGGINGFACE_TOKEN")
27
 
 
 
 
28
  # Load SentenceTransformer model
29
  sentence_model = SentenceTransformer('paraphrase-MiniLM-L6-v2')
30
 
31
+ def load_spacy_model():
32
+ try:
33
+ # Try to load the model
34
+ return spacy.load("en_core_web_sm")
35
+ except OSError:
36
+ # If loading fails, download the model
37
+ os.system("python -m spacy download en_core_web_sm")
38
+ # Try loading again
39
+ return spacy.load("en_core_web_sm")
40
+
41
+ # Load spaCy model
42
+ nlp = load_spacy_model()
43
+
44
  class EnhancedContextDrivenChatbot:
45
  def __init__(self, history_size=10):
46
  self.history = []