mirror of
https://github.com/escalante29/WealthySmart.git
synced 2026-07-17 10:08:46 +02:00
Log client details for API and agent requests
This commit is contained in:
@@ -41,7 +41,14 @@ def _last_user_prompt(messages: list[dict[str, Any]]) -> str | None:
|
||||
|
||||
|
||||
def create_chat_run(
|
||||
*, request_id: str, agui_run_id: str | None, thread_id: str | None, messages: list[dict[str, Any]]
|
||||
*,
|
||||
request_id: str,
|
||||
agui_run_id: str | None,
|
||||
thread_id: str | None,
|
||||
messages: list[dict[str, Any]],
|
||||
client_ip: str | None = None,
|
||||
user_agent: str | None = None,
|
||||
browser: str | None = None,
|
||||
) -> int:
|
||||
now = utcnow()
|
||||
with Session(engine) as session:
|
||||
@@ -50,6 +57,9 @@ def create_chat_run(
|
||||
agui_run_id=agui_run_id,
|
||||
requested_thread_id=thread_id,
|
||||
model=settings.AGENT_MODEL,
|
||||
client_ip=client_ip,
|
||||
user_agent=user_agent,
|
||||
browser=browser,
|
||||
user_prompt=_last_user_prompt(messages),
|
||||
expires_at=now + timedelta(days=CHAT_LOG_RETENTION_DAYS),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user