Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,21 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
from transformers import pipeline
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
def financial_planning(prompt):
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
10 |
|
11 |
|
12 |
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):
|
|
|
1 |
import gradio as gr
|
2 |
+
import openai
|
3 |
from transformers import pipeline
|
4 |
+
import environ
|
5 |
+
|
6 |
+
env = environ.Env()
|
7 |
+
environ.Env.read_env()
|
8 |
+
API_KEY = env("apikey")
|
9 |
+
openai.api_key = API_KEY
|
10 |
|
11 |
def financial_planning(prompt):
|
12 |
+
response = openai.chat.completions.create(
|
13 |
+
model="gpt-3.5-turbo-16k",
|
14 |
+
messages=prompt,
|
15 |
+
max_tokens=500,
|
16 |
+
temperature=0.7,
|
17 |
+
)
|
18 |
+
return response.choices[0].text.strip()
|
19 |
|
20 |
|
21 |
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):
|