git clone https://github.com/your-username/name-of-forked-repo.git# For instance, for LangChain:git clone https://github.com/parrot123/langchain.git
Copy
# Inside your repo, initialize environment and install dependenciesuv venv && source .venv/bin/activateuv sync --all-groups# or, to install a specific group only:uv sync --group test
make integration_tests# Or directly:uv run --group test --group test_integration pytest --retries 3 --retry-delay 1 tests/integration_tests# To run a specific test:TEST_FILE=tests/integration_tests/test_openai.py make integration_tests
def process_documents( docs: list[Document], processor: DocumentProcessor, *, batch_size: int = 100) -> ProcessingResult: """Process documents in batches. Args: docs: List of documents to process. processor: Document processing instance. batch_size: Number of documents per batch. Returns: Processing results with success/failure counts. """
必需:所有公共函数使用 Google 风格文档字符串。指导原则:文档字符串描述”是什么”;本站上的文档解释”如何”和”为什么”。
内容类型
位置
用途
参数类型
签名
自动生成到 API 参考
参数描述
文档字符串
自动生成到 API 参考
返回类型和异常
文档字符串
API 参考
最小用法示例
文档字符串
展示基本实例化模式
功能教程
本站
深度演练
端到端示例
本站
真实使用模式
概念解释
本站
理解和上下文
文档字符串应包含:
类/函数功能的一行摘要
指向本站教程、指南和使用模式的链接
带类型和描述的参数文档
返回值描述
可能引发的异常
展示基本实例化/使用的单个最小示例(如有必要)
好的文档字符串示例
Copy
class ChatAnthropic(BaseChatModel): """Interface to Claude chat models. See the [usage guide](https://docs.langchain.com/oss/python/integrations/chat/anthropic) for tutorials, feature walkthroughs, and examples. Args: model: Model identifier (e.g., `'claude-sonnet-4-6'`). temperature: Sampling temperature between `0` and `1`. max_tokens: Maximum number of tokens to generate. api_key: Anthropic API key. If not provided, reads from the `ANTHROPIC_API_KEY` environment variable. timeout: Request timeout in seconds. max_retries: Maximum number of retries for failed requests. Returns: A chat model instance that can be invoked with messages. Raises: ValueError: If the model identifier is not recognized. AuthenticationError: If the API key is invalid. Example: ```python from langchain_anthropic import ChatAnthropic model = ChatAnthropic(model="claude-sonnet-4-6") response = model.invoke("Hello!") ``` """
文档字符串中不应包含的内容
避免在文档字符串中重复不属于其中的内容:
参数类型:这些在函数签名中,并自动生成到 API 参考中。
功能教程:不要包含扩展演练。而是链接到本站:
Copy
"""...See the [extended thinking guide](https://docs.langchain.com/oss/integrations/chat/anthropic#extended-thinking)for configuration options."""
多个示例变体:包含一个最小示例,然后链接到综合指南:
Copy
"""Example: \`\`\`python message = HumanMessage(content=[ {"type": "image", "url": "https://example.com/image.jpg"} ]) \`\`\`See the [multimodal guide](https://docs.langchain.com/oss/integrations/chat/anthropic#multimodal)for all supported input formats."""
概念解释:保持对事实参数描述的关注。链接到文档以获取更深层次的上下文。
MkDocs 特定语法:避免在文档字符串中使用 ???+、手风琴或标签页。它们在 IDE 中无法渲染。