Contributing
We welcome contributions! Please follow these guidelines to ensure code quality and consistency.
Rust Coding Guidelines
General Rules
- Zero Warnings: The codebase must compile with 0 warnings.
- No Unused Code: Clean up dead code, redundant imports, and unused variables.
- English Only: correct, professional English for all comments, documentation, and commit messages. No Chinese characters in source code.
Code Style
- Use
rustfmtfor formatting. - Follow idioms such as
Builderpattern for complex object creation. - Prefer
Option<&str>overOption<String>for arguments when possible.
Error Handling
- Use
LlmConnectorErrorfor all library errors. - Never use
unwrap()in library code; use?orexpect()with a descriptive message if panic is absolutely necessary/invariant.
Security
Sensitive Information
- NEVER commit real API keys or secrets.
- Use placeholders like
sk-...oryour-api-keyin examples and documentation. - Use environment variables (e.g.,
OPENAI_API_KEY) for tests.
Testing
Running Tests
bash
cargo test
cargo test --features tencentWriting Tests
- Integration Tests: Place in
examples/ortests/. - Unit Tests: Place in
mod testswithin the source file. - Mocking: Use
wiremockfor network tests to avoid hitting real APIs during CI.
