|
36 | 36 | from pydantic import Discriminator, Field, Tag
|
37 | 37 | from typing_extensions import NotRequired, TypedDict, TypeGuard, assert_never
|
38 | 38 |
|
39 |
| -from .. import UnexpectedModelBehaviour, _pydantic, _utils, exceptions, result |
| 39 | +from .. import UnexpectedModelBehavior, _pydantic, _utils, exceptions, result |
40 | 40 | from ..messages import (
|
41 | 41 | ArgsObject,
|
42 | 42 | Message,
|
@@ -192,7 +192,7 @@ async def _make_request(self, messages: list[Message], streamed: bool) -> AsyncI
|
192 | 192 | async with self.http_client.stream('POST', url, content=request_json, headers=headers) as r:
|
193 | 193 | if r.status_code != 200:
|
194 | 194 | await r.aread()
|
195 |
| - raise exceptions.UnexpectedModelBehaviour(f'Unexpected response from gemini {r.status_code}', r.text) |
| 195 | + raise exceptions.UnexpectedModelBehavior(f'Unexpected response from gemini {r.status_code}', r.text) |
196 | 196 | yield r
|
197 | 197 |
|
198 | 198 | @staticmethod
|
@@ -223,7 +223,7 @@ async def _process_streamed_response(http_response: HTTPResponse) -> EitherStrea
|
223 | 223 | break
|
224 | 224 |
|
225 | 225 | if start_response is None:
|
226 |
| - raise UnexpectedModelBehaviour('Streamed response ended without content or tool calls') |
| 226 | + raise UnexpectedModelBehavior('Streamed response ended without content or tool calls') |
227 | 227 |
|
228 | 228 | if _extract_response_parts(start_response).is_left():
|
229 | 229 | return GeminiStreamStructuredResponse(_content=content, _stream=aiter_bytes)
|
@@ -287,7 +287,7 @@ def get(self, *, final: bool = False) -> Iterable[str]:
|
287 | 287 | for part in parts:
|
288 | 288 | yield part['text']
|
289 | 289 | else:
|
290 |
| - raise UnexpectedModelBehaviour( |
| 290 | + raise UnexpectedModelBehavior( |
291 | 291 | 'Streamed response with unexpected content, expected all parts to be text'
|
292 | 292 | )
|
293 | 293 |
|
@@ -334,7 +334,7 @@ def get(self, *, final: bool = False) -> ModelStructuredResponse:
|
334 | 334 | combined_parts.extend(parts)
|
335 | 335 | elif not candidate.get('finish_reason'):
|
336 | 336 | # you can get an empty text part along with the finish_reason, so we ignore that case
|
337 |
| - raise UnexpectedModelBehaviour( |
| 337 | + raise UnexpectedModelBehavior( |
338 | 338 | 'Streamed response with unexpected content, expected all parts to be function calls'
|
339 | 339 | )
|
340 | 340 | return _structured_response_from_parts(combined_parts, timestamp=self._timestamp)
|
@@ -534,14 +534,14 @@ def _extract_response_parts(
|
534 | 534 | Returns Either a list of function calls (Either.left) or a list of text parts (Either.right).
|
535 | 535 | """
|
536 | 536 | if len(response['candidates']) != 1:
|
537 |
| - raise UnexpectedModelBehaviour('Expected exactly one candidate in Gemini response') |
| 537 | + raise UnexpectedModelBehavior('Expected exactly one candidate in Gemini response') |
538 | 538 | parts = response['candidates'][0]['content']['parts']
|
539 | 539 | if _all_function_call_parts(parts):
|
540 | 540 | return _utils.Either(left=parts)
|
541 | 541 | elif _all_text_parts(parts):
|
542 | 542 | return _utils.Either(right=parts)
|
543 | 543 | else:
|
544 |
| - raise exceptions.UnexpectedModelBehaviour( |
| 544 | + raise exceptions.UnexpectedModelBehavior( |
545 | 545 | f'Unsupported response from Gemini, expected all parts to be function calls or text, got: {parts!r}'
|
546 | 546 | )
|
547 | 547 |
|
|
0 commit comments