-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/add json process tool #5555
Feat/add json process tool #5555
Conversation
Please fix the errors in CI, and make sure the commit messages are in English. |
The python and yaml styles have been fixed. |
@Yeuoly I have submitted the requested changes. Please review when you have a moment. Thank you. |
hello, pls rebase to main to fix conflicts. |
…add-json-process-tool
The branch is now up-to-date with the main branch and includes the latest dependency updates. |
@Yeuoly hello, the python style error in /tools/insert.py has been fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thanks for your amazing tools!
Thank you. And I want to ask if I need to resolve conflicts all the time? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* refs/heads/main: Feat/add json process tool (#5555) fix: do not remove (#5682) Feature/add qwen llm (#5659) Fix docker command (#5681) feature: Add presence_penalty and frequency_penalty parameters to the … (#5637) Feat/fix ops trace (#5672) feat: xxo enhancement. (#5671) chore: rearrange python dependencies in groups (#5603) chore: delete unused resource (#5667)
* commit '9513155fa46bc9bd1ed06381c163a831aea57d42': (32 commits) chore: support both $$ and $ latex format (langgenius#5723) Rename README to README.md (langgenius#5727) Chore/set entrypoint scripts permissions (langgenius#5726) add README for new docker/ directory (langgenius#5724) bump to 0.6.12 (langgenius#5712) Ignore new middleware.env docker file (langgenius#5715) fix: _convert_prompt_message_to_dict parameters err (langgenius#5716) fix: fix-app-site-missing command (langgenius#5714) feat: add fix-app-site-missing command (langgenius#5711) add docker-legacy and docker/nginx/conf.d/default.conf to .gitignore (langgenius#5707) fix: do not remove (langgenius#5706) build(deps): bump braces from 3.0.2 to 3.0.3 in /web (langgenius#5705) fix: yarn lock file missing (langgenius#5703) feat: add support Spark4.0 (langgenius#5688) Correction of Typo in French (langgenius#5699) Chore/improve deployment flow (langgenius#4299) feat: change TRACE_QUEUE_MANAGER_INTERVAL default value (langgenius#5698) Feat/add json process tool (langgenius#5555) fix: do not remove (langgenius#5682) Feature/add qwen llm (langgenius#5659) ... # Conflicts: # api/poetry.lock # api/pyproject.toml
Description
The existing template-transform node is quite complex when it comes to processing JSON data. For example, to extract just the URL from {"result": "{"url": "https://github.com/langgenius/dify"}\n"}, the complex code {{ result | replace('\n','') | replace('{"url": "','') | replace('"}','') }} needs to be used. To address this, a tool that uses jsonpath-ng for JSON processing has been introduced. This tool can parse, insert, delete and replace JSON content using simple instructions, greatly improving the ease of handling JSON. For the above example, simply inputting 'url' in json_filter is enough to obtain "https://github.com/langgenius/dify". This tool has significantly enhanced the convenience of JSON processing.
20240624_214703.mp4
parse
Given a JSON content and a json_filter, return the parsed result.
When the parsed result is a JSON structure, return it in JSON format. In other cases such as strings, numbers, etc., return a string.
insert
Given a JSON content, a query path, and a new_value:
delete
Given a JSON content and query. Based on the type of the query match, perform different deletion operations:
replace
Given the JSON content, query, replace_value, and replace_model:
Type of Change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Suggested Checklist:
dev/reformat
(backend) andcd web && npx lint-staged
(frontend) to appease the lint godsoptional
I have made corresponding changes to the documentationoptional
I have added tests that prove my fix is effective or that my feature worksoptional
New and existing unit tests pass locally with my changes