langchain-ai / langchain

🦜🔗 Build context-aware reasoning applications
https://python.langchain.com
MIT License
92.38k stars 14.77k forks source link

StructuredQueryOutputParser throws an error when the contains date and time #25526

Open MohammedShokr opened 1 month ago

MohammedShokr commented 1 month ago

Checked other resources

Example Code

``

Error Message and Stack Trace (if applicable)

langchain_core.exceptions.OutputParserException: Parsing text
json
{
    "query": "What are the articles created at August 6, 2024, at 07:30?",
    "filter": "and(eq('created_at_datetime', '2024-08-06T07:30:00Z'))"
}

 raised following error:
Unexpected token Token('CNAME', 'T07') at line 1, column 38.
Expected one of: 
        * COMMA
        * RPAR
Previous tokens: [Token('DATE', "'2024-08-06")

Description

System Info

System Information

OS: Linux OS Version: #45~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 15 16:40:02 UTC 2 Python Version: 3.11.6 (main, Oct 4 2023, 18:31:23) [GCC 11.4.0]

Package Information

langchain_core: 0.2.0 langchain: 0.2.0 langchain_community: 0.2.0 langsmith: 0.1.60 langchain_openai: 0.1.7 langchain_text_splitters: 0.2.0 langchain_weaviate: 0.0.2 langserve: 0.2.2

Packages not installed (Not Necessarily a Problem)

The following packages were not found:

langgraph

gbaian10 commented 3 weeks ago

Can you provide a minimal reproducible example?

MohammedShokr commented 3 weeks ago

Sure @gbaian10 , here's a notebook with minimal reproducible example and the error message testing_selfquery.zip

venkatram-dev commented 3 weeks ago

Created this PR to fix parser errors https://github.com/langchain-ai/langchain/pull/25763