Merge branch 'refs/heads/develop' into feature/agent-tool_xjn

This commit is contained in:
Timebomb2018
2026-04-10 18:33:39 +08:00
4 changed files with 13 additions and 13 deletions

View File

@@ -91,16 +91,16 @@ async def chat(
Agent/Workflow 聊天接口
- 不传 version使用当前生效版本current_release回滚后为回滚目标版本
- 传 version=N:使用指定版本的历史快照,例如 {"version": 2}
- 传 version=release_id:使用指定版本uuid的历史快照,例如 {"version": "{{release_id}}"}
"""
body = await request.json()
payload = AppChatRequest(**body)
app = app_service.get_app(api_key_auth.resource_id, api_key_auth.workspace_id)
# 版本切换:指定 version 时查找对应历史快照,否则使用当前激活版本
# 版本切换:指定 release_id 时查找对应历史快照,否则使用当前激活版本
if payload.version is not None:
active_release = app_service.get_release_by_version(app.id, payload.version)
active_release = app_service.get_release_by_id(app.id, payload.version)
else:
active_release = app.current_release
other_id = payload.user_id

View File

@@ -63,13 +63,13 @@ def get_apps_by_id(db: Session, app_id: uuid.UUID) -> App:
return repo.get_apps_by_id(app_id)
def get_release_by_version(db: Session, app_id: uuid.UUID, version: int):
"""根据版本号查询发布快照(仅返回激活状态)"""
def get_release_by_id(db: Session, app_id: uuid.UUID, release_id: uuid.UUID):
"""根据发布版本ID查询发布快照(仅返回激活状态)"""
from app.models.app_release_model import AppRelease
return db.scalars(
select(AppRelease).where(
AppRelease.app_id == app_id,
AppRelease.version == version,
AppRelease.id == release_id,
AppRelease.is_active.is_(True),
)
).first()

View File

@@ -616,7 +616,7 @@ class AppChatRequest(BaseModel):
stream: bool = Field(default=False, description="是否流式返回")
thinking: bool = Field(default=False, description="是否启用深度思考需Agent配置支持")
files: List[FileInput] = Field(default_factory=list, description="附件列表(支持多文件)")
version: Optional[int] = Field(default=None, description="指定发布版本,不传则使用当前发布版本")
version: Optional[uuid.UUID] = Field(default=None, description="指定发布版本ID,不传则使用当前生效版本")
class DraftRunRequest(BaseModel):

View File

@@ -620,12 +620,12 @@ class AppService:
self._validate_app_accessible(app, workspace_id)
return app
def get_release_by_version(self, app_id: uuid.UUID, version: int) -> AppRelease:
"""版本号获取发布快照
def get_release_by_id(self, app_id: uuid.UUID, release_id: uuid.UUID) -> AppRelease:
"""发布版本ID获取发布快照
Args:
app_id: 应用ID
version: 版本号(整数,按应用内递增)
release_id: 发布版本ID
Returns:
AppRelease: 发布快照
@@ -633,11 +633,11 @@ class AppService:
Raises:
BusinessException: 版本不存在或已下线
"""
from app.repositories.app_repository import get_release_by_version
release = get_release_by_version(self.db, app_id, version)
from app.repositories.app_repository import get_release_by_id
release = get_release_by_id(self.db, app_id, release_id)
if not release:
raise BusinessException(
f"版本 {version} 不存在或已下线",
f"版本 {release_id} 不存在或已下线",
BizCode.RELEASE_NOT_FOUND,
)
return release