@@ -91,19 +91,20 @@ def _default_params(self) -> dict[str, Any]:
9191 if max_tokens :
9292 params ["max_tokens" ] = max_tokens
9393 return params
94-
94+
9595 def _get_request_payload (
96- self ,
97- input_ : LanguageModelInput ,
98- * ,
99- stop : Optional [list [str ]] = None ,
100- ** kwargs : Any ,
96+ self ,
97+ input_ : LanguageModelInput ,
98+ * ,
99+ stop : Optional [list [str ]] = None ,
100+ ** kwargs : Any ,
101101 ) -> dict :
102102 max_tokens = self .max_tokens
103103 payload = super ()._get_request_payload (input_ , stop = stop , ** kwargs )
104104 if max_tokens :
105105 payload ["max_tokens" ] = max_tokens
106106 return payload
107+
107108 usage_metadata : dict = {}
108109
109110 # custom_get_token_ids = custom_get_token_ids
@@ -119,10 +120,10 @@ def _stream(self, *args: Any, **kwargs: Any) -> Iterator[ChatGenerationChunk]:
119120 yield chunk
120121
121122 def _convert_chunk_to_generation_chunk (
122- self ,
123- chunk : dict ,
124- default_chunk_class : type ,
125- base_generation_info : dict | None ,
123+ self ,
124+ chunk : dict ,
125+ default_chunk_class : type ,
126+ base_generation_info : dict | None ,
126127 ) -> ChatGenerationChunk | None :
127128 if chunk .get ("type" ) == "content.delta" : # from beta.chat.completions.stream
128129 return None
@@ -174,12 +175,12 @@ def _convert_chunk_to_generation_chunk(
174175 return generation_chunk
175176
176177 def invoke (
177- self ,
178- input : LanguageModelInput ,
179- config : RunnableConfig | None = None ,
180- * ,
181- stop : list [str ] | None = None ,
182- ** kwargs : Any ,
178+ self ,
179+ input : LanguageModelInput ,
180+ config : RunnableConfig | None = None ,
181+ * ,
182+ stop : list [str ] | None = None ,
183+ ** kwargs : Any ,
183184 ) -> BaseMessage :
184185 config = ensure_config (config )
185186 chat_result = cast (
0 commit comments