Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Infiniflow Ragflow UserCanvasService Save

From Leeroopedia
Knowledge Sources
Domains RAG, Agent_Systems
Last Updated 2026-02-12 06:00 GMT

Overview

Concrete tool for creating agent canvas records from templates or custom DSL provided by RAGFlow UserCanvasService.

Description

UserCanvasService.save creates a UserCanvas record via the inherited CommonService.save method. The POST /canvas/set endpoint handles both creation (no ID) and update (with ID), validates title uniqueness, and creates version snapshots via UserCanvasVersionService.

Usage

Called via REST API to create a new agent or update an existing one.

Code Reference

Source Location

  • Repository: ragflow
  • File: api/apps/canvas_app.py (L73-98), api/db/services/common_service.py (L141-154)

Signature

# REST endpoint
@manager.route('/set', methods=['POST'])
@login_required
async def save():
    """Create or update a canvas.
    Form: {title: str, dsl: dict|str, id?: str, canvas_category?: str}
    """

# Service method (inherited)
class UserCanvasService(CommonService):
    model = UserCanvas
    # save(**kwargs) inherited from CommonService

Import

from api.db.services.canvas_service import UserCanvasService

I/O Contract

Inputs

Name Type Required Description
title str Yes Canvas title
dsl dict or str Yes Workflow DSL definition
canvas_category str No "agent_canvas" (default) or "dataflow"
description str No Human-readable description

Outputs

Name Type Description
canvas dict Created canvas with id, title, dsl, user_id

Usage Examples

import requests

url = "http://localhost:9380/canvas/set"
payload = {
    "title": "Customer Support Agent",
    "dsl": {
        "components": {},
        "history": [],
        "path": [],
        "answer": []
    }
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, json=payload, headers=headers)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment