Use term keyword according to the official python doc glossary (#11338)

- **Description:** use term keyword according to the official python doc
glossary, see https://docs.python.org/3/glossary.html
  - **Issue:** not applicable
  - **Dependencies:** not applicable
  - **Tag maintainer:** @hwchase17
  - **Twitter handle:** vreyespue
This commit is contained in:
Vicente Reyes 2023-10-03 21:56:08 +02:00 committed by GitHub
parent 39316314fa
commit f3e13e7e5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 37 additions and 37 deletions

View File

@ -85,7 +85,7 @@ import InputMessages from "@snippets/get_started/quickstart/input_messages.mdx"
<InputMessages/> <InputMessages/>
For both these methods, you can also pass in parameters as key word arguments. For both these methods, you can also pass in parameters as keyword arguments.
For example, you could pass in `temperature=0` to adjust the temperature that is used from what the object was configured with. For example, you could pass in `temperature=0` to adjust the temperature that is used from what the object was configured with.
Whatever values are passed in during run time will always override what the object was configured with. Whatever values are passed in during run time will always override what the object was configured with.

View File

@ -54,7 +54,7 @@ prompt = ChatPromptTemplate.from_messages([
``` ```
How does the agent know what tools it can use? How does the agent know what tools it can use?
Those are passed in as a separate argument, so we can bind those as key word arguments to the LLM. Those are passed in as a separate argument, so we can bind those as keyword arguments to the LLM.
```python ```python
from langchain.tools.render import format_tool_to_openai_function from langchain.tools.render import format_tool_to_openai_function

View File

@ -30,9 +30,9 @@ def initialize_agent(
callback_manager: CallbackManager to use. Global callback manager is used if callback_manager: CallbackManager to use. Global callback manager is used if
not provided. Defaults to None. not provided. Defaults to None.
agent_path: Path to serialized agent to use. agent_path: Path to serialized agent to use.
agent_kwargs: Additional key word arguments to pass to the underlying agent agent_kwargs: Additional keyword arguments to pass to the underlying agent
tags: Tags to apply to the traced runs. tags: Tags to apply to the traced runs.
**kwargs: Additional key word arguments passed to the agent executor **kwargs: Additional keyword arguments passed to the agent executor
Returns: Returns:
An agent executor An agent executor

View File

@ -42,7 +42,7 @@ def load_agent_from_config(
config: Config dict to load agent from. config: Config dict to load agent from.
llm: Language model to use as the agent. llm: Language model to use as the agent.
tools: List of tools this agent has access to. tools: List of tools this agent has access to.
**kwargs: Additional key word arguments passed to the agent executor. **kwargs: Additional keyword arguments passed to the agent executor.
Returns: Returns:
An agent executor. An agent executor.
@ -92,7 +92,7 @@ def load_agent(
Args: Args:
path: Path to the agent file. path: Path to the agent file.
**kwargs: Additional key word arguments passed to the agent executor. **kwargs: Additional keyword arguments passed to the agent executor.
Returns: Returns:
An agent executor. An agent executor.

View File

@ -93,7 +93,7 @@ class AzureMLChatOnlineEndpoint(SimpleChatModel):
the endpoint""" the endpoint"""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
@validator("http_client", always=True, allow_reuse=True) @validator("http_client", always=True, allow_reuse=True)
@classmethod @classmethod

View File

@ -59,7 +59,7 @@ class BedrockEmbeddings(BaseModel, Embeddings):
equivalent to the modelId property in the list-foundation-models api""" equivalent to the modelId property in the list-foundation-models api"""
model_kwargs: Optional[Dict] = None model_kwargs: Optional[Dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
endpoint_url: Optional[str] = None endpoint_url: Optional[str] = None
"""Needed if you don't want to default to us-east-1 endpoint""" """Needed if you don't want to default to us-east-1 endpoint"""

View File

@ -45,9 +45,9 @@ class HuggingFaceEmbeddings(BaseModel, Embeddings):
"""Path to store models. """Path to store models.
Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable.""" Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable."""
model_kwargs: Dict[str, Any] = Field(default_factory=dict) model_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
encode_kwargs: Dict[str, Any] = Field(default_factory=dict) encode_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Key word arguments to pass when calling the `encode` method of the model.""" """Keyword arguments to pass when calling the `encode` method of the model."""
multi_process: bool = False multi_process: bool = False
"""Run encode() on multiple GPUs.""" """Run encode() on multiple GPUs."""
@ -133,9 +133,9 @@ class HuggingFaceInstructEmbeddings(BaseModel, Embeddings):
"""Path to store models. """Path to store models.
Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable.""" Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable."""
model_kwargs: Dict[str, Any] = Field(default_factory=dict) model_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
encode_kwargs: Dict[str, Any] = Field(default_factory=dict) encode_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Key word arguments to pass when calling the `encode` method of the model.""" """Keyword arguments to pass when calling the `encode` method of the model."""
embed_instruction: str = DEFAULT_EMBED_INSTRUCTION embed_instruction: str = DEFAULT_EMBED_INSTRUCTION
"""Instruction to use for embedding documents.""" """Instruction to use for embedding documents."""
query_instruction: str = DEFAULT_QUERY_INSTRUCTION query_instruction: str = DEFAULT_QUERY_INSTRUCTION
@ -212,9 +212,9 @@ class HuggingFaceBgeEmbeddings(BaseModel, Embeddings):
"""Path to store models. """Path to store models.
Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable.""" Can be also set by SENTENCE_TRANSFORMERS_HOME environment variable."""
model_kwargs: Dict[str, Any] = Field(default_factory=dict) model_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
encode_kwargs: Dict[str, Any] = Field(default_factory=dict) encode_kwargs: Dict[str, Any] = Field(default_factory=dict)
"""Key word arguments to pass when calling the `encode` method of the model.""" """Keyword arguments to pass when calling the `encode` method of the model."""
query_instruction: str = DEFAULT_QUERY_BGE_INSTRUCTION_EN query_instruction: str = DEFAULT_QUERY_BGE_INSTRUCTION_EN
"""Instruction to use for embedding query.""" """Instruction to use for embedding query."""

View File

@ -33,7 +33,7 @@ class HuggingFaceHubEmbeddings(BaseModel, Embeddings):
task: Optional[str] = "feature-extraction" task: Optional[str] = "feature-extraction"
"""Task to call the model with.""" """Task to call the model with."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
huggingfacehub_api_token: Optional[str] = None huggingfacehub_api_token: Optional[str] = None

View File

@ -90,7 +90,7 @@ class SagemakerEndpointEmbeddings(BaseModel, Embeddings):
""" # noqa: E501 """ # noqa: E501
model_kwargs: Optional[Dict] = None model_kwargs: Optional[Dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
endpoint_kwargs: Optional[Dict] = None endpoint_kwargs: Optional[Dict] = None
"""Optional attributes passed to the invoke_endpoint """Optional attributes passed to the invoke_endpoint

View File

@ -86,7 +86,7 @@ class SelfHostedHuggingFaceEmbeddings(SelfHostedEmbeddings):
model_load_fn: Callable = load_embedding_model model_load_fn: Callable = load_embedding_model
"""Function to load the model remotely on the server.""" """Function to load the model remotely on the server."""
load_fn_kwargs: Optional[dict] = None load_fn_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model load function.""" """Keyword arguments to pass to the model load function."""
inference_fn: Callable = _embed_documents inference_fn: Callable = _embed_documents
"""Inference function to extract the embeddings.""" """Inference function to extract the embeddings."""

View File

@ -36,7 +36,7 @@ class AmazonAPIGateway(LLM):
"""API Gateway HTTP Headers to send, e.g. for authentication""" """API Gateway HTTP Headers to send, e.g. for authentication"""
model_kwargs: Optional[Dict] = None model_kwargs: Optional[Dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
content_handler: ContentHandlerAmazonAPIGateway = ContentHandlerAmazonAPIGateway() content_handler: ContentHandlerAmazonAPIGateway = ContentHandlerAmazonAPIGateway()
"""The content handler class that provides an input and """The content handler class that provides an input and

View File

@ -36,7 +36,7 @@ class Anyscale(LLM):
""" """
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model. Reserved for future use""" """Keyword arguments to pass to the model. Reserved for future use"""
anyscale_service_url: Optional[str] = None anyscale_service_url: Optional[str] = None
anyscale_service_route: Optional[str] = None anyscale_service_route: Optional[str] = None

View File

@ -230,7 +230,7 @@ class AzureMLOnlineEndpoint(LLM, BaseModel):
the endpoint""" the endpoint"""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
@validator("http_client", always=True, allow_reuse=True) @validator("http_client", always=True, allow_reuse=True)
@classmethod @classmethod

View File

@ -147,7 +147,7 @@ class BedrockBase(BaseModel, ABC):
equivalent to the modelId property in the list-foundation-models api""" equivalent to the modelId property in the list-foundation-models api"""
model_kwargs: Optional[Dict] = None model_kwargs: Optional[Dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
endpoint_url: Optional[str] = None endpoint_url: Optional[str] = None
"""Needed if you don't want to default to us-east-1 endpoint""" """Needed if you don't want to default to us-east-1 endpoint"""

View File

@ -28,7 +28,7 @@ class ChatGLM(LLM):
endpoint_url: str = "http://127.0.0.1:8000/" endpoint_url: str = "http://127.0.0.1:8000/"
"""Endpoint URL to use.""" """Endpoint URL to use."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
max_token: int = 20000 max_token: int = 20000
"""Max token allowed to pass to the model.""" """Max token allowed to pass to the model."""
temperature: float = 0.1 temperature: float = 0.1

View File

@ -28,7 +28,7 @@ class DeepSparse(LLM):
"""The path to a model file or directory or the name of a SparseZoo model stub.""" """The path to a model file or directory or the name of a SparseZoo model stub."""
model_config: Optional[Dict[str, Any]] = None model_config: Optional[Dict[str, Any]] = None
"""Key word arguments passed to the pipeline construction. """Keyword arguments passed to the pipeline construction.
Common parameters are sequence_length, prompt_sequence_length""" Common parameters are sequence_length, prompt_sequence_length"""
generation_config: Union[None, str, Dict] = None generation_config: Union[None, str, Dict] = None

View File

@ -54,7 +54,7 @@ class GradientLLM(LLM):
""" """
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
gradient_api_url: str = "https://api.gradient.ai/api" gradient_api_url: str = "https://api.gradient.ai/api"
"""Endpoint URL to use.""" """Endpoint URL to use."""

View File

@ -39,7 +39,7 @@ class HuggingFaceEndpoint(LLM):
"""Task to call the model with. """Task to call the model with.
Should be a task that returns `generated_text` or `summary_text`.""" Should be a task that returns `generated_text` or `summary_text`."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
huggingfacehub_api_token: Optional[str] = None huggingfacehub_api_token: Optional[str] = None

View File

@ -33,7 +33,7 @@ class HuggingFaceHub(LLM):
"""Task to call the model with. """Task to call the model with.
Should be a task that returns `generated_text` or `summary_text`.""" Should be a task that returns `generated_text` or `summary_text`."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
huggingfacehub_api_token: Optional[str] = None huggingfacehub_api_token: Optional[str] = None

View File

@ -53,9 +53,9 @@ class HuggingFacePipeline(BaseLLM):
model_id: str = DEFAULT_MODEL_ID model_id: str = DEFAULT_MODEL_ID
"""Model name to use.""" """Model name to use."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments passed to the model.""" """Keyword arguments passed to the model."""
pipeline_kwargs: Optional[dict] = None pipeline_kwargs: Optional[dict] = None
"""Key word arguments passed to the pipeline.""" """Keyword arguments passed to the pipeline."""
batch_size: int = DEFAULT_BATCH_SIZE batch_size: int = DEFAULT_BATCH_SIZE
"""Batch size to use when passing multiple documents to generate.""" """Batch size to use when passing multiple documents to generate."""

View File

@ -53,7 +53,7 @@ class MosaicML(LLM):
inject_instruction_format: bool = False inject_instruction_format: bool = False
"""Whether to inject the instruction format into the prompt.""" """Whether to inject the instruction format into the prompt."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
retry_sleep: float = 1.0 retry_sleep: float = 1.0
"""How long to try sleeping for if a rate limit is encountered""" """How long to try sleeping for if a rate limit is encountered"""

View File

@ -40,7 +40,7 @@ class OctoAIEndpoint(LLM):
"""Endpoint URL to use.""" """Endpoint URL to use."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
octoai_api_token: Optional[str] = None octoai_api_token: Optional[str] = None
"""OCTOAI API Token""" """OCTOAI API Token"""

View File

@ -88,7 +88,7 @@ class OpenLLM(LLM):
"""Initialize this LLM instance in current process by default. Should """Initialize this LLM instance in current process by default. Should
only set to False when using in conjunction with BentoML Service.""" only set to False when using in conjunction with BentoML Service."""
llm_kwargs: Dict[str, Any] llm_kwargs: Dict[str, Any]
"""Key word arguments to be passed to openllm.LLM""" """Keyword arguments to be passed to openllm.LLM"""
_runner: Optional[openllm.LLMRunner] = PrivateAttr(default=None) _runner: Optional[openllm.LLMRunner] = PrivateAttr(default=None)
_client: Union[ _client: Union[

View File

@ -171,7 +171,7 @@ class SagemakerEndpoint(LLM):
""" """
model_kwargs: Optional[Dict] = None model_kwargs: Optional[Dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
endpoint_kwargs: Optional[Dict] = None endpoint_kwargs: Optional[Dict] = None
"""Optional attributes passed to the invoke_endpoint """Optional attributes passed to the invoke_endpoint

View File

@ -132,7 +132,7 @@ class SelfHostedPipeline(LLM):
model_load_fn: Callable model_load_fn: Callable
"""Function to load the model remotely on the server.""" """Function to load the model remotely on the server."""
load_fn_kwargs: Optional[dict] = None load_fn_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model load function.""" """Keyword arguments to pass to the model load function."""
model_reqs: List[str] = ["./", "torch"] model_reqs: List[str] = ["./", "torch"]
"""Requirements to install on hardware to inference the model.""" """Requirements to install on hardware to inference the model."""

View File

@ -158,7 +158,7 @@ class SelfHostedHuggingFaceLLM(SelfHostedPipeline):
device: int = 0 device: int = 0
"""Device to use for inference. -1 for CPU, 0 for GPU, 1 for second GPU, etc.""" """Device to use for inference. -1 for CPU, 0 for GPU, 1 for second GPU, etc."""
model_kwargs: Optional[dict] = None model_kwargs: Optional[dict] = None
"""Key word arguments to pass to the model.""" """Keyword arguments to pass to the model."""
hardware: Any hardware: Any
"""Remote hardware to send the inference function to.""" """Remote hardware to send the inference function to."""
model_reqs: List[str] = ["./", "transformers", "torch"] model_reqs: List[str] = ["./", "transformers", "torch"]

View File

@ -80,7 +80,7 @@ class Xinference(LLM):
model_uid: Optional[str] model_uid: Optional[str]
"""UID of the launched model""" """UID of the launched model"""
model_kwargs: Dict[str, Any] model_kwargs: Dict[str, Any]
"""Key word arguments to be passed to xinference.LLM""" """Keyword arguments to be passed to xinference.LLM"""
def __init__( def __init__(
self, self,

View File

@ -53,7 +53,7 @@ Dates are also represented as str.
# Unexpected keyword argument "extra" for "__init_subclass__" of "object" # Unexpected keyword argument "extra" for "__init_subclass__" of "object"
class Highlight(BaseModel, extra=Extra.allow): # type: ignore[call-arg] class Highlight(BaseModel, extra=Extra.allow): # type: ignore[call-arg]
"""Information that highlights the key words in the excerpt.""" """Information that highlights the keywords in the excerpt."""
BeginOffset: int BeginOffset: int
"""The zero-based location in the excerpt where the highlight starts.""" """The zero-based location in the excerpt where the highlight starts."""

View File

@ -20,7 +20,7 @@ def test_does_not_allow_args() -> None:
def test_does_not_allow_extra_kwargs() -> None: def test_does_not_allow_extra_kwargs() -> None:
"""Test formatting does not allow extra key word arguments.""" """Test formatting does not allow extra keyword arguments."""
template = "This is a {foo} test." template = "This is a {foo} test."
with pytest.raises(KeyError): with pytest.raises(KeyError):
formatter.format(template, foo="good", bar="oops") formatter.format(template, foo="good", bar="oops")