Skip to content

Commit

Permalink
Ajustes en views.py para integrar correctamente FAISS y OpenAIV3
Browse files Browse the repository at this point in the history
  • Loading branch information
Blaister9 committed Oct 3, 2024
1 parent 26ffc90 commit a94cfaf
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions backend/chatbot_laura/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def load_or_generate_index(self):
if os.path.exists(self.embedding_file) and os.path.exists(self.index_file):
logger.info("Cargando embeddings y FAISS index desde archivo...")
self.embeddings = self.load_embeddings(self.embedding_file)
self.index = faiss.read_index(self.index_file)
self.df = self.load_and_process_data(self.json_file)
self.index = faiss.read_index(self.index_file)
else:
logger.info("Generando nuevos embeddings y FAISS index...")
self.df = self.load_and_process_data(self.json_file)
Expand Down Expand Up @@ -117,8 +116,7 @@ def search(self, query, k=3):
for i in range(k):
result = self.df.iloc[I[0][i]]
results.append({
'pregunta': result['full_content'].get('pregunta', ''),
'respuesta': result['full_content'].get('respuesta', ''),
'content': result['full_content'],
'url': result['url'],
'type': result['type'],
'metadata': result['metadata'],
Expand Down

0 comments on commit a94cfaf

Please sign in to comment.