Skip to content

Commit 750d72a

Browse files
authored
Merge pull request #38 from GYFX35/feat/add-transaction-assistance-role-2778677707815491656
Feat: Add Transaction Assistance Role
2 parents 9e54b2a + b282765 commit 750d72a

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

app.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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'])
882893
def register():
883894
data = request.get_json()

google_ai.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff 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}"

0 commit comments

Comments
 (0)