Files
wehub-resource-sync 9201ef759e
Harness Compat / harness compat (push) Failing after 0s
CI / test on 3.12 (standard) (push) Has been cancelled
CI / test on 3.13 (standard) (push) Has been cancelled
CI / test on 3.14 (standard) (push) Has been cancelled
CI / test on 3.10 (all-extras) (push) Has been cancelled
CI / test on 3.11 (all-extras) (push) Has been cancelled
CI / test on 3.12 (all-extras) (push) Has been cancelled
CI / test on 3.14 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.10 (pydantic-evals) (push) Has been cancelled
CI / test on 3.11 (pydantic-evals) (push) Has been cancelled
CI / test on 3.12 (pydantic-evals) (push) Has been cancelled
CI / deploy-docs-preview (push) Has been cancelled
CI / build release artifacts (push) Has been cancelled
CI / publish to PyPI (push) Has been cancelled
CI / Send tweet (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / mypy (push) Has been cancelled
CI / docs (push) Has been cancelled
CI / test on 3.10 (standard) (push) Has been cancelled
CI / test on 3.11 (standard) (push) Has been cancelled
CI / test on 3.13 (all-extras) (push) Has been cancelled
CI / test on 3.14 (all-extras) (push) Has been cancelled
CI / test on 3.10 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.11 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.12 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.13 (pydantic-ai-slim) (push) Has been cancelled
CI / test on 3.13 (pydantic-evals) (push) Has been cancelled
CI / test on 3.14 (pydantic-evals) (push) Has been cancelled
CI / test on 3.10 (lowest-versions) (push) Has been cancelled
CI / test on 3.11 (lowest-versions) (push) Has been cancelled
CI / test on 3.12 (lowest-versions) (push) Has been cancelled
CI / test on 3.13 (lowest-versions) (push) Has been cancelled
CI / test on 3.14 (lowest-versions) (push) Has been cancelled
CI / test examples on 3.11 (push) Has been cancelled
CI / test examples on 3.12 (push) Has been cancelled
CI / test examples on 3.13 (push) Has been cancelled
CI / test examples on 3.14 (push) Has been cancelled
CI / coverage (push) Has been cancelled
CI / check (push) Has been cancelled
CI / deploy-docs (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:27:52 +08:00

58 lines
1.7 KiB
Python

from __future__ import annotations as _annotations
from pydantic import AwareDatetime, BaseModel
from typing_extensions import TypedDict
class TimeRangeBuilderSuccess(BaseModel, use_attribute_docstrings=True):
"""Response when a time range could be successfully generated."""
min_timestamp_with_offset: AwareDatetime
"""A datetime in ISO format with timezone offset."""
max_timestamp_with_offset: AwareDatetime
"""A datetime in ISO format with timezone offset."""
explanation: str | None
"""
A brief explanation of the time range that was selected.
For example, if a user only mentions a specific point in time, you might explain that you selected a 10 minute
window around that time.
"""
def __str__(self):
readable_min_timestamp = self.min_timestamp_with_offset.strftime(
'%A, %B %d, %Y %H:%M:%S %Z'
)
readable_max_timestamp = self.max_timestamp_with_offset.strftime(
'%A, %B %d, %Y %H:%M:%S %Z'
)
lines = [
'TimeRangeBuilderSuccess:',
f'* min_timestamp_with_offset: {readable_min_timestamp}',
f'* max_timestamp_with_offset: {readable_max_timestamp}',
]
if self.explanation is not None:
lines.append(f'* explanation: {self.explanation}')
return '\n'.join(lines)
class TimeRangeBuilderError(BaseModel):
"""Response when a time range cannot not be generated."""
error_message: str
def __str__(self):
return f'TimeRangeBuilderError:\n* {self.error_message}'
TimeRangeResponse = TimeRangeBuilderSuccess | TimeRangeBuilderError
class TimeRangeInputs(TypedDict):
"""The inputs for the time range inference agent."""
prompt: str
now: AwareDatetime