Update app.py
Browse files
app.py
CHANGED
|
@@ -98,17 +98,13 @@ def summarize_pdf_with_tooltips(_pdf_file_path, num_clusters=10):
|
|
| 98 |
2. Main methodologies used
|
| 99 |
3. Important data points
|
| 100 |
4. Limitations mentioned
|
| 101 |
-
|
| 102 |
For any information directly derived from the context excerpts provided below, insert an in-text citation as an HTML tooltip.
|
| 103 |
For each citation, use the following HTML format:
|
| 104 |
<span class="tooltip" data-tooltip="{full_text}">[{n}]</span>
|
| 105 |
-
|
| 106 |
Where:
|
| 107 |
- {n} is the citation number.
|
| 108 |
- {full_text} is the complete excerpt text for that citation.
|
| 109 |
-
|
| 110 |
Do not provide a separate reference list. Instead, embed the full citation text directly in the tooltip.
|
| 111 |
-
|
| 112 |
Context Excerpts:
|
| 113 |
{contexts}"""
|
| 114 |
)
|
|
@@ -150,7 +146,7 @@ Context Excerpts:
|
|
| 150 |
@handle_errors
|
| 151 |
def qa_pdf(_pdf_file_path, query, num_clusters=5):
|
| 152 |
embeddings_model = OpenAIEmbeddings(model="text-embedding-3-small", api_key=openai_api_key)
|
| 153 |
-
llm = ChatOpenAI(model="gpt-
|
| 154 |
|
| 155 |
prompt = ChatPromptTemplate.from_template(
|
| 156 |
"""Answer this question: {question}
|
|
@@ -190,7 +186,7 @@ def process_pdf(_pdf_file_path):
|
|
| 190 |
scale_factor = 300 / 50 # High-res to low-res ratio
|
| 191 |
|
| 192 |
for page in doc:
|
| 193 |
-
low_res = page.get_pixmap(dpi=
|
| 194 |
low_res_img = np.frombuffer(low_res.samples, dtype=np.uint8).reshape(low_res.height, low_res.width, 3)
|
| 195 |
|
| 196 |
results = model.predict(low_res_img)
|
|
@@ -378,4 +374,4 @@ st.markdown("""
|
|
| 378 |
width: 300px; /* Adjust width as needed */
|
| 379 |
}
|
| 380 |
</style>
|
| 381 |
-
""", unsafe_allow_html=True)
|
|
|
|
| 98 |
2. Main methodologies used
|
| 99 |
3. Important data points
|
| 100 |
4. Limitations mentioned
|
|
|
|
| 101 |
For any information directly derived from the context excerpts provided below, insert an in-text citation as an HTML tooltip.
|
| 102 |
For each citation, use the following HTML format:
|
| 103 |
<span class="tooltip" data-tooltip="{full_text}">[{n}]</span>
|
|
|
|
| 104 |
Where:
|
| 105 |
- {n} is the citation number.
|
| 106 |
- {full_text} is the complete excerpt text for that citation.
|
|
|
|
| 107 |
Do not provide a separate reference list. Instead, embed the full citation text directly in the tooltip.
|
|
|
|
| 108 |
Context Excerpts:
|
| 109 |
{contexts}"""
|
| 110 |
)
|
|
|
|
| 146 |
@handle_errors
|
| 147 |
def qa_pdf(_pdf_file_path, query, num_clusters=5):
|
| 148 |
embeddings_model = OpenAIEmbeddings(model="text-embedding-3-small", api_key=openai_api_key)
|
| 149 |
+
llm = ChatOpenAI(model="gpt-4", api_key=openai_api_key, temperature=0.3)
|
| 150 |
|
| 151 |
prompt = ChatPromptTemplate.from_template(
|
| 152 |
"""Answer this question: {question}
|
|
|
|
| 186 |
scale_factor = 300 / 50 # High-res to low-res ratio
|
| 187 |
|
| 188 |
for page in doc:
|
| 189 |
+
low_res = page.get_pixmap(dpi=50)
|
| 190 |
low_res_img = np.frombuffer(low_res.samples, dtype=np.uint8).reshape(low_res.height, low_res.width, 3)
|
| 191 |
|
| 192 |
results = model.predict(low_res_img)
|
|
|
|
| 374 |
width: 300px; /* Adjust width as needed */
|
| 375 |
}
|
| 376 |
</style>
|
| 377 |
+
""", unsafe_allow_html=True)
|