add source printing
Browse files
langchain-streamlit-demo/app.py
CHANGED
@@ -463,7 +463,7 @@ if st.session_state.llm:
|
|
463 |
# ],
|
464 |
# )
|
465 |
|
466 |
-
full_response: Union[str, None] = None
|
467 |
|
468 |
message_placeholder = st.empty()
|
469 |
sources_placeholder = st.empty()
|
@@ -530,10 +530,11 @@ if st.session_state.llm:
|
|
530 |
input_str,
|
531 |
config=get_config(callbacks),
|
532 |
)
|
533 |
-
st.session_state.sources = response["source_documents"]
|
534 |
with st.sidebar.expander("Sources"):
|
535 |
-
for source in st.session_state.sources:
|
536 |
st.markdown("-" * 50)
|
|
|
537 |
st.markdown(source.page_content)
|
538 |
# with sources_placeholder:
|
539 |
# with st.expander("Sources", expanded=False):
|
@@ -604,14 +605,15 @@ if st.session_state.llm:
|
|
604 |
full_response["output_text"],
|
605 |
full_response["source_documents"],
|
606 |
)
|
607 |
-
st.session_state.sources = sources
|
608 |
message_placeholder.markdown(
|
609 |
text_response + "\n\n" + f"⏱️ {finish_time:.2f}s"
|
610 |
)
|
611 |
with sources_placeholder:
|
612 |
with st.expander("Sources", expanded=False):
|
613 |
-
for source in st.session_state.sources:
|
614 |
st.markdown("-" * 50)
|
|
|
615 |
st.markdown(source.page_content)
|
616 |
|
617 |
# --- Tracing ---
|
|
|
463 |
# ],
|
464 |
# )
|
465 |
|
466 |
+
full_response: Union[str, dict[str, Any], None] = None
|
467 |
|
468 |
message_placeholder = st.empty()
|
469 |
sources_placeholder = st.empty()
|
|
|
530 |
input_str,
|
531 |
config=get_config(callbacks),
|
532 |
)
|
533 |
+
st.session_state.sources = response["source_documents"]
|
534 |
with st.sidebar.expander("Sources"):
|
535 |
+
for e, source in enumerate(st.session_state.sources):
|
536 |
st.markdown("-" * 50)
|
537 |
+
st.markdown(f"## Source {e+1}")
|
538 |
st.markdown(source.page_content)
|
539 |
# with sources_placeholder:
|
540 |
# with st.expander("Sources", expanded=False):
|
|
|
605 |
full_response["output_text"],
|
606 |
full_response["source_documents"],
|
607 |
)
|
608 |
+
st.session_state.sources = sources
|
609 |
message_placeholder.markdown(
|
610 |
text_response + "\n\n" + f"⏱️ {finish_time:.2f}s"
|
611 |
)
|
612 |
with sources_placeholder:
|
613 |
with st.expander("Sources", expanded=False):
|
614 |
+
for e, source in enumerate(st.session_state.sources):
|
615 |
st.markdown("-" * 50)
|
616 |
+
st.markdown(f"## Source {e+1}")
|
617 |
st.markdown(source.page_content)
|
618 |
|
619 |
# --- Tracing ---
|
langchain-streamlit-demo/defaults.py
CHANGED
@@ -48,7 +48,7 @@ DEFAULT_LANGSMITH_PROJECT = os.environ.get("LANGCHAIN_PROJECT")
|
|
48 |
|
49 |
TEST_QUESTIONS = [
|
50 |
"Come posso ottenerle le credenziali di accesso all'area riservata?",
|
51 |
-
"Quali prestazioni presenti nel checkup?",
|
52 |
"La risonanza magnetica è coperta dalla polizza?",
|
53 |
"Le visite odontoiatriche sono coperte dalla polizza?",
|
54 |
"Come posso richiedere il checkup?",
|
|
|
48 |
|
49 |
TEST_QUESTIONS = [
|
50 |
"Come posso ottenerle le credenziali di accesso all'area riservata?",
|
51 |
+
"Quali prestazioni sono presenti nel checkup?",
|
52 |
"La risonanza magnetica è coperta dalla polizza?",
|
53 |
"Le visite odontoiatriche sono coperte dalla polizza?",
|
54 |
"Come posso richiedere il checkup?",
|