zayeem00 commited on
Commit
50bfa03
1 Parent(s): c6c6535

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -5
app.py CHANGED
@@ -1,12 +1,21 @@
1
  import gradio as gr
 
2
  from transformers import pipeline
 
 
 
 
 
 
3
 
4
  def financial_planning(prompt):
5
- messages = [
6
- {"role": "system", "content": "You are a financial advisor who guides users on their investment plan!"},
7
- {"role": "user", "content": {prompt}}]
8
- chatbot = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.3")
9
- return chatbot(messages)
 
 
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):