mirror of
https://github.com/infiniflow/ragflow.git
synced 2026-07-07 03:48:44 +08:00
Feat: published agent version control (#13410)
### What problem does this PR solve? Feat: published agent version control ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@@ -1032,6 +1032,7 @@ class UserCanvas(DataBaseModel):
|
||||
title = CharField(max_length=255, null=True, help_text="Canvas title")
|
||||
|
||||
permission = CharField(max_length=16, null=False, help_text="me|team", default="me", index=True)
|
||||
release = BooleanField(null=False, help_text="is released", default=False, index=True)
|
||||
description = TextField(null=True, help_text="Canvas description")
|
||||
canvas_type = CharField(max_length=32, null=True, help_text="Canvas type", index=True)
|
||||
canvas_category = CharField(max_length=32, null=False, default="agent_canvas", help_text="Canvas category: agent_canvas|dataflow_canvas", index=True)
|
||||
@@ -1407,6 +1408,7 @@ def migrate_db():
|
||||
alter_db_add_column(migrator, "task", "task_type", CharField(max_length=32, null=False, default=""))
|
||||
alter_db_add_column(migrator, "task", "priority", IntegerField(default=0))
|
||||
alter_db_add_column(migrator, "user_canvas", "permission", CharField(max_length=16, null=False, help_text="me|team", default="me", index=True))
|
||||
alter_db_add_column(migrator, "user_canvas", "release", BooleanField(null=False, help_text="is released", default=False, index=True))
|
||||
alter_db_add_column(migrator, "llm", "is_tools", BooleanField(null=False, help_text="support tools", default=False))
|
||||
alter_db_add_column(migrator, "mcp_server", "variables", JSONField(null=True, help_text="MCP Server variables", default=dict))
|
||||
alter_db_rename_column(migrator, "task", "process_duation", "process_duration")
|
||||
|
||||
@@ -195,10 +195,12 @@ async def completion(tenant_id, agent_id, session_id=None, **kwargs):
|
||||
inputs = kwargs.get("inputs", {})
|
||||
user_id = kwargs.get("user_id", "")
|
||||
custom_header = kwargs.get("custom_header", "")
|
||||
release_mode = str(kwargs.get("release", "")).strip().lower()
|
||||
|
||||
if session_id:
|
||||
e, conv = API4ConversationService.get_by_id(session_id)
|
||||
assert e, "Session not found!"
|
||||
if not e:
|
||||
raise LookupError("Session not found!")
|
||||
if not conv.message:
|
||||
conv.message = []
|
||||
if not isinstance(conv.dsl, str):
|
||||
@@ -206,10 +208,15 @@ async def completion(tenant_id, agent_id, session_id=None, **kwargs):
|
||||
canvas = Canvas(conv.dsl, tenant_id, agent_id, canvas_id=agent_id, custom_header=custom_header)
|
||||
else:
|
||||
e, cvs = UserCanvasService.get_by_id(agent_id)
|
||||
assert e, "Agent not found."
|
||||
assert cvs.user_id == tenant_id, "You do not own the agent."
|
||||
if not e:
|
||||
raise LookupError("Agent not found.")
|
||||
if cvs.user_id != tenant_id:
|
||||
raise PermissionError("You do not own the agent.")
|
||||
if release_mode == "true" and not bool(cvs.release):
|
||||
raise PermissionError("No available published version")
|
||||
if not isinstance(cvs.dsl, str):
|
||||
cvs.dsl = json.dumps(cvs.dsl, ensure_ascii=False)
|
||||
|
||||
session_id=get_uuid()
|
||||
canvas = Canvas(cvs.dsl, tenant_id, agent_id, canvas_id=cvs.id, custom_header=custom_header)
|
||||
canvas.reset()
|
||||
|
||||
Reference in New Issue
Block a user