Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -6,16 +6,20 @@ def financial_planning(prompt, api_key):
|
|
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=
|
16 |
temperature=0.7,
|
|
|
17 |
)
|
18 |
-
|
|
|
|
|
|
|
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 = (
|
|
|
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. Do not include Formulas and limit to max 600 tokens."},
|
10 |
{"role": "user", "content": prompt}
|
11 |
]
|
12 |
response = openai.ChatCompletion.create(
|
13 |
model="gpt-4o",
|
14 |
messages= message,
|
15 |
+
max_tokens=1000,
|
16 |
temperature=0.7,
|
17 |
+
stream =True
|
18 |
)
|
19 |
+
for chunk in response:
|
20 |
+
stream = chunk.choices[0].delta.content
|
21 |
+
yield stream
|
22 |
+
yield stream
|
23 |
|
24 |
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):
|
25 |
prompt = (
|