Skip to content

Commit

Permalink
Merge branch 'main' into grounding
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkDaoust authored Sep 24, 2024
2 parents 4e76777 + 8f7f5cb commit af6ce40
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
20 changes: 18 additions & 2 deletions google/generativeai/types/generation_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,27 @@ 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.
Supported mimetype:
`text/plain`: (default) Text output.
`text/x-enum`: for use with a string-enum in `response_schema`
`application/json`: JSON response in the candidates.
response_schema:
Optional. Specifies the format of the JSON requested if response_mime_type is
`application/json`.
presence_penalty:
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 @@ -163,8 +173,13 @@ 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 Expand Up @@ -548,7 +563,8 @@ def __str__(self) -> str:
_result = _result.replace("\n", "\n ")

if self._error:
_error = f",\nerror=<{self._error.__class__.__name__}> {self._error}"

_error = f",\nerror={repr(self._error)}"
else:
_error = ""

Expand Down
2 changes: 1 addition & 1 deletion google/generativeai/types/model_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class TunedModel:
create_time: datetime.datetime | None = None
update_time: datetime.datetime | None = None
tuning_task: TuningTask | None = None
reader_project_numbers: List[int] | None = None
reader_project_numbers: list[int] | None = None

@property
def permissions(self) -> permission_types.Permissions:
Expand Down
2 changes: 1 addition & 1 deletion google/generativeai/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@
# limitations under the License.
from __future__ import annotations

__version__ = "0.8.1"
__version__ = "0.8.2"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_version():
release_status = "Development Status :: 5 - Production/Stable"

dependencies = [
"google-ai-generativelanguage@https://storage.googleapis.com/generativeai-downloads/preview/ai-generativelanguage-v1beta-py.tar.gz",
"google-ai-generativelanguage==0.6.10",
"google-api-core",
"google-api-python-client",
"google-auth>=2.15.0", # 2.15 adds API key auth support
Expand Down
12 changes: 7 additions & 5 deletions tests/test_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import annotations

from google.generativeai.types import file_types

import collections
import datetime
import os
from typing import Iterable, Union
from typing import Iterable, Sequence
import pathlib

import google
Expand All @@ -37,12 +38,13 @@ def __init__(self, test):

def create_file(
self,
path: Union[str, pathlib.Path, os.PathLike],
path: str | pathlib.Path | os.PathLike,
*,
mime_type: Union[str, None] = None,
name: Union[str, None] = None,
display_name: Union[str, None] = None,
mime_type: str | None = None,
name: str | None = None,
display_name: str | None = None,
resumable: bool = True,
metadata: Sequence[tuple[str, str]] = (),
) -> protos.File:
self.observed_requests.append(
dict(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_generative_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,10 +996,10 @@ def test_repr_error_info_for_stream_prompt_feedback_blocked(self):
}
}),
),
error=<BlockedPromptException> prompt_feedback {
error=BlockedPromptException(prompt_feedback {
block_reason: SAFETY
}
"""
)"""
)
self.assertEqual(expected, result)

Expand Down Expand Up @@ -1057,7 +1057,7 @@ def no_throw():
"prompt_feedback": {}
}),
),
error=<ValueError> """
error=ValueError()"""
)
self.assertEqual(expected, result)

Expand Down

0 comments on commit af6ce40

Please sign in to comment.