Skip to content

Commit

Permalink
load ollama model added
Browse files Browse the repository at this point in the history
  • Loading branch information
Leon-Sander committed Feb 27, 2024
1 parent 6e9bfba commit 877c159
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def load_chain():

def toggle_pdf_chat():
st.session_state.pdf_chat = True
clear_cache()

def get_session_key():
if st.session_state.session_key == "new_session":
Expand Down
7 changes: 7 additions & 0 deletions llm_chains.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@
from langchain.prompts import PromptTemplate
from langchain_community.llms import CTransformers
from langchain_community.vectorstores import Chroma
from langchain_community.llms import Ollama
from utils import load_config
import chromadb

config = load_config()

def load_ollama_model():
llm = Ollama(model=config["ollama_model"])
return llm

def create_llm(model_path = config["ctransformers"]["model_path"]["large"], model_type = config["ctransformers"]["model_type"], model_config = config["ctransformers"]["model_config"]):
llm = CTransformers(model=model_path, model_type=model_type, config=model_config)
return llm
Expand Down Expand Up @@ -52,6 +57,7 @@ class pdfChatChain:
def __init__(self):
vector_db = load_vectordb(create_embeddings())
llm = create_llm()
#llm = load_ollama_model()
self.llm_chain = load_retrieval_chain(llm, vector_db)

def run(self, user_input, chat_history):
Expand All @@ -62,6 +68,7 @@ class chatChain:

def __init__(self):
llm = create_llm()
#llm = load_ollama_model()
chat_prompt = create_prompt_from_template(memory_prompt_template)
self.llm_chain = create_llm_chain(llm, chat_prompt)

Expand Down

0 comments on commit 877c159

Please sign in to comment.