Se corrigen algunos errores en los modelos de ollama

This commit is contained in:
mongar
2024-05-04 21:34:43 -05:00
parent 24685ebb99
commit 6d3cafc579
9 changed files with 38 additions and 26 deletions

View File

@@ -2,38 +2,50 @@ from colorama import Fore, Back, Style
class MessageManager:
def create_chat(self, qa):
# Emoticon de robot
ia_emoticon = "\U0001F916" # Emoticon de robot Unicode
humano_emoticon = "\U0001F604" # Emoticon de carita feliz Unicode
ia_emoticon = "\U0001f916" # Emoticon de robot Unicode
humano_emoticon = "\U0001f604" # Emoticon de carita feliz Unicode
# Imprimir el texto en amarillo y negrita con el emoticon de robot
# Definicimo el mensaje de la IA
print(f"{ia_emoticon} " + Style.BRIGHT + Fore.YELLOW +
"IA: " + Style.RESET_ALL + "Pregunta algo al documento")
print(
f"{ia_emoticon} "
+ Style.BRIGHT
+ Fore.YELLOW
+ "IA: "
+ Style.RESET_ALL
+ "Pregunta algo al documento"
)
while True:
input_usuario = input(
Style.BRIGHT + Fore.BLUE + f"{humano_emoticon} You: " + Style.RESET_ALL)
if input_usuario.lower() == 'salir':
Style.BRIGHT + Fore.BLUE + f"{humano_emoticon} You: " + Style.RESET_ALL
)
if input_usuario.lower() == "salir":
break
bot_response = qa.invoke({"question": f"{input_usuario}"},
return_only_outputs=True)
print(f'{ia_emoticon} ' + Style.BRIGHT + Fore.YELLOW +
'IA:' + Style.RESET_ALL + f'{bot_response["answer"]}')
bot_response = qa.invoke(
{"question": f"{input_usuario}"}, return_only_outputs=True
)
print(
f"{ia_emoticon} "
+ Style.BRIGHT
+ Fore.YELLOW
+ "IA:"
+ Style.RESET_ALL
+ f'{bot_response["answer"]}'
)
def generate_citations(self, documents_source: list) -> str:
text_source: str = ""
for index, document in enumerate(documents_source):
quote: str = document.page_content
source: str = document.metadata['source'].replace(
'documents/pdfs/', '')
page: str = document.metadata['page'] + 1
fuente: str = f"**Fuente #{index + 1}:** \n '{quote}'\n(*{source}, P.{page})*"
source: str = document.metadata["source"].replace("documents/pdfs/", "")
page: str = document.metadata["page"] + 1
fuente: str = (
f"**Fuente #{index + 1}:** \n '{quote}'\n(*{source}, P.{page})*"
)
text_source += fuente + "\n\n\n"

View File

@@ -14,16 +14,16 @@ def import_file() -> str:
# Agregamos el nombre a la lista de archvios para luego podr verificarlos
List_of_files.append(nombre_archivo)
st.success(
f"El numero de archivos en la lista de archivos es de: {len(List_of_files)}"
)
# st.success(
# f"El numero de archivos en la lista de archivos es de: {len(List_of_files)}"
# )
# Abrir un archivo en modo escritura binaria ('wb') para guardar el archivo de audio
with open(f"documents/pdfs/{nombre_archivo}", "wb") as new_file:
# Leer los datos del archivo cargado y escribirlos en el nuevo archivo
new_file.write(archivo.read())
st.success(f"Se carga el archivo con nombre: {nombre_archivo}")
# st.success(f"Se carga el archivo con nombre: {nombre_archivo}")
# Verificamos que en la lista solo haya un archivo, de lo contrario, limpiamos la session_state
if (