Corin1998 commited on
Commit
b2c5e98
·
verified ·
1 Parent(s): a29650c

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +33 -7
app.py CHANGED
@@ -36,13 +36,39 @@ BASE_RATE = float(os.environ.get("BASE_RATE", "2.0")) # % per annum, configu
36
 
37
 
38
  def _load_policies() -> dict:
39
- cfg_path = os.path.join(os.path.dirname(__file__), "config", "risk_policies.yaml")
40
- with open(cfg_path, "r", encoding="utf-8") as f:
41
- return yaml.safe_load(f)
42
-
43
-
44
- POLICIES = _load_policies()
45
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
 
47
  def analyze(files: List[gr.File], company_name: str, industry_hint: str, currency_hint: str,
48
  base_rate: float, want_credit: bool, want_loan: bool, want_invest: bool, debug: bool):
 
36
 
37
 
38
  def _load_policies() -> dict:
39
+ import yaml, os
40
+ default_yaml = """\
41
+ liquidity:
42
+ current_ratio_good: 2.0
43
+ current_ratio_ok: 1.5
44
+ leverage:
45
+ debt_to_equity_good: 0.5
46
+ debt_to_equity_ok: 1.0
47
+ coverage:
48
+ interest_coverage_good: 6.0
49
+ interest_coverage_ok: 3.0
50
+ profitability:
51
+ net_margin_good: 0.1
52
+ net_margin_ok: 0.03
53
+ growth:
54
+ revenue_growth_high: 0.2
55
+ revenue_growth_ok: 0.05
56
+ """
57
+ cfg_dir = os.path.join(os.path.dirname(__file__), "config")
58
+ cfg_path = os.path.join(cfg_dir, "risk_policies.yaml")
59
+ default = yaml.safe_load(default_yaml)
60
+ try:
61
+ with open(cfg_path, "r", encoding="utf-8") as f:
62
+ data = yaml.safe_load(f) or {}
63
+ # ユーザー定義があれば default に上書き
64
+ if isinstance(data, dict):
65
+ default.update(data)
66
+ return default
67
+ except FileNotFoundError:
68
+ os.makedirs(cfg_dir, exist_ok=True)
69
+ with open(cfg_path, "w", encoding="utf-8") as f:
70
+ f.write(default_yaml)
71
+ return default
72
 
73
  def analyze(files: List[gr.File], company_name: str, industry_hint: str, currency_hint: str,
74
  base_rate: float, want_credit: bool, want_loan: bool, want_invest: bool, debug: bool):