feat: v0.1.1 迭代——人设外键重构、Chat UI优化、意识节点防幻觉、日志双视图

1. 人设外键重构:persona_template 成为 system_prompt 唯一权威来源,
   agent/系统节点通过 persona_id FK 引用,含数据迁移脚本
2. Chat UI:去掉底部AI提示、加号改为弹出菜单、新建对话乐观跳转
3. 意识节点:无可用worker时禁止编造agent_id,只能自行完成或拒绝
4. 日志页面:双tab布局(系统日志 + 工作流日志列表选择)
5. 其他:SSE流式聊天、对话删除/重命名、standalone模式修复

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-06-05 06:18:47 +00:00
parent e3b8686d45
commit 6f1bc27101
39 changed files with 2904 additions and 524 deletions
@@ -85,3 +85,29 @@ class ChatHistoryDatabase:
)
results = await session.execute(statement)
return results.scalars().all()
@database_exception
async def get_chat_session(self, chat_id: str) -> ChatHistoryRegister | None:
async with self.async_session_maker() as session:
statement = select(ChatHistoryRegister).where(
ChatHistoryRegister.chat_id == chat_id
)
results = await session.execute(statement)
return results.scalar_one_or_none()
@database_exception
async def delete_chat_session(self, chat_id: str) -> None:
from sqlalchemy import delete as sa_delete
async with self.async_session_maker() as session:
await session.execute(
sa_delete(ChatHistoryMessage).where(
ChatHistoryMessage.chat_id == chat_id
)
)
await session.execute(
sa_delete(ChatHistoryRegister).where(
ChatHistoryRegister.chat_id == chat_id
)
)
await session.commit()
@@ -27,18 +27,11 @@ class PersonaTemplateDatabase:
return result.scalar_one_or_none()
@database_exception
async def list_templates(self, owner_id: str = None, include_builtin: bool = True):
async def list_templates(self, owner_id: str = None, **kwargs):
async with self.async_session_maker() as session:
stmt = select(PersonaTemplate)
if owner_id and include_builtin:
from sqlalchemy import or_
stmt = stmt.where(
or_(PersonaTemplate.owner_id == owner_id, PersonaTemplate.is_builtin == True)
)
elif owner_id:
if owner_id:
stmt = stmt.where(PersonaTemplate.owner_id == owner_id)
elif include_builtin:
stmt = stmt.where(PersonaTemplate.is_builtin == True)
result = await session.execute(stmt)
return list(result.scalars().all())
@@ -93,6 +93,19 @@ class ProviderDatabase:
session.delete(provider)
await session.commit()
@database_exception
async def delete_provider_by_title(self, provider_title: str) -> None:
"""按 provider_title 删除 Provider;不存在时静默返回。"""
async with self.async_session_maker() as session:
statement = select(ProviderModel).where(
ProviderModel.provider_title == provider_title
)
result = await session.execute(statement)
provider = result.scalar_one_or_none()
if provider is not None:
await session.delete(provider)
await session.commit()
@database_exception
async def update_provider(self, provider_id: str, **kwargs) -> None:
"""部分更新指定 Provider 的字段;``provider_apikey`` 写入前自动加密。"""
@@ -31,7 +31,7 @@ class SystemNodeDatabase:
provider_title: str,
model_id: str,
tools: Optional[List[str]] = None,
custom_system_prompt: Optional[str] = None,
persona_id: Optional[str] = None,
display_name: Optional[str] = None,
) -> SystemNodeConfigModel:
"""按 node_name 插入或更新一个系统节点的模型配置。"""
@@ -46,8 +46,8 @@ class SystemNodeDatabase:
config.model_id = model_id
if tools is not None:
config.tools = tools
if custom_system_prompt is not None:
config.custom_system_prompt = custom_system_prompt
if persona_id is not None:
config.persona_id = persona_id
if display_name is not None:
config.display_name = display_name
else:
@@ -56,7 +56,7 @@ class SystemNodeDatabase:
provider_title=provider_title,
model_id=model_id,
tools=tools,
custom_system_prompt=custom_system_prompt,
persona_id=persona_id,
display_name=display_name,
)
session.add(config)