From d5efd2c13f1646ec40fe711c057c8d7401f70a2f Mon Sep 17 00:00:00 2001 From: Tim Li Date: Mon, 30 Dec 2024 00:50:39 -0800 Subject: [PATCH] fix first page only parsing issue --- fastchat/serve/gradio_block_arena_vision.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/fastchat/serve/gradio_block_arena_vision.py b/fastchat/serve/gradio_block_arena_vision.py index 09139a2ec..c6c6c0393 100644 --- a/fastchat/serve/gradio_block_arena_vision.py +++ b/fastchat/serve/gradio_block_arena_vision.py @@ -215,8 +215,7 @@ def wrap_pdfchat_query(query, document): document_context = f""" The following is the content of a document: {document} - Based on this document, answer the following question: - {query} + Based on this document, answer the user query. """ reformatted_query_context = ( @@ -236,13 +235,13 @@ def parse_pdf(file_path): assert ( "LLAMA_CLOUD_API_KEY" in os.environ ), "Make sure to specify LlamaParse API key." - document = LlamaParse( + documents = LlamaParse( result_type="markdown", verbose=True, ).load_data(file_path) - - assert len(document) > 0 - output = document[0].text + + assert len(documents) > 0 + output = "\n".join([doc.text for doc in documents]) return output