Closed GauravatGrowhut closed 5 months ago
🤖
Hello @GauravatGrowhut! 👋
I'm Dosu, a friendly bot designed to help you solve bugs, answer questions, and guide you towards becoming a proficient contributor to our projects. I'm here to assist you while we wait for a human maintainer to join us. If there's anything you need, don't hesitate to ask. Let's make your coding journey smoother together! 😄
The error you're encountering is due to the use of the includes
method in your JSONPath query. The includes
method is not a valid JSONPath operator. JSONPath supports a limited set of operators, which are primarily comparison operators like ==
, !=
, <
, >
, etc.
The query that's causing the issue seems to be $.courses[?(@.courseTags.includes('Computer Science') || @.coursePrerequisites.includes('Bachelor of Technology'))]
. This query is trying to use the includes
method to check if a certain string is included in the courseTags
or coursePrerequisites
arrays.
To fix this issue, you can use the in
operator instead of includes
. Here's how you can modify your query:
$.courses[?(@.courseTags in ['Computer Science'] || @.coursePrerequisites in ['Bachelor of Technology'])]
This query will return all courses where 'Computer Science' is in courseTags
or 'Bachelor of Technology' is in coursePrerequisites
.
Please replace the includes
method with the in
operator in your query and try again. If you continue to face issues, please provide the exact query you're using so I can assist you better.
For more information on JSONPath syntax and operators, you can refer to the JSONPath GitHub page.
Let me know if this helps! If you have any other questions or run into any other issues, feel free to ask.
-Dosu
This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
If you want to continue the conversation, start your reply with @dosu-bot.
Thanks @GauravatGrowhut for filing this bug. Can confirm that I'm able to reproduce the bug based on your provided code. Someone will look into this shortly!
@GauravatGrowhut can you actually provide the specific query that wasn't working for you?
The query I tested that doesn't work involved filtering on an array type. The JSONPath expression that gave it problems was:
$.courses[?(@.courseTags.indexOf('Machine Learning') != -1)].courseName
Hi @nerdai thank you for reply.
instructions = "Provide a list of five courses and all their details along with relevancy score. \
Filter the courses based on the student's interests. Then sort by students fees, and finally their qualifications. \
Rank these courses by their relevance, assigning each a score between 0.0 and 1.0. \
Present this information in a clear and understandable format."
with open("student.json") as student_info:
student = json.load(student_info)
query = f"```\nStudent_Info:```{student}```\nInstruction: {instructions}"
student.json
{
"UserID": "abcd-1234",
"Demographic": {
"Name": "John Doe",
"Age": 22,
"Address": {
"city": "Nagpur",
"state": "Maharashtra",
"country": "India"
},
"UID": "IN-XYZ123"
},
"Qualifications": {
"Work Experience": [
{
"Company": "XYZ",
"Role": "Software Developer",
"Duration": "1 year",
"Description": "Worked on developing and maintaining web applications."
}
],
"Academics": [
{
"degree": "10th Standard",
"board": "CBSE",
"percentage": 85,
"year_of_passing": 2017
},
{
"degree": "12th Standard",
"board": "CBSE",
"percentage": 90,
"year_of_passing": 2019
},
{
"degree": "Bachelor of Technology",
"major": "Computer Science",
"university": "XYZ University",
"GPA": 8.5,
"year_of_passing": 2023
}
],
"Certifications": [{"Name": "AWS Cybersecurity Expert"}],
"Interests":["Cybersecurity"],
"Max_Fees": "$20,000",
"Research Papers": [
{
"Title": "Machine Learning in Healthcare",
"Published In": "XYZ Journal",
"Year": 2023
}
]
}
}
It is also important to mention the code given in docs works for me. Even after I replace the example dictionaries and queries with mine.
It is also important to mention the code given in docs works for me. Even after I replace the example dictionaries and queries with mine.
Oh you mean that your query and your data work when replacing example jsons/queries with your own? You just experience a bug when you don't run in the notebook?
Partially true. Example notebook works with my data and a much smaller query (Provide a List of Relevant Data Science Courses). The same doesn't work on my other notebook with complex query.
the failure reason I think is that the query statement generated by the LLM is not guaranteed to be correct, we can't totally expect the query give the expected result.
Hi all, I have the same issue but this time with the official docs from here: https://docs.llamaindex.ai/en/latest/examples/query_engine/json_query_engine.html
When I run it in colab, in the end I get the error:
alueError: Invalid JSON Path: JSONPath: $.comments[?(@.username=='jerry')].content
Bug Description
Dependencies:
Code:
Version
0.9.39
Steps to Reproduce
Run Above Code With Following JSON:
test.json
schema.json
Relevant Logs/Tracbacks