Closed darthShana closed 1 week ago
🤖
Hey @darthShana, great to see you back! Running into a bit of a snag, huh? Let's see what we can do about that.
From the error message you provided, it seems like the issue is with the filter query syntax. The error message indicates that the parser is not expecting a comma (',') at the position where it is found.
The filter query you're using is:
"or(eq(\"vehicle_type\", \"Hatchback\"), eq(\"vehicle_type\", \"Sedan\")), in(\"location\", [\"Westgate\", \"North Shore\", \"Otahuhu\", \"Penrose\", \"Botany\", \"Manukau\"])"
The error might be due to the misplaced comma (',') after the or
function. The or
function takes multiple arguments and combines them using the logical OR operator. The arguments should be separated by commas (',') and enclosed in parentheses ('()'). The in
function should be one of the arguments of the or
function, not a separate function call.
Here's how the filter query should look like:
"or(eq(\"vehicle_type\", \"Hatchback\"), eq(\"vehicle_type\", \"Sedan\"), in(\"location\", [\"Westgate\", \"North Shore\", \"Otahuhu\", \"Penrose\", \"Botany\", \"Manukau\"]))"
This filter query checks if the vehicle_type
is either "Hatchback" or "Sedan" and if the location
is in the list ["Westgate", "North Shore", "Otahuhu", "Penrose", "Botany", "Manukau"].
Please try updating your filter query and let me know if the issue persists. If it does, it would be helpful if you could provide more information about the query_constructor
and structured_query_translator
you're using with the SelfQueryRetriever
. These components are responsible for generating and translating the filter query, so the issue might be with their implementation.
For more information about the expected syntax for the filter query, you can refer to the LangChain documentation and the source code of the SelfQueryRetriever
class in the LangChain repository.
hi.. so two things
i don't agree with your logical assessment of the query if This filter query checks if the vehicle_type is either "Hatchback" or "Sedan" and if the location is in the list ["Westgate", "North Shore", "Otahuhu", "Penrose", "Botany", "Manukau"]. then the query should be and( or( eq(\"vehicle_type\", \"Hatchback\"), eq(\"vehicle_type\", \"Sedan\") ), in(\"location\", [\"Westgate\", \"North Shore\", \"Otahuhu\", \"Penrose\", \"Botany\", \"Manukau\"]) )" note () specifying the operators to which the or operator should apply
As im using a SelfQueryRetriver i didnt write this query. Should'nt the langchain prompts be asking the llm to construct the query in the correct syntax? btw im using model="gpt-4-turbo-preview"
hi.. so two things
- i don't agree with your logical assessment of the query if This filter query checks if the vehicle_type is either "Hatchback" or "Sedan" and if the location is in the list ["Westgate", "North Shore", "Otahuhu", "Penrose", "Botany", "Manukau"]. then the query should be and( or( eq("vehicle_type", "Hatchback"), eq("vehicle_type", "Sedan") ), in("location", ["Westgate", "North Shore", "Otahuhu", "Penrose", "Botany", "Manukau"]) )" note () specifying the operators to which the or operator should apply
- As im using a SelfQueryRetriver i didnt write this query. Should'nt the langchain prompts be asking the llm to construct the query in the correct syntax? btw im using model="gpt-4-turbo-preview"
Hello brother, I have encountered the same problem. Have you resolved it
Checked other resources
Example Code
Im using a standard SelfQueryRetriver to extract relevant documents (car listings) that match a user query. Its has been working pretty well but recently it started giving me errors (stack trace attached). ise
retriever = SelfQueryRetriever.from_llm( llm, vectordb, document_content_description, metadata_field_info, verbose=True )
Error Message and Stack Trace (if applicable)
OutputParserException('Parsing text\n
json\n{\n "query": "with bluetooth and a reversing camera recent",\n "filter": "or(eq(\\"vehicle_type\\", \\"Hatchback\\"), eq(\\"vehicle_type\\", \\"Sedan\\")), in(\\"location\\", [\\"Westgate\\", \\"North Shore\\", \\"Otahuhu\\", \\"Penrose\\", \\"Botany\\", \\"Manukau\\"])"\n}\n
\n raised following error:\nUnexpected token Token(\'COMMA\', \',\') at line 1, column 65.\nExpected one of: \n\t* $END\n')Traceback (most recent call last):File "/home/dharshana/.local/share/virtualenvs/tina-virtual-assistant-eLldwkZS/lib/python3.11/site-packages/lark/parsers/lalr_parser_state.py", line 77, in feed_token action, arg = states[state][token.type]