feat: add versioned app chat API and fix release isolation bug
This commit is contained in:
@@ -63,13 +63,13 @@ def get_apps_by_id(db: Session, app_id: uuid.UUID) -> App:
|
|||||||
return repo.get_apps_by_id(app_id)
|
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_version(db: Session, app_id: uuid.UUID, release_id: uuid.UUID):
|
||||||
"""根据版本号查询发布快照(仅返回激活状态)"""
|
"""根据发布版本ID查询发布快照(仅返回激活状态)"""
|
||||||
from app.models.app_release_model import AppRelease
|
from app.models.app_release_model import AppRelease
|
||||||
return db.scalars(
|
return db.scalars(
|
||||||
select(AppRelease).where(
|
select(AppRelease).where(
|
||||||
AppRelease.app_id == app_id,
|
AppRelease.app_id == app_id,
|
||||||
AppRelease.version == version,
|
AppRelease.id == release_id,
|
||||||
AppRelease.is_active.is_(True),
|
AppRelease.is_active.is_(True),
|
||||||
)
|
)
|
||||||
).first()
|
).first()
|
||||||
|
|||||||
@@ -616,7 +616,7 @@ class AppChatRequest(BaseModel):
|
|||||||
stream: bool = Field(default=False, description="是否流式返回")
|
stream: bool = Field(default=False, description="是否流式返回")
|
||||||
thinking: bool = Field(default=False, description="是否启用深度思考(需Agent配置支持)")
|
thinking: bool = Field(default=False, description="是否启用深度思考(需Agent配置支持)")
|
||||||
files: List[FileInput] = Field(default_factory=list, description="附件列表(支持多文件)")
|
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):
|
class DraftRunRequest(BaseModel):
|
||||||
|
|||||||
@@ -619,12 +619,12 @@ class AppService:
|
|||||||
self._validate_app_accessible(app, workspace_id)
|
self._validate_app_accessible(app, workspace_id)
|
||||||
return app
|
return app
|
||||||
|
|
||||||
def get_release_by_version(self, app_id: uuid.UUID, version: int) -> AppRelease:
|
def get_release_by_version(self, app_id: uuid.UUID, release_id: uuid.UUID) -> AppRelease:
|
||||||
"""按版本号获取发布快照
|
"""按发布版本ID获取发布快照
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
app_id: 应用ID
|
app_id: 应用ID
|
||||||
version: 版本号(整数,按应用内递增)
|
release_id: 发布版本ID
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
AppRelease: 发布快照
|
AppRelease: 发布快照
|
||||||
@@ -633,10 +633,10 @@ class AppService:
|
|||||||
BusinessException: 版本不存在或已下线
|
BusinessException: 版本不存在或已下线
|
||||||
"""
|
"""
|
||||||
from app.repositories.app_repository import get_release_by_version
|
from app.repositories.app_repository import get_release_by_version
|
||||||
release = get_release_by_version(self.db, app_id, version)
|
release = get_release_by_version(self.db, app_id, release_id)
|
||||||
if not release:
|
if not release:
|
||||||
raise BusinessException(
|
raise BusinessException(
|
||||||
f"版本 {version} 不存在或已下线",
|
f"版本 {release_id} 不存在或已下线",
|
||||||
BizCode.RELEASE_NOT_FOUND,
|
BizCode.RELEASE_NOT_FOUND,
|
||||||
)
|
)
|
||||||
return release
|
return release
|
||||||
|
|||||||
Reference in New Issue
Block a user