afortuny commited on
Commit
95fdd2d
·
1 Parent(s): 490534e

better layout 5

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -33,10 +33,16 @@ def find_matching_notes(uploaded_file, user_input):
33
  # Get the top 5 indices of the most similar entries
34
  top_indices = cosine_similarities[0].argsort()[-5:][::-1]
35
 
36
- # Prepare the results as a DataFrame for better display
37
  results = df.iloc[top_indices][['Notes', 'Source', 'Section']]
 
38
 
39
- return results
 
 
 
 
 
40
 
41
  return "Please upload a valid CSV file."
42
 
@@ -47,7 +53,7 @@ iface = gr.Interface(
47
  gr.File(label="Upload Research Notes (CSV)"),
48
  gr.Textbox(label="Enter your text here", placeholder="Type your content...")
49
  ],
50
- outputs=gr.Dataframe(label="Top 5 Matching Entries"),
51
  title="Research Notes Matcher",
52
  description="Upload a CSV file with 'Source', 'Section', and 'Notes'. Enter your text to find the top 5 matching notes."
53
  )
@@ -56,3 +62,4 @@ iface = gr.Interface(
56
  iface.launch()
57
 
58
 
 
 
33
  # Get the top 5 indices of the most similar entries
34
  top_indices = cosine_similarities[0].argsort()[-5:][::-1]
35
 
36
+ # Prepare the results
37
  results = df.iloc[top_indices][['Notes', 'Source', 'Section']]
38
+ results_list = results.values.tolist()
39
 
40
+ # Format output for display
41
+ formatted_results = []
42
+ for row in results_list:
43
+ formatted_results.append(f"**Notes:** {row[0]}\n**Source:** {row[1]}\n**Section:** {row[2]}\n")
44
+
45
+ return "\n".join(formatted_results)
46
 
47
  return "Please upload a valid CSV file."
48
 
 
53
  gr.File(label="Upload Research Notes (CSV)"),
54
  gr.Textbox(label="Enter your text here", placeholder="Type your content...")
55
  ],
56
+ outputs=gr.Textbox(label="Top 5 Matching Entries", lines=10, placeholder="Results will be displayed here..."),
57
  title="Research Notes Matcher",
58
  description="Upload a CSV file with 'Source', 'Section', and 'Notes'. Enter your text to find the top 5 matching notes."
59
  )
 
62
  iface.launch()
63
 
64
 
65
+