Se corrigen algunos errores en los modelos de ollama
This commit is contained in:
parent
24685ebb99
commit
6d3cafc579
Binary file not shown.
@ -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"
|
||||
|
||||
|
@ -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 (
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -68,7 +68,7 @@ class LangChainTools:
|
||||
"""
|
||||
|
||||
# db_name = _file_name.replace(".pdf", "").replace(" ", "_").lower()
|
||||
st.success(_file_name)
|
||||
# st.success(_file_name)
|
||||
|
||||
if "db_name" not in st.session_state.keys():
|
||||
st.session_state.db_name = (
|
||||
@ -265,7 +265,7 @@ class LangChainTools:
|
||||
# Pregunta: {question}
|
||||
# Respuesta en español:"""
|
||||
|
||||
conversation.combine_docs_chain.llm_chain.prompt.template = template
|
||||
conversation.question_generator.prompt.template = "Dado el siguiente diálogo y una pregunta de seguimiento, reformula la pregunta de seguimiento para que sea una pregunta independiente, en su idioma original.\n\nHistorial del chat:\n{chat_history}\nPregunta de seguimiento: {question}\nPregunta independiente:"
|
||||
# conversation.combine_docs_chain.llm_chain.prompt.template = template
|
||||
# conversation.question_generator.prompt.template = "Dado el siguiente diálogo y una pregunta de seguimiento, reformula la pregunta de seguimiento para que sea una pregunta independiente, en su idioma original.\n\nHistorial del chat:\n{chat_history}\nPregunta de seguimiento: {question}\nPregunta independiente:"
|
||||
|
||||
return conversation
|
||||
|
@ -39,7 +39,7 @@ class PdfLangChain:
|
||||
loader = PyPDFLoader(_self.file_path)
|
||||
_self.docs = loader.load()
|
||||
|
||||
st.success(f"Se carga el pdf : {_self.file_path}")
|
||||
# st.success(f"Se carga el pdf : {_self.file_path}")
|
||||
return _self.docs
|
||||
|
||||
def split_docs(self, data: list) -> list:
|
||||
@ -60,6 +60,6 @@ class PdfLangChain:
|
||||
)
|
||||
self.docs_split = splitter.split_documents(data)
|
||||
|
||||
st.success(f"{self.file_path[3][:200]}")
|
||||
# st.success(f"{self.file_path[3][:200]}")
|
||||
|
||||
return self.docs_split
|
||||
|
Loading…
Reference in New Issue
Block a user