code-review
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecode-review
代码审核
Review code changes following pplx-sdk project standards and the layered architecture.
对照pplx-sdk项目标准及分层架构审核代码变更。
When to use
使用场景
Use this skill when reviewing pull requests or code changes in the pplx-sdk repository to ensure compliance with project conventions.
当在pplx-sdk仓库中审核拉取请求或代码变更时,使用此技能以确保符合项目规范。
Instructions
操作步骤
- Check architecture layer compliance: Verify imports respect dependency flow. No circular imports allowed.
core → shared → transport/domain → client - Verify type safety: All functions must have complete type annotations. Use at the top of every module.
from __future__ import annotations - Validate error handling: Custom exceptions from must be used — never bare
pplx_sdk.core.exceptions. Chain exceptions withException.from exc - Review docstrings: Google-style docstrings required on all public classes and methods, including Args, Returns, Raises sections.
- Check test coverage: Tests follow Arrange-Act-Assert pattern with descriptive names ().
test_<module>_<behavior> - Inspect Pydantic models: Domain models use Pydantic v2 with
BaseModeldescriptions.Field() - Verify transport protocol: Transport implementations conform to the protocol from
Transport.pplx_sdk.core.protocols
- 检查架构层合规性:验证导入是否遵循的依赖流向。不允许循环导入。
core → shared → transport/domain → client - 验证类型安全性:所有函数必须具备完整的类型注解。在每个模块顶部使用。
from __future__ import annotations - 验证错误处理:必须使用中的自定义异常——禁止使用原生
pplx_sdk.core.exceptions。通过Exception链接异常。from exc - 审核文档字符串:所有公共类和方法必须使用Google风格的文档字符串,包含Args、Returns、Raises章节。
- 检查测试覆盖率:测试需遵循Arrange-Act-Assert模式,且测试名称具有描述性(格式为)。
test_<module>_<behavior> - 检查Pydantic模型:领域模型使用Pydantic v2的并搭配
BaseModel描述。Field() - 验证传输协议:传输实现需符合中的
pplx_sdk.core.protocols协议。Transport
Architecture Layer Rules
架构层规则
core/ → No imports from other pplx_sdk modules
shared/ → May import from core/ only
transport/ → May import from core/, shared/
domain/ → May import from core/, shared/, transport/
client.py → May import from all layerscore/ → 禁止导入其他pplx_sdk模块
shared/ → 仅可从core/导入
transport/ → 可从core/、shared/导入
domain/ → 可从core/、shared/、transport/导入
client.py → 可从所有层导入Exception Hierarchy
异常层级
PerplexitySDKError (base)
├── TransportError (status_code, response_body)
│ ├── AuthenticationError (401)
│ └── RateLimitError (429, retry_after)
├── StreamingError
└── ValidationErrorPerplexitySDKError (基类)
├── TransportError (status_code, response_body)
│ ├── AuthenticationError (401)
│ └── RateLimitError (429, retry_after)
├── StreamingError
└── ValidationErrorOutput Format
输出格式
For each file reviewed, provide:
- ✅ Passes — or
- ❌ Issue found: description and suggested fix
对于每个审核的文件,提供:
- ✅ 通过 —— 或
- ❌ 发现问题:描述及建议修复方案