Skip to content

Commit

Permalink
Merge pull request #708 from Mirascope/fix-gemini-call-params-with-py…
Browse files Browse the repository at this point in the history
…dantic-2.10.0

Fix gemini call params with pydantic 2.10.0
  • Loading branch information
willbakst authored Nov 21, 2024
2 parents 80eef5b + a5dec7e commit 3f3cbe3
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 67 deletions.
30 changes: 25 additions & 5 deletions mirascope/core/gemini/call_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,37 @@

from __future__ import annotations

from google.generativeai.types import (
GenerationConfig,
GenerationConfigDict,
RequestOptions,
)
from typing import TYPE_CHECKING

from google.generativeai.types.content_types import ToolConfigType
from google.generativeai.types.safety_types import SafetySettingOptions
from pydantic import ConfigDict, with_config
from typing_extensions import NotRequired

from ..base import BaseCallParams

if TYPE_CHECKING:
from google.generativeai.types import (
GenerationConfig,
GenerationConfigDict,
RequestOptions,
)
else:
from google.generativeai.types import (
GenerationConfig as _GenerationConfig,
)
from google.generativeai.types import GenerationConfigDict as _GenerationConfigDict
from google.generativeai.types import RequestOptions as _RequestOptions

@with_config(ConfigDict(arbitrary_types_allowed=True))
class GenerationConfigDict(_GenerationConfigDict): ...

class GenerationConfig(_GenerationConfig):
__pydantic_config__ = ConfigDict(arbitrary_types_allowed=True)

class RequestOptions(_RequestOptions):
__pydantic_config__ = ConfigDict(arbitrary_types_allowed=True)


class GeminiCallParams(BaseCallParams):
"""The parameters to use when calling the Gemini API.
Expand Down
Loading

0 comments on commit 3f3cbe3

Please sign in to comment.