File size: 1,213 Bytes
f572bf3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
import streamlit as st
from sentence_transformers import SentenceTransformer
from Rag_milvus import pdfachunk,split_chunks,generaremben,insertarenqdra
from Llm_local import generarPages
col1, col2 = st.columns([1, 4])
with col1:
st.image("Procuradurialogo.jpg", width=600)
with col2:
st.markdown("""
<div style='display: flex; align-items: center; height: 100%;'>
<h1 style='margin: 0; text-align: center;'>ProcurIA</h1>
</div>
""", unsafe_allow_html=True)
st.sidebar.title("Menú de Funciones")
generarPages()
model = SentenceTransformer("all-MiniLM-L6-v2")
archivo = st.file_uploader("📂 Sube tus documentos PDF para chatear con ellos", type=["pdf", "txt"], accept_multiple_files=True)
if archivo:
for file in archivo:
nombre_coleccion = f"coleccion_{file.name.replace('.pdf', '').replace(' ', '_')}"
pdf_chunks = pdfachunk(file)
split_docs = split_chunks(pdf_chunks)
texts = [doc.page_content for doc in split_docs]
embeddings = generaremben(model, texts)
insertarenqdra(embeddings, texts, nombre_coleccion)
st.success("Archivos subidos en la base vectorial con éxito!") |