Skip to content

Commit

Permalink
fix: trazas subir archivo
Browse files Browse the repository at this point in the history
  • Loading branch information
Jlarrinzal committed Dec 2, 2024
1 parent cdc8066 commit 0ac442b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
18 changes: 11 additions & 7 deletions routes/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,25 @@ def upload_file():
files = request.files.getlist('file')
if not files:
return jsonify({"error": "No selected file"}), 400



for file in files:
if file.filename == '':
return jsonify({"error": f"Empty filename in {file}"}), 400
filename = secure_filename(file.filename)
file_path = os.path.join('uploads', filename)
file.save(file_path)

try:
filename = secure_filename(file.filename)
file_path = os.path.join('uploads', filename)
file.save(file_path)

initialize_weaviate(file_path)
except Exception as e:
return jsonify({"error": str(e)}), 500

print(f"Ha fallado subir a la carpeta uploads: {e}")
return jsonify({"error": f"Failed to process file {file.filename}: {str(e)}"}), 500

print(f"Files uploaded, processed, and embeddings stored in Weaviate")
return jsonify({"message": "Files uploaded, processed, and embeddings stored in Weaviate"}), 200


# @routes_bp.route('/ask', methods=['POST'])
# def ask_question():
# data = request.get_json()
Expand Down
1 change: 1 addition & 0 deletions services/embeddings_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def initialize_weaviate(pdf_path):

# Verificar si Weaviate está listo
if not client.is_ready():
print("Weaviate no está listo. Verifica que el contenedor Docker esté corriendo.")
raise ConnectionError("Weaviate no está listo. Verifica que el contenedor Docker esté corriendo.")

# Crear la colección Rag1 si no existe
Expand Down

0 comments on commit 0ac442b

Please sign in to comment.