apak commited on
Commit
753da88
·
verified ·
1 Parent(s): cc64dce

Update ui_modules.py

Browse files
Files changed (1) hide show
  1. ui_modules.py +14 -71
ui_modules.py CHANGED
@@ -1,90 +1,33 @@
1
  import gradio as gr
2
 
3
  def format_entity_log(word, wiki, reasoning, new_label):
4
- """
5
- LLM'den gelen analiz sonuçlarını şık bir HTML kart yapısına dönüştürür.
6
- """
7
- # Adımları parçalara ayırarak daha okunaklı hale getirelim
8
  steps = reasoning.split('|')
9
- steps_html = ""
10
-
11
- # Her bir adımı ikonlu ve temiz bir satır olarak biçimlendir
12
- for step in steps:
13
- if step.strip():
14
- steps_html += f"<div style='margin-bottom: 5px; font-size: 0.9em; color: #34495e;'>• {step.strip()}</div>"
15
 
16
  return f"""
17
- <div style="border: 1px solid #e0e0e0; border-radius: 10px; padding: 15px; margin-bottom: 15px; background-color: #ffffff; box-shadow: 2px 2px 5px rgba(0,0,0,0.05);">
18
- <div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid #3498db; padding-bottom: 8px; margin-bottom: 10px;">
19
- <span style="font-weight: bold; font-size: 1.1em; color: #2c3e50;">🔍 Tespit Edilen: {word}</span>
20
- <span style="background-color: #3498db; color: white; padding: 2px 10px; border-radius: 15px; font-size: 0.85em;">{new_label}</span>
21
- </div>
22
-
23
- <div style="background-color: #f8f9fa; border-left: 4px solid #9b59b6; padding: 8px; margin-bottom: 10px; border-radius: 4px;">
24
- <small style="color: #8e44ad; font-weight: bold;">🌐 Wikipedia Özeti:</small>
25
- <p style="margin: 5px 0 0 0; font-size: 0.9em; color: #2c3e50;">{wiki}</p>
26
  </div>
27
-
28
- <div style="background-color: #f0fdf4; border-left: 4px solid #27ae60; padding: 8px; border-radius: 4px;">
29
- <small style="color: #218838; font-weight: bold;">🧠 LLM Karar Mekanizması (CoT):</small>
30
- <div style="margin-top: 5px;">
31
- {steps_html}
32
- </div>
33
  </div>
34
-
35
- <div style="margin-top: 10px; text-align: right;">
36
- <span style="font-size: 0.8em; color: #7f8c8d;">🎯 Yeni Etiket: <b style="color: #e67e22;">{new_label}</b></span>
37
  </div>
38
  </div>
39
  """
40
 
41
  def create_ui_layout():
42
- """
43
- Gradio arayüzünün iskeletini oluşturur.
44
- """
45
- # Tema uyarısını gidermek için temayı burada tanımlıyoruz, ancak launch kısmına taşımıyoruz (Blocks içinde kalabilir ama Divider hatasını siliyoruz)
46
- custom_theme = gr.themes.Soft(primary_hue="orange", secondary_hue="blue")
47
-
48
- with gr.Blocks(theme=custom_theme) as demo:
49
  gr.Markdown("# 🚀 RAG-NER Uzman Karar Destek Sistemi")
50
- gr.Markdown("MISC varlıkları Wikipedia ve LLM muhakemesi ile otomatik olarak yeniden etiketler.")
51
-
52
  with gr.Tab("Metin Analizi"):
53
  with gr.Row():
54
  with gr.Column(scale=2):
55
- input_text = gr.Textbox(
56
- label="Analiz Edilecek Metin",
57
- placeholder="Örn: Antalya Altın Portakal ödülünü Vizontele filmi aldı.",
58
- lines=4
59
- )
60
-
61
- gr.Examples(
62
- examples=[
63
- ["Antalya Altın Portakal ödülünü Vizontele filmi aldı."],
64
- ["Nuri Bilge Ceylan, Kış Uykusu filmiyle Cannes Film Festivali'nde ödül kazandı."],
65
- ["Amerikalı yazar George Orwell'in 1984 romanı, Apple'ın Macintosh reklamına ilham verdi."],
66
- ["Android işletim sistemli bir telefon aldım, içinde Python yüklüydü."]
67
- ],
68
- inputs=input_text,
69
- label="Hazır Senaryolar"
70
- )
71
-
72
- analyze_btn = gr.Button("Analiz Et", variant="primary", size="lg")
73
-
74
  with gr.Column(scale=1):
75
- output_table = gr.Dataframe(
76
- headers=["Varlık", "İlk", "Nihai", "Kaynak"],
77
- datatype=["str", "str", "html", "str"],
78
- label="Analiz Özeti"
79
- )
80
-
81
- # gr.Divider() yerine HTML yatay çizgi kullanıyoruz (Hata buradaydı)
82
- gr.HTML("<hr style='margin: 20px 0; border: 0; border-top: 1px solid #eee;'>")
83
-
84
- with gr.Row():
85
- output_logs = gr.HTML(
86
- label="Detaylı Muhakeme Kartları",
87
- value="<p style='text-align:center; color:gray;'>Analiz sonuçları burada kartlar halinde görünecektir.</p>"
88
- )
89
-
90
  return demo, input_text, output_logs, output_table, analyze_btn
 
1
  import gradio as gr
2
 
3
  def format_entity_log(word, wiki, reasoning, new_label):
 
 
 
 
4
  steps = reasoning.split('|')
5
+ steps_html = "".join([f"<div style='margin-bottom:5px; font-size:0.9em;'>• {s.strip()}</div>" for s in steps if s.strip()])
 
 
 
 
 
6
 
7
  return f"""
8
+ <div style="border: 1px solid #e0e0e0; border-radius: 10px; padding: 15px; margin-bottom: 15px; background: white;">
9
+ <div style="display: flex; justify-content: space-between; border-bottom: 2px solid #3498db; padding-bottom: 5px; margin-bottom: 10px;">
10
+ <b>🔍 {word}</b> <span style="background:#3498db; color:white; padding:2px 8px; border-radius:10px;">{new_label}</span>
 
 
 
 
 
 
11
  </div>
12
+ <div style="background:#f8f9fa; border-left:4px solid #9b59b6; padding:8px; margin-bottom:10px;">
13
+ <small>Wikipedia:</small><p style="margin:0; font-size:0.9em;">{wiki}</p>
 
 
 
 
14
  </div>
15
+ <div style="background:#f0fdf4; border-left:4px solid #27ae60; padding:8px;">
16
+ <small>Muhakeme:</small><div>{steps_html}</div>
 
17
  </div>
18
  </div>
19
  """
20
 
21
  def create_ui_layout():
22
+ with gr.Blocks(theme=gr.themes.Soft(primary_hue="orange")) as demo:
 
 
 
 
 
 
23
  gr.Markdown("# 🚀 RAG-NER Uzman Karar Destek Sistemi")
 
 
24
  with gr.Tab("Metin Analizi"):
25
  with gr.Row():
26
  with gr.Column(scale=2):
27
+ input_text = gr.Textbox(label="Metin", lines=4)
28
+ analyze_btn = gr.Button("Analiz Et", variant="primary")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  with gr.Column(scale=1):
30
+ output_table = gr.Dataframe(headers=["Varlık", "İlk", "Nihai", "Kaynak"], label="Özet")
31
+ gr.HTML("<hr>") # Divider yerine HTML
32
+ output_logs = gr.HTML(label="Detaylar")
 
 
 
 
 
 
 
 
 
 
 
 
33
  return demo, input_text, output_logs, output_table, analyze_btn