Spaces:
Sleeping
Sleeping
FauziIsyrinApridal
commited on
Commit
·
3de8e98
1
Parent(s):
173e833
revisi 4
Browse files- app.py +1 -1
- app/rag.py +2 -2
- app/session.py +1 -1
app.py
CHANGED
|
@@ -35,7 +35,7 @@ def main():
|
|
| 35 |
initialize_session_state()
|
| 36 |
st.set_page_config(
|
| 37 |
page_title="PNP-Bot",
|
| 38 |
-
page_icon="favicon.ico",
|
| 39 |
)
|
| 40 |
# Try restore Supabase session if user missing
|
| 41 |
restore_user_session_if_needed()
|
|
|
|
| 35 |
initialize_session_state()
|
| 36 |
st.set_page_config(
|
| 37 |
page_title="PNP-Bot",
|
| 38 |
+
page_icon="assets/favicon.ico",
|
| 39 |
)
|
| 40 |
# Try restore Supabase session if user missing
|
| 41 |
restore_user_session_if_needed()
|
app/rag.py
CHANGED
|
@@ -22,14 +22,14 @@ def create_conversational_chain(vector_store):
|
|
| 22 |
model_kwargs={"temperature": 0.1, "top_p": 0.9, "max_new_tokens": 3000}
|
| 23 |
)
|
| 24 |
memory = ConversationBufferWindowMemory(
|
| 25 |
-
k=
|
| 26 |
memory_key="chat_history",
|
| 27 |
return_messages=True,
|
| 28 |
output_key="answer"
|
| 29 |
)
|
| 30 |
chain = ConversationalRetrievalChain.from_llm(
|
| 31 |
llm,
|
| 32 |
-
retriever=vector_store.as_retriever(search_type="mmr", search_kwargs={"k":
|
| 33 |
combine_docs_chain_kwargs={"prompt": sahabat_prompt},
|
| 34 |
return_source_documents=True,
|
| 35 |
memory=memory,
|
|
|
|
| 22 |
model_kwargs={"temperature": 0.1, "top_p": 0.9, "max_new_tokens": 3000}
|
| 23 |
)
|
| 24 |
memory = ConversationBufferWindowMemory(
|
| 25 |
+
k=6,
|
| 26 |
memory_key="chat_history",
|
| 27 |
return_messages=True,
|
| 28 |
output_key="answer"
|
| 29 |
)
|
| 30 |
chain = ConversationalRetrievalChain.from_llm(
|
| 31 |
llm,
|
| 32 |
+
retriever=vector_store.as_retriever(search_type="mmr", search_kwargs={"k": 6, "fetch_k": 20}),
|
| 33 |
combine_docs_chain_kwargs={"prompt": sahabat_prompt},
|
| 34 |
return_source_documents=True,
|
| 35 |
memory=memory,
|
app/session.py
CHANGED
|
@@ -36,7 +36,7 @@ def ensure_active_session(user_id: str):
|
|
| 36 |
sid = create_chat_session(user_id, title="Percakapan Baru")
|
| 37 |
st.session_state["session_id"] = sid
|
| 38 |
try:
|
| 39 |
-
ensure_chat_session(user_id) # make sure exists in DB if missing
|
| 40 |
except Exception:
|
| 41 |
pass
|
| 42 |
return st.session_state["session_id"]
|
|
|
|
| 36 |
sid = create_chat_session(user_id, title="Percakapan Baru")
|
| 37 |
st.session_state["session_id"] = sid
|
| 38 |
try:
|
| 39 |
+
ensure_chat_session(user_id, sid) # make sure exists in DB if missing
|
| 40 |
except Exception:
|
| 41 |
pass
|
| 42 |
return st.session_state["session_id"]
|