mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-17 18:23:59 +00:00
IMPROVEMENT self-query template (#13305)
- [ ] https://github.com/langchain-ai/langchain/pull/12694#discussion_r1391334719 -> keep date - [x] https://github.com/langchain-ai/langchain/pull/12694#discussion_r1391336586
This commit is contained in:
parent
b46f88d364
commit
50a5c919f0
@ -1,4 +1,5 @@
|
||||
import datetime
|
||||
import warnings
|
||||
from typing import Any, Literal, Optional, Sequence, Union
|
||||
|
||||
from typing_extensions import TypedDict
|
||||
@ -55,6 +56,8 @@ GRAMMAR = r"""
|
||||
|
||||
|
||||
class ISO8601Date(TypedDict):
|
||||
"""A date in ISO 8601 format (YYYY-MM-DD)."""
|
||||
|
||||
date: str
|
||||
type: Literal["date"]
|
||||
|
||||
@ -140,11 +143,11 @@ class QueryTransformer(Transformer):
|
||||
item = str(item).strip("\"'")
|
||||
try:
|
||||
datetime.datetime.strptime(item, "%Y-%m-%d")
|
||||
except ValueError as e:
|
||||
raise ValueError(
|
||||
except ValueError:
|
||||
warnings.warn(
|
||||
"Dates are expected to be provided in ISO 8601 date format "
|
||||
"(YYYY-MM-DD)."
|
||||
) from e
|
||||
)
|
||||
return {"date": item, "type": "date"}
|
||||
|
||||
def string(self, item: Any) -> str:
|
||||
|
Loading…
Reference in New Issue
Block a user