Ilia Tambovtsev commited on
Commit
8dae32e
·
1 Parent(s): 1603571

refactor: parameterize formatting of output

Browse files
Files changed (1) hide show
  1. src/webapp/app.py +5 -8
src/webapp/app.py CHANGED
@@ -18,7 +18,9 @@ logger = logging.getLogger(__name__)
18
 
19
 
20
  def format_page_results(result_page: SearchResultPage) -> str:
21
- """Format individual slide results as markdown text"""
 
 
22
  chunks = result_page.slide_chunks
23
 
24
  text = dedent(
@@ -29,11 +31,6 @@ def format_page_results(result_page: SearchResultPage) -> str:
29
  """
30
  )
31
 
32
- # chunk_distances_str = ""
33
- # for chunk_type, distance in result_page.chunk_distances.items():
34
- # distance_str = f"{distance:.4f}" if distance else "`not matched`"
35
- # chunk_distances_str += f"{chunk_type}: {distance_str}\\\n"
36
-
37
  chunk_df = (
38
  pd.DataFrame(result_page.chunk_distances, index=["distance"])
39
  .T.assign(
@@ -62,9 +59,9 @@ def format_page_results(result_page: SearchResultPage) -> str:
62
 
63
 
64
  def format_presentation_results(
65
- pres_result: SearchResultPresentation, n_pages: Optional[int] = None
66
  ) -> str:
67
- """Format single presentation results"""
68
  # Get best matching page
69
  best_slide = pres_result.best_slide
70
  pdf_path = Path(best_slide.pdf_path)
 
18
 
19
 
20
  def format_page_results(result_page: SearchResultPage) -> str:
21
+ """Format individual slide results as markdown
22
+ text specifically for the webapp.
23
+ """
24
  chunks = result_page.slide_chunks
25
 
26
  text = dedent(
 
31
  """
32
  )
33
 
 
 
 
 
 
34
  chunk_df = (
35
  pd.DataFrame(result_page.chunk_distances, index=["distance"])
36
  .T.assign(
 
59
 
60
 
61
  def format_presentation_results(
62
+ pres_result: SearchResultPresentation, n_pages: Optional[int] = None
63
  ) -> str:
64
+ """Format single presentation results specifically for the webapp"""
65
  # Get best matching page
66
  best_slide = pres_result.best_slide
67
  pdf_path = Path(best_slide.pdf_path)