feersdilaa commited on
Commit
41bc2ba
·
verified ·
1 Parent(s): 4dfb0dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -26
app.py CHANGED
@@ -1,32 +1,20 @@
1
  import gradio as gr
2
  from rag_engine import NewsLegalAnalyzer
3
 
4
- def analyze_news(text):
5
- return "Hasil analisis untuk: " + text[:50] + "..."
6
 
7
- # CSS tetap di definisikan di atas
8
- css = """
9
- body {max-width: 1600px; margin: auto;}
10
- .gradio-container {max-width: 1600px !important;}
11
- """
12
 
13
- # 1. Hapus 'theme' dan 'css' dari gr.Blocks()
14
- with gr.Blocks() as demo:
15
- gr.Markdown("# 📰 News Legal Analyzer")
16
-
17
- with gr.Row():
18
- input_box = gr.Textbox(lines=14, label="Masukkan Teks Berita", scale=1)
19
-
20
- with gr.Row():
21
- output_box = gr.Textbox(lines=20, label="Hasil Analisis", scale=1)
22
 
23
- analyze_button = gr.Button("Analisis")
24
-
25
- analyze_button.click(analyze_news, inputs=[input_box], outputs=[output_box])
26
-
27
- # 2. Tambahkan 'theme' dan 'css' ke demo.launch()
28
- demo.launch(
29
- inline=False,
30
- theme="gradio/soft", # Parameter dipindahkan ke sini
31
- css=css # Parameter dipindahkan ke sini
32
- )
 
1
  import gradio as gr
2
  from rag_engine import NewsLegalAnalyzer
3
 
4
+ analyzer = NewsLegalAnalyzer()
5
+ analyzer.initialize()
6
 
7
+ def analyze_news(news):
8
+ if len(news) < 50:
9
+ return "Berita terlalu pendek."
10
+ return analyzer.analyze(news)
 
11
 
12
+ demo = gr.Interface(
13
+ fn=analyze_news,
14
+ inputs=gr.Textbox(label="Masukkan Berita", lines=10),
15
+ outputs=gr.Textbox(label="Hasil Analisis", lines=20),
16
+ title="AI RAG Hukum – Qwen + Gemini",
17
+ description="Masukkan berita dan sistem RAG akan mencari pasal hukum paling relevan."
18
+ )
 
 
19
 
20
+ demo.launch()