File tree Expand file tree Collapse file tree 2 files changed +27
-7
lines changed
Expand file tree Collapse file tree 2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change @@ -432,12 +432,6 @@ def get_data():
432432"""
433433 return response_message .strip ()
434434
435- def get_financial_advice (prompt ):
436- advice = _ ("Based on your query, here is some general financial advice: diversify your investments and create a budget." )
437- # In a real application, this would involve more sophisticated logic,
438- # possibly integrating with financial data APIs or a fine-tuned LLM.
439- return advice
440-
441435def generate_art_criticism (prompt ):
442436 criticism = _ ("This is a placeholder for an art criticism based on your prompt: %(prompt)s" , prompt = prompt )
443437 # In a real application, this would connect to a generative AI model
@@ -749,7 +743,7 @@ def financial_advice_endpoint():
749743 prompt = data .get ('prompt' )
750744 if not prompt :
751745 return jsonify ({"error" : _ ("Prompt is required" )}), 400
752- message = get_financial_advice (prompt )
746+ message = google_ai . provide_financial_advice (prompt )
753747 return jsonify ({"status" : "success" , "message" : message })
754748
755749@app .route ('/api/v1/art/criticism' , methods = ['POST' ])
Original file line number Diff line number Diff line change @@ -214,3 +214,29 @@ def analyze_data(prompt: str) -> str:
214214 except Exception as e :
215215 print (f"Error analyzing data with Vertex AI: { e } " )
216216 return f"Error: { e } "
217+
218+
219+ def provide_financial_advice (prompt : str ) -> str :
220+ """
221+ Provides financial advice for a given issue using Vertex AI.
222+ """
223+ model = GenerativeModel ("gemini-1.5-flash" )
224+
225+ generation_prompt = f"""
226+ You are an expert financial advisor. Your task is to provide financial advice based on the following user prompt.
227+
228+ User Prompt:
229+ ---
230+ { prompt }
231+ ---
232+
233+ The advice should be comprehensive and include actionable steps.
234+ """
235+
236+ try :
237+ response = model .generate_content (generation_prompt )
238+ return response .text .strip ()
239+
240+ except Exception as e :
241+ print (f"Error providing financial advice with Vertex AI: { e } " )
242+ return f"Error: { e } "
You can’t perform that action at this time.
0 commit comments