Update app.py
Browse files
app.py
CHANGED
@@ -17,7 +17,7 @@ from langchain_community.document_loaders.directory import DirectoryLoader
|
|
17 |
from langchain_core.output_parsers import StrOutputParser
|
18 |
from langchain_core.runnables import RunnablePassthrough
|
19 |
from langchain_experimental.chat_models import Llama2Chat
|
20 |
-
|
21 |
|
22 |
lang_api_key = os.getenv("lang_api_key")
|
23 |
|
@@ -160,7 +160,7 @@ def create_conversational_rag_chain(retriever):
|
|
160 |
|
161 |
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
162 |
|
163 |
-
llm =
|
164 |
model_path = "qwen2-0_5b-instruct-q8_0.gguf",
|
165 |
seed = 41,
|
166 |
n_gpu_layers=0,
|
@@ -174,9 +174,7 @@ def create_conversational_rag_chain(retriever):
|
|
174 |
verbose=False,
|
175 |
)
|
176 |
|
177 |
-
|
178 |
-
llm=llm,
|
179 |
-
)
|
180 |
|
181 |
template = """Answer the question, based only on the following context:
|
182 |
{context}. Be consise.
|
@@ -188,7 +186,7 @@ def create_conversational_rag_chain(retriever):
|
|
188 |
|
189 |
|
190 |
|
191 |
-
rag_chain = prompt |
|
192 |
|
193 |
|
194 |
return rag_chain
|
|
|
17 |
from langchain_core.output_parsers import StrOutputParser
|
18 |
from langchain_core.runnables import RunnablePassthrough
|
19 |
from langchain_experimental.chat_models import Llama2Chat
|
20 |
+
from langchain_community.chat_models.llamacpp import ChatLlamaCpp
|
21 |
|
22 |
lang_api_key = os.getenv("lang_api_key")
|
23 |
|
|
|
160 |
|
161 |
callback_manager = CallbackManager([StreamingStdOutCallbackHandler()])
|
162 |
|
163 |
+
llm = ChatLlamaCpp(
|
164 |
model_path = "qwen2-0_5b-instruct-q8_0.gguf",
|
165 |
seed = 41,
|
166 |
n_gpu_layers=0,
|
|
|
174 |
verbose=False,
|
175 |
)
|
176 |
|
177 |
+
|
|
|
|
|
178 |
|
179 |
template = """Answer the question, based only on the following context:
|
180 |
{context}. Be consise.
|
|
|
186 |
|
187 |
|
188 |
|
189 |
+
rag_chain = prompt | llm | StrOutputParser()
|
190 |
|
191 |
|
192 |
return rag_chain
|