forked from AI_team/Philosophy-RAG-demo
Shows PDF to the side with a nice link
This commit is contained in:
parent
47f574390e
commit
79c1450730
@ -127,12 +127,9 @@ async def add_sources(chainlit_response: cl.Message, pdf_sources: dict, web_sour
|
|||||||
if len(pdf_sources) > 0:
|
if len(pdf_sources) > 0:
|
||||||
await chainlit_response.stream_token("\n\nThe following PDF source were consulted:\n")
|
await chainlit_response.stream_token("\n\nThe following PDF source were consulted:\n")
|
||||||
for source, page_numbers in pdf_sources.items():
|
for source, page_numbers in pdf_sources.items():
|
||||||
page_numbers = list(page_numbers)
|
filename = Path(source).name
|
||||||
page_numbers.sort()
|
await chainlit_response.stream_token(f"- {filename} on page(s): {sorted(page_numbers)}\n")
|
||||||
# display="side" seems to be not supported by chainlit for PDF's, so we use "inline" instead.
|
chainlit_response.elements.append(cl.Pdf(name=filename, display="side", path=source, page=sorted(page_numbers)[0]))
|
||||||
chainlit_response.elements.append(cl.Pdf(name="pdf", display="inline", path=source, page=page_numbers[0]))
|
|
||||||
await chainlit_response.update()
|
|
||||||
await chainlit_response.stream_token(f"- '{source}' on page(s): {page_numbers}\n")
|
|
||||||
|
|
||||||
if len(web_sources) > 0:
|
if len(web_sources) > 0:
|
||||||
await chainlit_response.stream_token("\n\nThe following web sources were consulted:\n")
|
await chainlit_response.stream_token("\n\nThe following web sources were consulted:\n")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user