vizsum-pro / ui.py
Vartex39's picture
Claude 3 Haiku entegresi, tüm modüller güncellendi, prod-ready
0303b9b
raw
history blame
1.56 kB
import gradio as gr
from ocr_engine import extract_text_from_image
from pdf_reader import extract_text_from_pdf
from summarizer import summarize_text
def process_input(pdf, image, manual_text, mode):
if pdf is not None:
text = extract_text_from_pdf(pdf)
elif image is not None:
text = extract_text_from_image(image)
elif manual_text.strip() != "":
text = manual_text
else:
return "Lütfen bir giriş türü seçin.", ""
if "[ERROR]" in text or "[INFO]" in text:
return text, ""
summary = summarize_text(text, mode)
return text, summary
with gr.Blocks() as demo:
gr.Markdown("## VizSum Pro+: AI Destekli Özetleme Aracı")
with gr.Row():
pdf_input = gr.File(label="PDF Yükle", file_types=[".pdf"])
image_input = gr.Image(type="filepath", label="Görsel Yükle")
manual_input = gr.Textbox(lines=5, label="Metni Manuel Gir")
mode_selector = gr.Dropdown(
choices=["Teknik Özet", "Sade Anlatım", "Eleştir ve Değerlendir", "Başlık Çıkar", "Not Formatı"],
label="Özetleme Modu",
value="Teknik Özet"
)
with gr.Row():
submit_btn = gr.Button("Özetle")
with gr.Row():
text_output = gr.Textbox(label="Giriş Metni")
summary_output = gr.Textbox(label="AI Özeti")
submit_btn.click(
fn=process_input,
inputs=[pdf_input, image_input, manual_input, mode_selector],
outputs=[text_output, summary_output]
)
if __name__ == "__main__":
demo.launch(share=True)