File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change @@ -878,6 +878,17 @@ def sciences_educator_endpoint():
878878 return jsonify ({"status" : "success" , "message" : message })
879879
880880
881+ @app .route ('/api/v1/assistance/transaction' , methods = ['POST' ])
882+ @require_api_key
883+ def transaction_assistance_endpoint ():
884+ data = request .get_json ()
885+ prompt = data .get ('prompt' )
886+ if not prompt :
887+ return jsonify ({"error" : _ ("Prompt is required" )}), 400
888+ message = google_ai .provide_transaction_assistance (prompt )
889+ return jsonify ({"status" : "success" , "message" : message })
890+
891+
881892@app .route ('/api/register' , methods = ['POST' ])
882893def register ():
883894 data = request .get_json ()
Original file line number Diff line number Diff line change @@ -423,3 +423,30 @@ def provide_science_education(prompt: str) -> str:
423423 except Exception as e :
424424 print (f"Error providing science education with Vertex AI: { e } " )
425425 return f"Error: { e } "
426+
427+
428+ def provide_transaction_assistance (prompt : str ) -> str :
429+ """
430+ Provides mobile operator, banks, and transactions assistance using Vertex AI.
431+ """
432+ model = GenerativeModel ("gemini-1.5-flash" )
433+
434+ generation_prompt = f"""
435+ You are a helpful assistant for mobile operators, banks, and transactions.
436+ Your task is to provide information and assistance on fraud prevention and transaction facilities.
437+
438+ User Request:
439+ ---
440+ { prompt }
441+ ---
442+
443+ Provide a clear, concise, and helpful response.
444+ """
445+
446+ try :
447+ response = model .generate_content (generation_prompt )
448+ return response .text .strip ()
449+
450+ except Exception as e :
451+ print (f"Error providing transaction assistance with Vertex AI: { e } " )
452+ return f"Error: { e } "
You can’t perform that action at this time.
0 commit comments