Se corrigio el problema que mantenia el archivo entre sesiones implementando la session_state de streamlit y un mejor manejo de la cache

This commit is contained in:
mongar
2024-05-04 15:24:50 -05:00
parent a691ebd109
commit 24685ebb99
6 changed files with 25 additions and 1 deletions

View File

@@ -10,6 +10,7 @@ from langchain.chains import RetrievalQAWithSourcesChain, ConversationalRetrieva
from langchain_community.llms import HuggingFaceEndpoint
from langchain_community.embeddings import HuggingFaceEmbeddings
from streamlit.runtime.state import session_state
from langchain_community.llms import Ollama
class LangChainTools:
@@ -150,6 +151,26 @@ class LangChainTools:
return llm
@st.cache_resource
def load_llm_ollama(_self):
"""Esta funcion carga un modelo de LLM OpenSource desde Ollama
Returns:
_type_: Retorno a un objetito de tipo LLM de OpenAI
"""
# Elegimos el modelo de Ollama que utilizaremos
model: str = "gemma:2b"
llm = Ollama(
model=model,
temperature=0.1,
num_ctx=1000,
)
return llm
def define_retrieval_qa(self, _llm, _vectordb, _file_name, _embedding_model):
"""Esta función integra un LLM y una base de datos vectorial en una
chain de LangChain para hacer requerimientos. Este modelo no integra memoria.