Spaces:
Sleeping

Corin1998 commited on
Commit
9ef0cc0
·
verified ·
1 Parent(s): 3619f7b

Delete ui/dash.py

Browse files
Files changed (1) hide show
  1. ui/dash.py +0 -83
ui/dash.py DELETED
@@ -1,83 +0,0 @@
1
- # ui/dash.py
2
- from __future__ import annotations
3
- import gradio as gr
4
- import pandas as pd
5
- from app.core.utils import ensure_file
6
- from app.services.pipeline import run_full_pipeline
7
- from app.core.policies import INDUSTRY_BENCH
8
- from app.scoring import make_summary
9
-
10
- INDUSTRY_OPTIONS = list(INDUSTRY_BENCH.keys()) + ["その他/未選択"]
11
-
12
- def _theme():
13
- return gr.themes.Soft(radius_size="8px", text_size="sm").set(
14
- body_text_color="#111",
15
- block_title_text_color="#111",
16
- background_fill_primary="#f7f8fa",
17
- block_background_fill="#ffffff",
18
- )
19
-
20
- def _bars(scores: dict) -> pd.DataFrame:
21
- rows = [
22
- ("与信", scores["credit"]["score"]),
23
- ("融資", scores["lending"]["score"]),
24
- ("投資", scores["investment"]["score"]),
25
- ("AI", scores["ai"]["ai_total"]),
26
- ("外部(財務)", scores["external"]["external_total"]),
27
- ("ハイブリッド", scores["hybrid"]["hybrid_total"]),
28
- ]
29
- return pd.DataFrame(rows, columns=["項目","スコア(0-100)"])
30
-
31
- def build_interface() -> gr.Blocks:
32
- with gr.Blocks(theme=_theme(), css="""
33
- .bar-row td{padding:6px 8px;}
34
- """) as demo:
35
- gr.Markdown("## 企業スコア(PDF 読込→財務→与信/融資/投資/AI)")
36
-
37
- with gr.Row():
38
- pdf = gr.File(label="決算書PDF", file_types=[".pdf"])
39
- unit = gr.Radio(["自動","円","千円","百万円","億円"], value="自動", label="単位")
40
- c_name = gr.Textbox(label="会社名(任意)")
41
- industry = gr.Dropdown(choices=INDUSTRY_OPTIONS, value="その他/未選択", label="業界(比較用)")
42
- products = gr.Textbox(label="主要プロダクト/事業(AI用、任意)")
43
-
44
- run_btn = gr.Button("解析してスコアリング", variant="primary")
45
- gr.Markdown("### スコア概要(バー)")
46
-
47
- bars = gr.Dataframe(headers=["項目","スコア(0-100)"], interactive=False, wrap=True, elem_classes=["bar-row"])
48
- summary = gr.Markdown("")
49
-
50
- with gr.Row():
51
- fin_tbl = gr.Dataframe(label="財務(抽出値)", interactive=False, wrap=True)
52
- ratio_tbl = gr.Dataframe(label="財務分析(主要)", interactive=False, wrap=True)
53
- kpi_tbl = gr.Dataframe(label="KPI(人員効率など)", interactive=False, wrap=True)
54
-
55
- with gr.Accordion("詳細(与信/融資/投資/AI/外部のJSON)", open=False):
56
- dbg = gr.JSON()
57
-
58
- def _run(pdf_file, unit_sel, c, ind, prod):
59
- path = ensure_file(pdf_file)
60
- u = None if unit_sel=="自動" else unit_sel
61
- out = run_full_pipeline(path, unit_hint=u, company_name=c or "", industry=ind or "", products=prod or "")
62
- df_fin = out["financials"].reset_index()
63
- df_fin.columns = ["科目","値"]
64
- df_rat = out["ratios"].reset_index()
65
- df_rat.columns = ["指標","値"]
66
- df_kpi = out["kpis"].reset_index()
67
- df_kpi.columns = ["KPI","値"]
68
-
69
- s = out["scores"]
70
- bar_df = _bars(s)
71
- summ = make_summary(c or "対象企業", s["external"], s["ai"], s["hybrid"])
72
- return bar_df, summ, df_fin, df_rat, df_kpi, s
73
-
74
- run_btn.click(_run, [pdf, unit, c_name, industry, products], [bars, summary, fin_tbl, ratio_tbl, kpi_tbl, dbg])
75
-
76
- with gr.Accordion("起動診断", open=False):
77
- import sys, pkgutil
78
- env = {
79
- "python": sys.version,
80
- "packages": sorted([m.name for m in pkgutil.iter_modules() if m.name.startswith(("gradio","uvicorn","fastapi","pdf","pandas","openai"))]),
81
- }
82
- gr.JSON(env, label="環境")
83
- return demo