mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-15 06:26:12 +00:00
Add Google-style docstring linting and update pyproject.toml (#29303)
### Description: This PR introduces Google-style docstring linting for the ModelLaboratory class in libs/langchain/langchain/model_laboratory.py. It also updates the pyproject.toml file to comply with the latest Ruff configuration standards (deprecating top-level lint settings in favor of lint). ### Changes include: - [x] Added detailed Google-style docstrings to all methods in ModelLaboratory. - [x] Updated pyproject.toml to move select and pydocstyle settings under the [tool.ruff.lint] section. - [x] Ensured all files pass Ruff linting. Issue: Closes #25154 ### Dependencies: No additional dependencies are required for this change. ### Checklist - [x] Files passes ruff linting. - [x] Docstrings conform to the Google-style convention. - [x] pyproject.toml updated to avoid deprecation warnings. - [x] My PR is ready to review, please review.
This commit is contained in:
@@ -13,13 +13,23 @@ from langchain.chains.llm import LLMChain
|
||||
|
||||
|
||||
class ModelLaboratory:
|
||||
"""Experiment with different models."""
|
||||
"""A utility to experiment with and compare the performance of different models."""
|
||||
|
||||
def __init__(self, chains: Sequence[Chain], names: Optional[List[str]] = None):
|
||||
"""Initialize with chains to experiment with.
|
||||
"""Initialize the ModelLaboratory with chains to experiment with.
|
||||
|
||||
Args:
|
||||
chains: list of chains to experiment with.
|
||||
chains (Sequence[Chain]): A sequence of chains to experiment with.
|
||||
Each chain must have exactly one input and one output variable.
|
||||
names (Optional[List[str]]): Optional list of names corresponding to each chain.
|
||||
If provided, its length must match the number of chains.
|
||||
|
||||
|
||||
Raises:
|
||||
ValueError: If any chain is not an instance of `Chain`.
|
||||
ValueError: If a chain does not have exactly one input variable.
|
||||
ValueError: If a chain does not have exactly one output variable.
|
||||
ValueError: If the length of `names` does not match the number of chains.
|
||||
"""
|
||||
for chain in chains:
|
||||
if not isinstance(chain, Chain):
|
||||
@@ -50,12 +60,15 @@ class ModelLaboratory:
|
||||
def from_llms(
|
||||
cls, llms: List[BaseLLM], prompt: Optional[PromptTemplate] = None
|
||||
) -> ModelLaboratory:
|
||||
"""Initialize with LLMs to experiment with and optional prompt.
|
||||
"""Initialize the ModelLaboratory with LLMs and an optional prompt.
|
||||
|
||||
Args:
|
||||
llms: list of LLMs to experiment with
|
||||
prompt: Optional prompt to use to prompt the LLMs. Defaults to None.
|
||||
If a prompt was provided, it should only have one input variable.
|
||||
llms (List[BaseLLM]): A list of LLMs to experiment with.
|
||||
prompt (Optional[PromptTemplate]): An optional prompt to use with the LLMs.
|
||||
If provided, the prompt must contain exactly one input variable.
|
||||
|
||||
Returns:
|
||||
ModelLaboratory: An instance of `ModelLaboratory` initialized with LLMs.
|
||||
"""
|
||||
if prompt is None:
|
||||
prompt = PromptTemplate(input_variables=["_input"], template="{_input}")
|
||||
|
Reference in New Issue
Block a user