Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,8 +13,8 @@ from huggingface_hub import snapshot_download, hf_hub_download
|
|
| 13 |
|
| 14 |
# from prompts import CONDENSE_QUESTION_PROMPT
|
| 15 |
|
| 16 |
-
repo_name = "IlyaGusev/
|
| 17 |
-
model_name = "model-
|
| 18 |
|
| 19 |
#snapshot_download(repo_id=repo_name, local_dir=".", allow_patterns=model_name)
|
| 20 |
|
|
@@ -50,17 +50,17 @@ def get_vectorstore(text_chunks):
|
|
| 50 |
|
| 51 |
|
| 52 |
def get_conversation_chain(vectorstore, model_name):
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
llm = ChatOpenAI()
|
| 64 |
|
| 65 |
memory = ConversationBufferMemory(memory_key='chat_history', input_key='question', output_key='answer', return_messages=True)
|
| 66 |
|
|
@@ -68,7 +68,7 @@ def get_conversation_chain(vectorstore, model_name):
|
|
| 68 |
# condense_question_prompt=CONDENSE_QUESTION_PROMPT,
|
| 69 |
retriever=vectorstore.as_retriever(),
|
| 70 |
memory=memory,
|
| 71 |
-
|
| 72 |
)
|
| 73 |
|
| 74 |
return conversation_chain
|
|
@@ -79,9 +79,12 @@ def handle_userinput(user_question):
|
|
| 79 |
|
| 80 |
st.session_state.chat_history = response['chat_history']
|
| 81 |
|
| 82 |
-
|
| 83 |
|
| 84 |
-
|
|
|
|
|
|
|
|
|
|
| 85 |
|
| 86 |
for i, message in enumerate(st.session_state.chat_history):
|
| 87 |
if i % 2 == 0:
|
|
|
|
| 13 |
|
| 14 |
# from prompts import CONDENSE_QUESTION_PROMPT
|
| 15 |
|
| 16 |
+
repo_name = "IlyaGusev/saiga2_7b_gguf"
|
| 17 |
+
model_name = "model-q2_K.gguf"
|
| 18 |
|
| 19 |
#snapshot_download(repo_id=repo_name, local_dir=".", allow_patterns=model_name)
|
| 20 |
|
|
|
|
| 50 |
|
| 51 |
|
| 52 |
def get_conversation_chain(vectorstore, model_name):
|
| 53 |
+
llm = LlamaCpp(model_path=model_name,
|
| 54 |
+
temperature=0.1,
|
| 55 |
+
top_k=30,
|
| 56 |
+
top_p=0.9,
|
| 57 |
+
streaming=True,
|
| 58 |
+
n_ctx=2048,
|
| 59 |
+
n_parts=1,
|
| 60 |
+
echo=True
|
| 61 |
+
)
|
| 62 |
+
|
| 63 |
+
#llm = ChatOpenAI()
|
| 64 |
|
| 65 |
memory = ConversationBufferMemory(memory_key='chat_history', input_key='question', output_key='answer', return_messages=True)
|
| 66 |
|
|
|
|
| 68 |
# condense_question_prompt=CONDENSE_QUESTION_PROMPT,
|
| 69 |
retriever=vectorstore.as_retriever(),
|
| 70 |
memory=memory,
|
| 71 |
+
return_source_documents=True
|
| 72 |
)
|
| 73 |
|
| 74 |
return conversation_chain
|
|
|
|
| 79 |
|
| 80 |
st.session_state.chat_history = response['chat_history']
|
| 81 |
|
| 82 |
+
st.session_state.retrieved_text = response['source_documents']
|
| 83 |
|
| 84 |
+
for n in enumerate(st.session_state.retrieved_text):
|
| 85 |
+
st.write(response['source_documents'][n])
|
| 86 |
+
|
| 87 |
+
print(response['source_documents'][0])
|
| 88 |
|
| 89 |
for i, message in enumerate(st.session_state.chat_history):
|
| 90 |
if i % 2 == 0:
|