ragflow
ragflow copied to clipboard
[Question]: Howto process json content with Template component ?
Describe your problem
In my agent graph, I have an Invoke component that outputs a JSON array like this:
{
"results": [
{
"type": "techdocs",
"document": {
"kind": "component",
"name": "component-1",
"path": "",
"text": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla lacinia lacus id consequat fermentum. Nulla nec eleifend purus. Etiam feugiat luctus consectetur. Mauris rhoncus orci egestas tincidunt faucibus. Aliquam pellentesque a ex a euismod. In ultricies metus lectus. Quisque auctor nulla lectus, at tempus felis aliquam in. Etiam mattis sem molestie justo semper dignissim et id dui. Interdum et malesuada fames ac ante ipsum primis in faucibus. Donec tempor porta elit.",
"type": "service",
"owner": "my-team",
"title": "Introduction",
"location": "/docs/default/component/component-1/",
"lifecycle": "experimental",
"namespace": "default",
"componentType": "service"
},
If I want to process this json with a Template component in order to format it as a Markdown output, how can I do that ?
The documentation says that it can use jinja2 template.
In my case, I tested a Jinja2 template like this but it doesn't work:
{% for result in results %}
## {{ result.document.title }}
{{ result.document.text }}
{% endfor %}
My graph looks like this:
Can you tell me how to proceed ?