style: some cleanup (#33857)

This commit is contained in:
Mason Daugherty
2025-11-06 23:50:46 -05:00
committed by GitHub
parent d40e340479
commit e023201d42
79 changed files with 662 additions and 531 deletions

View File

@@ -452,27 +452,41 @@ class ChatMistralAI(BaseChatModel):
client: httpx.Client = Field( # type: ignore[assignment] # : meta private:
default=None, exclude=True
)
async_client: httpx.AsyncClient = Field( # type: ignore[assignment] # : meta private:
default=None, exclude=True
) #: :meta private:
)
mistral_api_key: SecretStr | None = Field(
alias="api_key",
default_factory=secret_from_env("MISTRAL_API_KEY", default=None),
)
endpoint: str | None = Field(default=None, alias="base_url")
max_retries: int = 5
timeout: int = 120
max_concurrent_requests: int = 64
model: str = Field(default="mistral-small", alias="model_name")
temperature: float = 0.7
max_tokens: int | None = None
top_p: float = 1
"""Decode using nucleus sampling: consider the smallest set of tokens whose
probability sum is at least `top_p`. Must be in the closed interval
`[0.0, 1.0]`."""
random_seed: int | None = None
safe_mode: bool | None = None
streaming: bool = False
model_kwargs: dict[str, Any] = Field(default_factory=dict)
"""Holds any invocation parameters not explicitly specified."""
@@ -803,10 +817,10 @@ class ChatMistralAI(BaseChatModel):
Args:
schema: The output schema. Can be passed in as:
- an OpenAI function/tool schema,
- a JSON Schema,
- a `TypedDict` class,
- or a Pydantic class.
- An OpenAI function/tool schema,
- A JSON Schema,
- A `TypedDict` class,
- Or a Pydantic class.
If `schema` is a Pydantic class then the model output will be a
Pydantic instance of that class, and the model-generated fields will be
@@ -836,11 +850,15 @@ class ChatMistralAI(BaseChatModel):
Added method="json_schema"
include_raw:
If `False` then only the parsed structured output is returned. If
an error occurs during model output parsing it will be raised. If `True`
then both the raw model response (a `BaseMessage`) and the parsed model
response will be returned. If an error occurs during output parsing it
will be caught and returned as well.
If `False` then only the parsed structured output is returned.
If an error occurs during model output parsing it will be raised.
If `True` then both the raw model response (a `BaseMessage`) and the
parsed model response will be returned.
If an error occurs during output parsing it will be caught and returned
as well.
The final output is always a `dict` with keys `'raw'`, `'parsed'`, and
`'parsing_error'`.

View File

@@ -124,20 +124,27 @@ class MistralAIEmbeddings(BaseModel, Embeddings):
# The type for client and async_client is ignored because the type is not
# an Optional after the model is initialized and the model_validator
# is run.
client: httpx.Client = Field(default=None) # type: ignore[assignment] # :meta private:
client: httpx.Client = Field(default=None) # type: ignore[assignment]
async_client: httpx.AsyncClient = Field( # type: ignore[assignment] # :meta private:
async_client: httpx.AsyncClient = Field( # type: ignore[assignment]
default=None
)
mistral_api_key: SecretStr = Field(
alias="api_key",
default_factory=secret_from_env("MISTRAL_API_KEY", default=""),
)
endpoint: str = "https://api.mistral.ai/v1/"
max_retries: int | None = 5
timeout: int = 120
wait_time: int | None = 30
max_concurrent_requests: int = 64
tokenizer: Tokenizer = Field(default=None)
model: str = "mistral-embed"