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:
parent
a691ebd109
commit
24685ebb99
5
app.py
5
app.py
@ -60,7 +60,10 @@ if pdf_name:
|
||||
)
|
||||
|
||||
# Cargamos el modelo LLM desde LangChain
|
||||
llm = langChainTools.load_llm_open_source()
|
||||
# llm = langChainTools.load_llm_open_source()
|
||||
|
||||
# Cargamos el modelo LLm de Ollama
|
||||
llm = langChainTools.load_llm_ollama()
|
||||
|
||||
# Creamos la cadena que integra Vectorstroe, el LLM para hacer consultas.
|
||||
# Para este caso la cadena tene el parametro de memoria.
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user