Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GenerationConfig to match the API. #609

Merged
merged 2 commits into from
Oct 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions google/generativeai/types/generation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ class GenerationConfigDict(TypedDict, total=False):
temperature: float
response_mime_type: str
response_schema: protos.Schema | Mapping[str, Any] # fmt: off
presence_penalty: float
frequency_penalty: float


@dataclasses.dataclass
Expand Down Expand Up @@ -144,8 +146,6 @@ class GenerationConfig:
Note: The default value varies by model, see the
`Model.top_k` attribute of the `Model` returned the
`genai.get_model` function.
seed:
Optional. Seed used in decoding. If not set, the request uses a randomly generated seed.
response_mime_type:
Optional. Output response mimetype of the generated candidate text.

Expand All @@ -161,10 +161,6 @@ class GenerationConfig:
Optional.
frequency_penalty:
Optional.
response_logprobs:
Optional. If true, export the `logprobs` results in response.
logprobs:
Optional. Number of candidates of log probabilities to return at each step of decoding.
"""

candidate_count: int | None = None
Expand All @@ -173,13 +169,10 @@ class GenerationConfig:
temperature: float | None = None
top_p: float | None = None
top_k: int | None = None
seed: int | None = None
response_mime_type: str | None = None
response_schema: protos.Schema | Mapping[str, Any] | type | None = None
presence_penalty: float | None = None
frequency_penalty: float | None = None
response_logprobs: bool | None = None
logprobs: int | None = None


GenerationConfigType = Union[protos.GenerationConfig, GenerationConfigDict, GenerationConfig]
Expand Down
Loading