From c74e3f688c0ff631e6c1d93919b8f9bea30d58bf Mon Sep 17 00:00:00 2001 From: qzl Date: Tue, 14 Apr 2026 12:42:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20basedpyright=20?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E9=94=99=E8=AF=AF=E5=92=8C=E8=AF=AD=E8=A8=80?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E5=90=8C=E6=AD=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit runner.py: 将 user_text 解构从 tuple 第二元素改为第一元素(str), 消除 str | list[dict[str,Any]] 与 Msg.content 的类型不兼容问题。 简化了始终为 true 的 user_blocks 条件分支。 repository.py: 将 result.rowcount 的 type: ignore 替换为基于 pyright: ignore[reportAttributeAccessIssue],消除 basedpyright 错误。 app.dart: 保存 profile 时同步 _locale 和 session store 中的语言标记。 --- apps/lib/app/app.dart | 4 ++++ backend/src/core/agentscope/runtime/runner.py | 15 ++------------- backend/src/v1/users/repository.py | 4 ++-- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/apps/lib/app/app.dart b/apps/lib/app/app.dart index 03dc486..7cc1156 100644 --- a/apps/lib/app/app.dart +++ b/apps/lib/app/app.dart @@ -300,7 +300,11 @@ class _EryaoAppState extends State { if (!mounted) { return; } + final serverLanguage = profile.preferences.interfaceLanguage; + final serverLocale = localeFromLanguageTag(serverLanguage); + await _sessionStore.saveLocaleTag(serverLanguage); setState(() { + _locale = serverLocale; _profileSettings = profile; _loadedProfileUserEmail = userEmail; }); diff --git a/backend/src/core/agentscope/runtime/runner.py b/backend/src/core/agentscope/runtime/runner.py index af65c96..a39e960 100644 --- a/backend/src/core/agentscope/runtime/runner.py +++ b/backend/src/core/agentscope/runtime/runner.py @@ -324,8 +324,7 @@ class AgentScopeRunner: if derived_divination is not None: user_text = build_divination_user_prompt(derived=derived_divination) else: - _, latest_user_text = extract_latest_user_payload(run_input) - user_text = latest_user_text + user_text, _ = extract_latest_user_payload(run_input) if derived_divination is not None and context_messages: last = context_messages[-1] @@ -342,17 +341,7 @@ class AgentScopeRunner: if last.role == "user": return context_messages - user_blocks = [{"type": "text", "text": user_text}] - if ( - user_blocks - and isinstance(user_blocks[0], dict) - and user_blocks[0].get("type") == "text" - ): - content: Any = user_text - else: - content = user_blocks - - user_msg = Msg(name="user", role="user", content=content) + user_msg = Msg(name="user", role="user", content=user_text) return [*context_messages, user_msg] @staticmethod diff --git a/backend/src/v1/users/repository.py b/backend/src/v1/users/repository.py index 61a1a36..0ab7df1 100644 --- a/backend/src/v1/users/repository.py +++ b/backend/src/v1/users/repository.py @@ -41,7 +41,7 @@ class SQLAlchemyUserRepository: async def delete_invite_codes_by_owner_id(self, *, user_id: UUID) -> int: stmt = delete(InviteCode).where(InviteCode.owner_id == user_id) result = await self.session.execute(stmt) - return int(result.rowcount or 0) + return result.rowcount # pyright: ignore[reportAttributeAccessIssue] async def delete_points_audit_snapshots( self, @@ -61,4 +61,4 @@ class SQLAlchemyUserRepository: PointsAuditLedger.user_id_snapshot == user_id ) result = await self.session.execute(stmt) - return int(result.rowcount or 0) + return result.rowcount # pyright: ignore[reportAttributeAccessIssue]