Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import time # Gecikməni simulyasiya etmək üçün
|
| 3 |
+
|
| 4 |
+
# --- API MƏNTİQİ MÜVƏQQƏTİ SÖNDÜRÜLÜB ---
|
| 5 |
+
# Bu bölmə şəbəkə problemi həll olunana qədər istifadə edilmir.
|
| 6 |
+
# API_URL = "..."
|
| 7 |
+
# headers = {...}
|
| 8 |
+
# def query_llm(...): ...
|
| 9 |
+
# ----------------------------------------------
|
| 10 |
+
|
| 11 |
+
# Bu, bizim AI-dan gəlməsini gözlədiyimiz NÜMUNƏ cavabdır.
|
| 12 |
+
def get_simulated_ai_response():
|
| 13 |
+
fake_json_response = """
|
| 14 |
+
{
|
| 15 |
+
"report_date": "2025-07-31",
|
| 16 |
+
"project_name": "Azure Business Center",
|
| 17 |
+
"weather": "Sunny, 32C",
|
| 18 |
+
"work_summary": "Completed excavation for foundation of Block A. Poured 50 cubic meters of concrete for foundation slab. Installed rebar for columns C1 and C2.",
|
| 19 |
+
"materials_used": "Concrete B25: 50 m3, Rebar Steel A500: 2.5 tons, Diesel Fuel: 150 liters",
|
| 20 |
+
"personnel_count": 21
|
| 21 |
+
}
|
| 22 |
+
"""
|
| 23 |
+
return fake_json_response
|
| 24 |
+
|
| 25 |
+
# Əsas funksiyamız
|
| 26 |
+
def process_document(document):
|
| 27 |
+
if document is None:
|
| 28 |
+
return "⚠️ Please upload a document first."
|
| 29 |
+
|
| 30 |
+
# Faylı oxuyuruq, amma məzmunu heç yerdə istifadə etmirik, çünki cavab simulyasiyadır.
|
| 31 |
+
# Bu, sadəcə interfeysin işlək qalması üçündür.
|
| 32 |
+
|
| 33 |
+
# AI cavabını gözləməyi simulyasiya edirik
|
| 34 |
+
print("Simulating AI response...")
|
| 35 |
+
time.sleep(2) # 2 saniyə gözlə
|
| 36 |
+
|
| 37 |
+
# Simulyasiya edilmiş cavabı alırıq
|
| 38 |
+
generated_text = get_simulated_ai_response()
|
| 39 |
+
|
| 40 |
+
formatted_output = f"## Extracted Information (SIMULATED)\n```json\n{generated_text}\n```"
|
| 41 |
+
return formatted_output
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
# Gradio interfeysi
|
| 45 |
+
iface = gr.Interface(
|
| 46 |
+
fn=process_document,
|
| 47 |
+
inputs=gr.File(label="Upload Construction Daily Report (.txt)"),
|
| 48 |
+
outputs=gr.Markdown(label="Structured Data (JSON)"),
|
| 49 |
+
title="AICONSTRUCT-PM",
|
| 50 |
+
description="An AI-powered assistant that extracts structured data from construction daily reports. (Currently running in OFFLINE SIMULATION MODE due to a network issue).",
|
| 51 |
+
theme=gr.themes.Soft()
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
# Proqramı işə salırıq
|
| 55 |
+
if __name__ == "__main__":
|
| 56 |
+
iface.launch()
|