3
3
from __future__ import annotations
4
4
5
5
import asyncio
6
+ import builtins
6
7
import inspect
7
8
import json
8
- import typing
9
9
import warnings
10
10
from abc import ABC , abstractmethod
11
11
from collections .abc import AsyncIterator , Iterator , Sequence
@@ -366,7 +366,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
366
366
367
367
@model_validator (mode = "before" )
368
368
@classmethod
369
- def raise_deprecation (cls , values : typing . Dict ) -> Any : # noqa: UP006
369
+ def raise_deprecation (cls , values : builtins . dict ) -> Any :
370
370
"""Raise deprecation warning if ``callback_manager`` is used.
371
371
372
372
Args:
@@ -393,7 +393,7 @@ def raise_deprecation(cls, values: typing.Dict) -> Any: # noqa: UP006
393
393
)
394
394
395
395
@cached_property
396
- def _serialized (self ) -> typing . Dict [str , Any ]: # noqa: UP006
396
+ def _serialized (self ) -> builtins . dict [str , Any ]:
397
397
return dumpd (self )
398
398
399
399
# --- Runnable methods ---
@@ -743,8 +743,8 @@ async def astream(
743
743
744
744
def _combine_llm_outputs (
745
745
self ,
746
- llm_outputs : list [Optional [typing . Dict ]], # noqa: ARG002, UP006
747
- ) -> typing . Dict : # noqa: UP006
746
+ llm_outputs : list [Optional [builtins . dict ]], # noqa: ARG002
747
+ ) -> builtins . dict :
748
748
return {}
749
749
750
750
def _convert_cached_generations (self , cache_val : list ) -> list [ChatGeneration ]:
@@ -790,7 +790,7 @@ def _get_invocation_params(
790
790
self ,
791
791
stop : Optional [list [str ]] = None ,
792
792
** kwargs : Any ,
793
- ) -> typing . Dict : # noqa: UP006
793
+ ) -> builtins . dict :
794
794
params = self .asdict ()
795
795
params ["stop" ] = stop
796
796
return {** params , ** kwargs }
@@ -854,7 +854,7 @@ def generate(
854
854
callbacks : Callbacks = None ,
855
855
* ,
856
856
tags : Optional [list [str ]] = None ,
857
- metadata : Optional [typing . Dict [str , Any ]] = None , # noqa: UP006
857
+ metadata : Optional [builtins . dict [str , Any ]] = None ,
858
858
run_name : Optional [str ] = None ,
859
859
run_id : Optional [uuid .UUID ] = None ,
860
860
** kwargs : Any ,
@@ -969,7 +969,7 @@ async def agenerate(
969
969
callbacks : Callbacks = None ,
970
970
* ,
971
971
tags : Optional [list [str ]] = None ,
972
- metadata : Optional [typing . Dict [str , Any ]] = None , # noqa: UP006
972
+ metadata : Optional [builtins . dict [str , Any ]] = None ,
973
973
run_name : Optional [str ] = None ,
974
974
run_id : Optional [uuid .UUID ] = None ,
975
975
** kwargs : Any ,
@@ -1542,20 +1542,18 @@ def _llm_type(self) -> str:
1542
1542
1543
1543
@deprecated ("0.3.61" , alternative = "asdict" , removal = "1.0" )
1544
1544
@override
1545
- def dict (self , ** kwargs : Any ) -> typing . Dict [str , Any ]: # noqa: UP006
1545
+ def dict (self , ** kwargs : Any ) -> builtins . dict [str , Any ]:
1546
1546
return self .asdict ()
1547
1547
1548
- def asdict (self ) -> typing . Dict [str , Any ]: # noqa: UP006
1548
+ def asdict (self ) -> builtins . dict [str , Any ]:
1549
1549
"""Return a dictionary of the LLM."""
1550
1550
starter_dict = dict (self ._identifying_params )
1551
1551
starter_dict ["_type" ] = self ._llm_type
1552
1552
return starter_dict
1553
1553
1554
1554
def bind_tools (
1555
1555
self ,
1556
- tools : Sequence [
1557
- Union [typing .Dict [str , Any ], type , Callable , BaseTool ] # noqa: UP006
1558
- ],
1556
+ tools : Sequence [Union [builtins .dict [str , Any ], type , Callable , BaseTool ]],
1559
1557
* ,
1560
1558
tool_choice : Optional [Union [str ]] = None ,
1561
1559
** kwargs : Any ,
@@ -1574,11 +1572,11 @@ def bind_tools(
1574
1572
1575
1573
def with_structured_output (
1576
1574
self ,
1577
- schema : Union [typing . Dict , type ], # noqa: UP006
1575
+ schema : Union [builtins . dict , type ],
1578
1576
* ,
1579
1577
include_raw : bool = False ,
1580
1578
** kwargs : Any ,
1581
- ) -> Runnable [LanguageModelInput , Union [typing . Dict , BaseModel ]]: # noqa: UP006
1579
+ ) -> Runnable [LanguageModelInput , Union [builtins . dict , BaseModel ]]:
1582
1580
"""Model wrapper that returns outputs formatted to match the given schema.
1583
1581
1584
1582
Args:
0 commit comments