BinduRP commited on
Commit
303f724
·
verified ·
1 Parent(s): 32ae303

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -34,21 +34,20 @@ client = genai.Client(api_key=os.environ.get('GOOGLE_API_KEY'))
34
  # Use gemini-1.5-flash for the best free-tier stability
35
  STABLE_MODEL = "gemini-flash-latest"
36
 
37
- # --- Data Preparation ---
38
  df_credit = pd.DataFrame({'ID': [1111, 2222, 3333, 4444, 5555], 'Credit_Score': [455, 685, 825, 840, 350]})
39
  df_account = pd.DataFrame({
40
  'ID': [1111, 2222, 3333, 4444, 5555],
41
  'Name': ['Loren', 'Matt', 'Hilda', 'Andy', 'Kit'],
42
- 'Status': ['good-standing', 'closed', 'delinquent', 'good-standing', 'delinquent'],
43
  'Nationality': ['Singaporean', 'NonSingaporean', 'Singaporean', 'NonSingaporean', 'Singaporean']
44
  })
45
  df_gov = pd.DataFrame({'ID': [2222, 4444], 'PR_Status': [True, False]})
46
  df_merged = df_account.merge(df_credit, on="ID").merge(df_gov, on="ID", how="left").fillna(False)
47
 
48
- # --- Upload Policies once on startup ---
49
- # These files MUST be in the same folder as app.py in Hugging Face
50
- risk_policy = client.files.upload(file="Bank Loan Overall Risk Policy.pdf")
51
- rate_policy = client.files.upload(file="Bank Loan Interest Rate Policy.pdf")
52
 
53
  # 4. Standardized Assessment Logic
54
  def process_loan_request(applicant_id, customer_name_optional):
@@ -114,12 +113,12 @@ def process_loan_request(applicant_id, customer_name_optional):
114
  except Exception as e:
115
  return f"System Error: {str(e)}"
116
 
117
- # --- Gradio Interface ---
118
  demo = gr.Interface(
119
- fn=process_loan,
120
  inputs=[gr.Textbox(label="Applicant ID"), gr.Textbox(label="Name (Optional)")],
121
  outputs=gr.Markdown(),
122
- title="🏦 Loan Risk Assessment Tool"
123
  )
124
 
125
  if __name__ == "__main__":
 
34
  # Use gemini-1.5-flash for the best free-tier stability
35
  STABLE_MODEL = "gemini-flash-latest"
36
 
37
+ # 2. Data Preparation (Structured Systems)
38
  df_credit = pd.DataFrame({'ID': [1111, 2222, 3333, 4444, 5555], 'Credit_Score': [455, 685, 825, 840, 350]})
39
  df_account = pd.DataFrame({
40
  'ID': [1111, 2222, 3333, 4444, 5555],
41
  'Name': ['Loren', 'Matt', 'Hilda', 'Andy', 'Kit'],
42
+ 'Status': ['Good-standing', 'Closed', 'Delinquent', 'Good-standing', 'Delinquent'],
43
  'Nationality': ['Singaporean', 'NonSingaporean', 'Singaporean', 'NonSingaporean', 'Singaporean']
44
  })
45
  df_gov = pd.DataFrame({'ID': [2222, 4444], 'PR_Status': [True, False]})
46
  df_merged = df_account.merge(df_credit, on="ID").merge(df_gov, on="ID", how="left").fillna(False)
47
 
48
+ # 3. Upload Policy Files once on startup
49
+ risk_policy_file = client.files.upload(file="Bank Loan Overall Risk Policy.pdf")
50
+ interest_policy_file = client.files.upload(file="Bank Loan Interest Rate Policy.pdf")
 
51
 
52
  # 4. Standardized Assessment Logic
53
  def process_loan_request(applicant_id, customer_name_optional):
 
113
  except Exception as e:
114
  return f"System Error: {str(e)}"
115
 
116
+ # 5. Launch Gradio Interface
117
  demo = gr.Interface(
118
+ fn=process_loan_request,
119
  inputs=[gr.Textbox(label="Applicant ID"), gr.Textbox(label="Name (Optional)")],
120
  outputs=gr.Markdown(),
121
+ title="🏦 Enterprise AI Loan Underwriter"
122
  )
123
 
124
  if __name__ == "__main__":