Spaces:
Sleeping
Sleeping
Create ui_modules.py
Browse files- ui_modules.py +31 -0
ui_modules.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
|
| 3 |
+
def create_ui_layout():
|
| 4 |
+
with gr.Blocks(title="RAG-NER Uzman Sistemi") as demo:
|
| 5 |
+
gr.Markdown("# 🚀 RAG-NER Uzman Karar Destek Sistemi")
|
| 6 |
+
|
| 7 |
+
with gr.Tab("Metin Analizi"):
|
| 8 |
+
input_text = gr.Textbox(label="Analiz Edilecek Metin", lines=3)
|
| 9 |
+
|
| 10 |
+
examples = gr.Examples(
|
| 11 |
+
examples=[["Nuri Bilge Ceylan, Kış Uykusu filmiyle ödül aldı."], ["1984 romanı Apple reklamında kullanıldı."]],
|
| 12 |
+
inputs=input_text
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
with gr.Row():
|
| 16 |
+
log_output = gr.HTML(label="Sistem Günlüğü")
|
| 17 |
+
table_output = gr.Dataframe(
|
| 18 |
+
headers=["Varlık", "İlk", "Nihai", "Kaynak"],
|
| 19 |
+
datatype="markdown"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
submit_btn = gr.Button("Analiz Et", variant="primary")
|
| 23 |
+
|
| 24 |
+
return demo, input_text, log_output, table_output, submit_btn
|
| 25 |
+
|
| 26 |
+
def format_log_entry(type, word, content):
|
| 27 |
+
if type == "wiki":
|
| 28 |
+
return f"<div style='margin-left:20px; border-left:2px solid #007bff; padding-left:10px; color:#555;'>🌐 <b>Wiki [{word}]:</b> {content}</div>"
|
| 29 |
+
if type == "cot":
|
| 30 |
+
return f"<div style='margin-left:20px; border-left:4px solid #28a745; padding-left:10px; background-color:#f8fff8; margin-bottom:10px;'>💡 <b>{word}</b><br><small>{content}</small></div>"
|
| 31 |
+
return f"<div>{content}</div>"
|