improved money movement scenario

This commit is contained in:
Joshua Smith
2025-03-27 09:24:44 -04:00
parent a3ec7b045a
commit 64f8a34d19
3 changed files with 45 additions and 29 deletions

View File

@@ -43,3 +43,8 @@ GOAL_CATEGORIES=hr,travel,fin # default is all
# Set if the UI should force a user confirmation step or not
SHOW_CONFIRM=True
# Money Scenarios:
# Set if you want it to really start workflows - otherwise it'll fake it
# if you want it to be real you'll need moneytransfer and early return workers running
FIN_START_REAL_WORKFLOW=FALSE

View File

@@ -1,7 +1,7 @@
# todo list
[ ] try claude-3-7-sonnet-20250219, see [tool_activities.py](./activities/tool_activities.py) <br />
[x] make agent respond to name of goals and not just numbers <br />
[ ] josh to do fintech scenarios <br />
[x] josh to do fintech scenarios <br />
[ ] expand [tests](./tests/agent_goal_workflow_test.py)<br />
[ ] fintech goals <br />
@@ -9,7 +9,7 @@
- Personalized Financial Advice - An AI agent analyzes a customers financial data (e.g., income, spending habits, savings, investments) and provides tailored advice, such as budgeting tips, investment options, or debt repayment strategies.<br />
- Portfolio Management and Rebalancing - The AI monitors a customers investment portfolio, rebalancing it automatically based on market trends, risk tolerance, and financial goals (e.g., shifting assets between stocks, bonds, or crypto).<br />
[x] money movement - start money transfer <br />
[ ] todo use env vars to do connect to local or non-local
[x] todo use env vars to do connect to local or non-local
[x] account balance - <br />
[ ] new loan/fraud check/update with start <br />
@@ -24,4 +24,4 @@
[ ] change initial goal selection prompt to list capabilities and prompt more nicely - not a bulleted list - see how that works
[ ] todo use env vars to do connect to local or non-local cloud for activities for money scenarios
[x] todo use env vars to do connect to local or non-local cloud for activities for money scenarios

View File

@@ -1,3 +1,4 @@
import os
from pathlib import Path
import json
from temporalio.client import Client
@@ -5,6 +6,8 @@ from dataclasses import dataclass
from typing import Optional
import asyncio
from temporalio.exceptions import WorkflowAlreadyStartedError
from shared.config import get_temporal_client
from enum import Enum, auto
@@ -45,9 +48,10 @@ async def move_money(args: dict) -> dict:
for account in account_list:
if account["email"] == account_key or account["account_id"] == account_key:
amount_str: str = str(amount)
amount_str: str = str(amount) # LLM+python gets sassy about types but we need it to be str
from_account_combo = account_key + account_type
transfer_workflow_id = await start_workflow(amount_cents=str_dollars_to_cents(amount_str),from_account_name=account_key, to_account_name=destinationaccount)
transfer_workflow_id = await start_workflow(amount_cents=str_dollars_to_cents(amount_str),from_account_name=from_account_combo, to_account_name=destinationaccount)
account_type_key = 'checking_balance'
if(account_type.casefold() == "checking" ):
@@ -66,7 +70,7 @@ async def move_money(args: dict) -> dict:
with open(file_path, 'w') as file:
json.dump(data, file, indent=4)
return {'status': "money movement complete", 'confirmation id': transfer_workflow_id, 'new_balance': account["checking_balance"]}
return {'status': "money movement complete", 'confirmation id': transfer_workflow_id, 'new_balance': account[account_type_key]}
return_msg = "Account not found with for " + account_key
return {"error": return_msg}
@@ -76,12 +80,19 @@ async def start_workflow(amount_cents: int, from_account_name: str, to_account_n
# Connect to Temporal
# todo use env vars to do connect to local or non-local
client:Client = await Client.connect("localhost:7233")
client = await get_temporal_client()
start_real_workflow = os.getenv("FIN_START_REAL_WORKFLOW")
if start_real_workflow is not None and start_real_workflow.lower() == "false":
START_REAL_WORKFLOW = False
else:
START_REAL_WORKFLOW = True
if START_REAL_WORKFLOW:
# Create the parameter object
params = MoneyMovementWorkflowParameterObj(
amount=amount_cents*100,
amount=amount_cents,
scenario="HAPPY_PATH"
)
@@ -98,8 +109,8 @@ async def start_workflow(amount_cents: int, from_account_name: str, to_account_n
except WorkflowAlreadyStartedError as e:
existing_handle = client.get_workflow_handle(workflow_id=workflow_id)
return existing_handle.id
else:
return "TRANSFER-ACCT-" + from_account_name + "-TO-" + to_account_name + "not-real"
#cleans a string dollar amount description to cents value