drguilhermeapolinario commited on
Commit
4a9ffaf
·
verified ·
1 Parent(s): 9fc3844

Update views/rag_med.py

Browse files
Files changed (1) hide show
  1. views/rag_med.py +17 -2
views/rag_med.py CHANGED
@@ -9,8 +9,23 @@ from sentence_transformers import SentenceTransformer
9
  import pickle
10
  from prompt_template import prompt
11
 
12
- # root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
13
- # sys.path.append(root_dir)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  # Initialize the messages list in the session state
16
  if "messages" not in st.session_state:
 
9
  import pickle
10
  from prompt_template import prompt
11
 
12
+ # Função para encontrar o arquivo
13
+ def find_file(filename):
14
+ current_dir = os.path.dirname(os.path.abspath(__file__))
15
+ root_dir = os.path.dirname(current_dir)
16
+
17
+ possible_paths = [
18
+ os.path.join(current_dir, filename),
19
+ os.path.join(root_dir, filename),
20
+ os.path.join("/content", filename), # Para ambientes como Colab
21
+ os.path.join("/home/user/app", filename) # Caminho comum no Hugging Face
22
+ ]
23
+
24
+ for path in possible_paths:
25
+ if os.path.exists(path):
26
+ return path
27
+
28
+ raise FileNotFoundError(f"Não foi possível encontrar o arquivo: {filename}")
29
 
30
  # Initialize the messages list in the session state
31
  if "messages" not in st.session_state: