File size: 2,263 Bytes
cc21f11
196ae1d
cc21f11
 
 
 
940be83
cc21f11
 
 
 
 
 
 
196ae1d
cc21f11
196ae1d
 
cc21f11
940be83
196ae1d
 
 
 
 
 
cc21f11
 
795049f
cc21f11
 
0303b9b
 
cc21f11
0303b9b
cc21f11
 
96bc60c
 
 
 
 
 
 
 
 
 
 
 
cc21f11
940be83
 
 
 
 
 
 
 
 
 
cc21f11
 
 
 
0303b9b
55f43e1
31ecf39
196ae1d
cc21f11
 
 
e997719
196ae1d
cc21f11
245e92a
55f43e1
cc21f11
 
0303b9b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import gradio as gr
import tempfile  # Bu satır eksikti
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, model_name):
    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.", "", None

    if "[ERROR]" in text:
        return text, "", None

    summary = summarize_text(text, mode, model_name)

    temp_file = tempfile.NamedTemporaryFile(delete=False, suffix=".txt", mode='w', encoding='utf-8')
    temp_file.write(summary)
    temp_file.close()

    return text, summary, temp_file.name

with gr.Blocks() as demo:
    gr.Markdown("## VizSum")

    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ı",
        "Karma Özet"  # 🔥 Yeni mod
    ],
    label="Özetleme Modu",
    value="Teknik Özet"
)


    model_selector = gr.Dropdown(
        choices=[
            "anthropic/claude-3-haiku",
            "openai/gpt-3.5-turbo",
            "mistralai/mistral-7b-instruct"
        ],
        label="Dil Modeli",
        value="anthropic/claude-3-haiku"
    )

    with gr.Row():
        submit_btn = gr.Button("Özetle")

    with gr.Row():
        text_output = gr.Textbox(label="Giriş Metni")
        copy_status = gr.Textbox(visible=False)
        summary_output = gr.Textbox(label="AI Özeti", lines=10, show_copy_button=True)
        summary_file = gr.File(label="Özeti İndir", interactive=True)

    submit_btn.click(
        fn=process_input,
        inputs=[pdf_input, image_input, manual_input, mode_selector, model_selector],
        outputs=[text_output, summary_output, summary_file]
    )



if __name__ == "__main__":
    demo.launch(share=True)