forked from YuvBindal/FinBloom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LLM.py
45 lines (38 loc) · 1.87 KB
/
LLM.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Generative AI approach
import pandas as pd
import google.generativeai as genai
import dotenv
import os
# this should be how the parameter into the function looks like
new_data = pd.DataFrame({
' no_of_dependents': [2],
' education': [1],
' self_employed': [1],
' income_annum': [25000],
' loan_term': [5],
' cibil_score': [700],
' residential_assets_value': [0],
' commercial_assets_value': [25000],
' luxury_assets_value': [0],
' bank_asset_value': [0]
})
# let this sample response stay for prompt guidance
sample_response = {
"predicted_amount": "amount_here",
"predicted_repayment_schedule": {
"Effective_Interest_Rate": 0.1,
"Principal_Amount_SGD": 10000,
"Loan_Maturity_Years": 5,
"Total_Loan_Amount_SGD": 16105.1,
"Installments_Per_Year": 12,
"Installment_Amount": 268.42
}
}
dotenv.load_dotenv()
API_KEY = os.getenv('GEMINI_API_KEY')
def loan_prediction_and_repayment_generation(loan_data):
prompt = f"Given the following data about a business seeking microfinancing (in SGD), where 0/1 in education means not graduate/graduate level education respectively, and similarily 1 for self employed , 0 for not: {loan_data}. Predict an estimated amount of microloan this individual would be eligible for as the first number in your response. Secondly given the loan_terms column (in years). Generate a concise repayment schedule table, particularly the interest and payment intervals. Deduce the individua's credit history from their cibil score, and make ideal assumptions if you need more data. Lastly, your response should be in a JSON format such as this: {sample_response}. Note that the numbers are just samples for your understanding."
genai.configure(api_key=API_KEY)
model = genai.GenerativeModel('gemini-pro')
response = model.generate_content(prompt)
return response.text