mirror of
https://github.com/hwchase17/langchain.git
synced 2025-09-05 04:55:14 +00:00
partners[lint]: run pyupgrade
to get code in line with 3.9 standards (#30781)
Using `pyupgrade` to get all `partners` code up to 3.9 standards (mostly, fixing old `typing` imports).
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any, Awaitable, Callable, Dict, List, Mapping, Optional, Union
|
||||
from collections.abc import Awaitable, Mapping
|
||||
from typing import Any, Callable, Optional, Union, cast
|
||||
|
||||
import openai
|
||||
from langchain_core.language_models import LangSmithParams
|
||||
from langchain_core.utils import from_env, secret_from_env
|
||||
from pydantic import Field, SecretStr, model_validator
|
||||
from typing_extensions import Self, cast
|
||||
from typing_extensions import Self
|
||||
|
||||
from langchain_openai.llms.base import BaseOpenAI
|
||||
|
||||
@@ -91,12 +92,12 @@ class AzureOpenAI(BaseOpenAI):
|
||||
"""
|
||||
|
||||
@classmethod
|
||||
def get_lc_namespace(cls) -> List[str]:
|
||||
def get_lc_namespace(cls) -> list[str]:
|
||||
"""Get the namespace of the langchain object."""
|
||||
return ["langchain", "llms", "openai"]
|
||||
|
||||
@property
|
||||
def lc_secrets(self) -> Dict[str, str]:
|
||||
def lc_secrets(self) -> dict[str, str]:
|
||||
return {
|
||||
"openai_api_key": "AZURE_OPENAI_API_KEY",
|
||||
"azure_ad_token": "AZURE_OPENAI_AD_TOKEN",
|
||||
@@ -188,12 +189,12 @@ class AzureOpenAI(BaseOpenAI):
|
||||
}
|
||||
|
||||
@property
|
||||
def _invocation_params(self) -> Dict[str, Any]:
|
||||
def _invocation_params(self) -> dict[str, Any]:
|
||||
openai_params = {"model": self.deployment_name}
|
||||
return {**openai_params, **super()._invocation_params}
|
||||
|
||||
def _get_ls_params(
|
||||
self, stop: Optional[List[str]] = None, **kwargs: Any
|
||||
self, stop: Optional[list[str]] = None, **kwargs: Any
|
||||
) -> LangSmithParams:
|
||||
"""Get standard params for tracing."""
|
||||
params = super()._get_ls_params(stop=stop, **kwargs)
|
||||
@@ -209,7 +210,7 @@ class AzureOpenAI(BaseOpenAI):
|
||||
return "azure"
|
||||
|
||||
@property
|
||||
def lc_attributes(self) -> Dict[str, Any]:
|
||||
def lc_attributes(self) -> dict[str, Any]:
|
||||
return {
|
||||
"openai_api_type": self.openai_api_type,
|
||||
"openai_api_version": self.openai_api_version,
|
||||
|
Reference in New Issue
Block a user