ragflow icon indicating copy to clipboard operation
ragflow copied to clipboard

[Question]: Howto process json content with Template component ?

Open vmahe35 opened this issue 1 week ago • 0 comments

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:

Image

Can you tell me how to proceed ?

vmahe35 avatar Feb 18 '25 09:02 vmahe35