Update app.py
Browse files
app.py
CHANGED
@@ -192,20 +192,30 @@ def compare_embeddings(file, query, model_types, model_names, split_strategy, ch
|
|
192 |
return all_results + all_stats
|
193 |
|
194 |
def format_results(results, stats):
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
205 |
formatted_stats = pd.DataFrame([stats])
|
206 |
|
207 |
return df, formatted_stats
|
208 |
|
|
|
209 |
# Gradio interface
|
210 |
iface = gr.Interface(
|
211 |
fn=compare_embeddings,
|
|
|
192 |
return all_results + all_stats
|
193 |
|
194 |
def format_results(results, stats):
|
195 |
+
# List to store the processed document data
|
196 |
+
data = []
|
197 |
+
|
198 |
+
# Extracting content and metadata from each document
|
199 |
+
for doc in results:
|
200 |
+
# Ensure metadata is a dictionary (if it's a custom object, convert it)
|
201 |
+
metadata_dict = dict(doc.metadata)
|
202 |
+
|
203 |
+
# Create a combined dictionary with 'Content' and all metadata fields
|
204 |
+
doc_data = {"Content": doc.page_content}
|
205 |
+
doc_data.update(metadata_dict) # Add all metadata key-value pairs
|
206 |
+
|
207 |
+
# Append the processed document data to the list
|
208 |
+
data.append(doc_data)
|
209 |
+
|
210 |
+
# Convert the list of document data into a DataFrame
|
211 |
+
df = pd.DataFrame(data)
|
212 |
+
|
213 |
+
# Formatting stats as a DataFrame
|
214 |
formatted_stats = pd.DataFrame([stats])
|
215 |
|
216 |
return df, formatted_stats
|
217 |
|
218 |
+
|
219 |
# Gradio interface
|
220 |
iface = gr.Interface(
|
221 |
fn=compare_embeddings,
|