Skip to content

Commit 3f3cbe3

Browse files
authored
Merge pull request #708 from Mirascope/fix-gemini-call-params-with-pydantic-2.10.0
Fix gemini call params with pydantic 2.10.0
2 parents 80eef5b + a5dec7e commit 3f3cbe3

File tree

2 files changed

+95
-67
lines changed

2 files changed

+95
-67
lines changed

mirascope/core/gemini/call_params.py

+25-5
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,37 @@
22

33
from __future__ import annotations
44

5-
from google.generativeai.types import (
6-
GenerationConfig,
7-
GenerationConfigDict,
8-
RequestOptions,
9-
)
5+
from typing import TYPE_CHECKING
6+
107
from google.generativeai.types.content_types import ToolConfigType
118
from google.generativeai.types.safety_types import SafetySettingOptions
9+
from pydantic import ConfigDict, with_config
1210
from typing_extensions import NotRequired
1311

1412
from ..base import BaseCallParams
1513

14+
if TYPE_CHECKING:
15+
from google.generativeai.types import (
16+
GenerationConfig,
17+
GenerationConfigDict,
18+
RequestOptions,
19+
)
20+
else:
21+
from google.generativeai.types import (
22+
GenerationConfig as _GenerationConfig,
23+
)
24+
from google.generativeai.types import GenerationConfigDict as _GenerationConfigDict
25+
from google.generativeai.types import RequestOptions as _RequestOptions
26+
27+
@with_config(ConfigDict(arbitrary_types_allowed=True))
28+
class GenerationConfigDict(_GenerationConfigDict): ...
29+
30+
class GenerationConfig(_GenerationConfig):
31+
__pydantic_config__ = ConfigDict(arbitrary_types_allowed=True)
32+
33+
class RequestOptions(_RequestOptions):
34+
__pydantic_config__ = ConfigDict(arbitrary_types_allowed=True)
35+
1636

1737
class GeminiCallParams(BaseCallParams):
1838
"""The parameters to use when calling the Gemini API.

0 commit comments

Comments
 (0)