mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-10-24 09:25:21 +08:00
fix(web): correct monitoring empty states and Space request headers
This commit is contained in:
@@ -24,12 +24,21 @@ def parse_iso_datetime(datetime_str: str | None) -> datetime.datetime | None:
|
||||
return dt
|
||||
|
||||
|
||||
def validate_monitoring_window(start_time: datetime.datetime | None, end_time: datetime.datetime | None) -> None:
|
||||
def validate_monitoring_window(
|
||||
start_time: datetime.datetime | None,
|
||||
end_time: datetime.datetime | None,
|
||||
*,
|
||||
allow_point_window: bool = False,
|
||||
) -> None:
|
||||
"""Bound explicit dashboard windows to one year without silently truncating them."""
|
||||
if start_time is None:
|
||||
return
|
||||
end = end_time or datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None)
|
||||
if start_time >= end or end - start_time > datetime.timedelta(days=365):
|
||||
if (
|
||||
start_time > end
|
||||
or (start_time == end and not allow_point_window)
|
||||
or end - start_time > datetime.timedelta(days=365)
|
||||
):
|
||||
quart.abort(400, description='Monitoring time range must be positive and no longer than 365 days')
|
||||
|
||||
|
||||
@@ -580,7 +589,8 @@ class MonitoringRouterGroup(group.RouterGroup):
|
||||
"""Get detailed analysis for a specific session"""
|
||||
start_time = parse_iso_datetime(quart.request.args.get('startTime'))
|
||||
end_time = parse_iso_datetime(quart.request.args.get('endTime'))
|
||||
validate_monitoring_window(start_time, end_time)
|
||||
# Message pages can contain one timestamp; tool-call bounds are inclusive.
|
||||
validate_monitoring_window(start_time, end_time, allow_point_window=True)
|
||||
analysis = await self.ap.monitoring_service.get_session_analysis(
|
||||
request_context,
|
||||
session_id,
|
||||
|
||||
Reference in New Issue
Block a user