Vartex39 commited on
Commit
3c1d21c
·
1 Parent(s): 138dc70

Add: Claude-only restriction for table summaries

Browse files
Files changed (1) hide show
  1. ui.py +7 -4
ui.py CHANGED
@@ -4,8 +4,9 @@ from ocr_engine import extract_text_from_image
4
  from pdf_reader import extract_text_chunks_from_pdf
5
  from summarizer import summarize_text
6
 
7
- def process_input(pdf, image, manual_text, mode, model_name, start_page, end_page, lang_mode):
8
-
 
9
  if pdf is not None:
10
  text_chunks = extract_text_chunks_from_pdf(pdf, start=int(start_page), end=int(end_page))
11
  if any("[ERROR]" in chunk for chunk in text_chunks):
@@ -24,7 +25,7 @@ def process_input(pdf, image, manual_text, mode, model_name, start_page, end_pag
24
  summaries = []
25
 
26
  for chunk in text_chunks:
27
- summary = summarize_text(chunk, mode, model_name, lang_mode)
28
  summaries.append(summary)
29
 
30
  full_summary = "\n\n".join(summaries)
@@ -104,10 +105,12 @@ with gr.Blocks() as demo:
104
  label="Dil Algılama / Çeviri Modu",
105
  value="Otomatik"
106
  )
 
 
107
 
108
  submit_btn.click(
109
  fn=process_input,
110
- inputs=[pdf_input, image_input, manual_input, mode_selector, model_selector, start_page, end_page, lang_mode],
111
  outputs=[text_output, summary_output, summary_file]
112
  )
113
 
 
4
  from pdf_reader import extract_text_chunks_from_pdf
5
  from summarizer import summarize_text
6
 
7
+ def process_input(pdf, image, manual_text, mode, model_name, start_page, end_page, lang_mode, is_table):
8
+ if is_table and model_name != "anthropic/claude-3-haiku":
9
+ return "Tablo içeriği için yalnızca Claude önerilir.","",None
10
  if pdf is not None:
11
  text_chunks = extract_text_chunks_from_pdf(pdf, start=int(start_page), end=int(end_page))
12
  if any("[ERROR]" in chunk for chunk in text_chunks):
 
25
  summaries = []
26
 
27
  for chunk in text_chunks:
28
+ summary = summarize_text(chunk, mode, model_name, lang_mode, is_table)
29
  summaries.append(summary)
30
 
31
  full_summary = "\n\n".join(summaries)
 
105
  label="Dil Algılama / Çeviri Modu",
106
  value="Otomatik"
107
  )
108
+
109
+ is_table = gr.Checkbox(label="Tablo içeriyor (Claude tablo gibi özetlesin)", value=False)
110
 
111
  submit_btn.click(
112
  fn=process_input,
113
+ inputs=[pdf_input, image_input, manual_input, mode_selector, model_selector, start_page, end_page, lang_mode, is_table],
114
  outputs=[text_output, summary_output, summary_file]
115
  )
116