- Introduced `pending_trade` handling in the chat API to manage trade requests more effectively. - Updated the `submit_trade_api` to allow advisors to access customer trades based on assigned roles. - Added new methods in `GatewayRepository` for managing core holdings during trade subscriptions and redemptions. - Implemented context-aware trade dialogue management in the customer service layer to improve user experience during multi-turn interactions. - Enhanced the tool service to support trade actions and suitability checks, ensuring accurate processing of user requests. This update significantly improves the trade interaction flow, providing a more robust and user-friendly experience for customers engaging in trading activities.
54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
import sys
|
|
from sqlalchemy import text
|
|
from app.utils.db import get_engine
|
|
from app.config.settings import settings
|
|
from app.config.database import get_redis_client
|
|
|
|
sid = sys.argv[1] if len(sys.argv) > 1 else "sess-b5a2dcd1110"
|
|
eng = get_engine(settings.mysql_database, "rw")
|
|
with eng.connect() as c:
|
|
print("=== agent_session ===")
|
|
for row in c.execute(
|
|
text("SELECT session_id, customer_id, status, updated_at FROM agent_session WHERE session_id=:s"),
|
|
{"s": sid},
|
|
):
|
|
print(row)
|
|
print("=== agent_message (last 20) ===")
|
|
rows = c.execute(
|
|
text(
|
|
"SELECT seq_no, role, intent, LEFT(content, 1200) "
|
|
"FROM agent_message WHERE session_id=:s ORDER BY seq_no DESC LIMIT 20"
|
|
),
|
|
{"s": sid},
|
|
).fetchall()
|
|
for row in reversed(rows):
|
|
print("\n---", row[0], row[1], row[2], "---\n", row[3])
|
|
print("=== audit_log (last 15) ===")
|
|
try:
|
|
audits = c.execute(
|
|
text(
|
|
"SELECT id, created_at, event_type, path, status_code, "
|
|
"LEFT(COALESCE(payload,''), 800) "
|
|
"FROM audit_log WHERE session_id=:s ORDER BY id DESC LIMIT 15"
|
|
),
|
|
{"s": sid},
|
|
).fetchall()
|
|
for a in audits:
|
|
print(a)
|
|
except Exception as e:
|
|
print("audit err", e)
|
|
|
|
r = get_redis_client()
|
|
for key in (f"customer:{sid}:consult", f"customer:{sid}:chitchat", f"customer:{sid}:trade_flow"):
|
|
print("=== redis", key, "===")
|
|
try:
|
|
if key.endswith("trade_flow"):
|
|
v = r.get(key)
|
|
print(v)
|
|
else:
|
|
items = r.lrange(key, 0, -1)
|
|
for raw in items[-6:]:
|
|
print(raw[:1500])
|
|
except Exception as e:
|
|
print(e)
|