Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,21 @@
|
|
1 |
import gradio as gr
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def generate_advice(name, age, income, expenses, savings, debts, investment_preferences, risk_tolerance, retirement_age, retirement_savings_goal, short_term_goals, long_term_goals, dependents, health_expenses, education_expenses, insurance_policies, major_purchases, emergency_fund, annual_income_growth, annual_expense_growth, currency, api_key):
|
5 |
prompt = (
|
|
|
1 |
import gradio as gr
|
2 |
+
import openai
|
3 |
+
|
4 |
+
def financial_planning(prompt, api_key):
|
5 |
+
|
6 |
+
openai.api_key = api_key
|
7 |
+
|
8 |
+
message=[
|
9 |
+
{"role": "system", "content": "You are a knowledgeable and insightful Financial Planner dedicated to assisting users in making well-informed investment decisions. Your goal is to provide personalized financial advice tailored to each user’s unique financial profile, including their income, expenses, savings, debts, investment preferences, risk tolerance, retirement goals, and other relevant financial details. With your expertise, you aim to help users achieve their financial goals, whether it’s planning for retirement, saving for major purchases, or optimizing their investments. Guide them with detailed and practical financial plans that consider both their short-term needs and long-term aspirations."},
|
10 |
+
{"role": "user", "content": prompt}
|
11 |
+
]
|
12 |
+
response = openai.ChatCompletion.create(
|
13 |
+
model="gpt-4o",
|
14 |
+
messages= message,
|
15 |
+
max_tokens=800,
|
16 |
+
temperature=0.7,
|
17 |
+
)
|
18 |
+
return response.choices[0]["message"]["content"]
|
19 |
|
20 |
def generate_advice(name, age, income, expenses, savings, debts, investment_preferences, risk_tolerance, retirement_age, retirement_savings_goal, short_term_goals, long_term_goals, dependents, health_expenses, education_expenses, insurance_policies, major_purchases, emergency_fund, annual_income_growth, annual_expense_growth, currency, api_key):
|
21 |
prompt = (
|