Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
PredictionService
-----------------------------------

.. automodule:: google.ai.generativelanguage_v1beta.services.prediction_service
:members:
:inherited-members:
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ Services for Google Ai Generativelanguage v1beta API
generative_service
model_service
permission_service
prediction_service
retriever_service
text_service
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@
from google.ai.generativelanguage_v1beta.services.permission_service.client import (
PermissionServiceClient,
)
from google.ai.generativelanguage_v1beta.services.prediction_service.async_client import (
PredictionServiceAsyncClient,
)
from google.ai.generativelanguage_v1beta.services.prediction_service.client import (
PredictionServiceClient,
)
from google.ai.generativelanguage_v1beta.services.retriever_service.async_client import (
RetrieverServiceAsyncClient,
)
Expand Down Expand Up @@ -84,12 +90,14 @@
CodeExecution,
CodeExecutionResult,
Content,
DynamicRetrievalConfig,
ExecutableCode,
FileData,
FunctionCall,
FunctionCallingConfig,
FunctionDeclaration,
FunctionResponse,
GoogleSearchRetrieval,
GroundingPassage,
GroundingPassages,
Part,
Expand Down Expand Up @@ -132,6 +140,13 @@
GenerateContentResponse,
GenerationConfig,
GroundingAttribution,
GroundingChunk,
GroundingMetadata,
GroundingSupport,
LogprobsResult,
RetrievalMetadata,
SearchEntryPoint,
Segment,
SemanticRetrieverConfig,
TaskType,
)
Expand Down Expand Up @@ -159,6 +174,10 @@
TransferOwnershipResponse,
UpdatePermissionRequest,
)
from google.ai.generativelanguage_v1beta.types.prediction_service import (
PredictRequest,
PredictResponse,
)
from google.ai.generativelanguage_v1beta.types.retriever import (
Chunk,
ChunkData,
Expand Down Expand Up @@ -243,6 +262,8 @@
"ModelServiceAsyncClient",
"PermissionServiceClient",
"PermissionServiceAsyncClient",
"PredictionServiceClient",
"PredictionServiceAsyncClient",
"RetrieverServiceClient",
"RetrieverServiceAsyncClient",
"TextServiceClient",
Expand All @@ -260,12 +281,14 @@
"CodeExecution",
"CodeExecutionResult",
"Content",
"DynamicRetrievalConfig",
"ExecutableCode",
"FileData",
"FunctionCall",
"FunctionCallingConfig",
"FunctionDeclaration",
"FunctionResponse",
"GoogleSearchRetrieval",
"GroundingPassage",
"GroundingPassages",
"Part",
Expand Down Expand Up @@ -303,6 +326,13 @@
"GenerateContentResponse",
"GenerationConfig",
"GroundingAttribution",
"GroundingChunk",
"GroundingMetadata",
"GroundingSupport",
"LogprobsResult",
"RetrievalMetadata",
"SearchEntryPoint",
"Segment",
"SemanticRetrieverConfig",
"TaskType",
"Model",
Expand All @@ -325,6 +355,8 @@
"TransferOwnershipRequest",
"TransferOwnershipResponse",
"UpdatePermissionRequest",
"PredictRequest",
"PredictResponse",
"Chunk",
"ChunkData",
"Condition",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.6.9" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
GenerateContentRequest,
GenerateContentResponse,
GenerationConfig,
LogprobsResult,
TaskType,
)
from .types.model import Model
Expand Down Expand Up @@ -66,6 +67,7 @@
"HarmCategory",
"ListModelsRequest",
"ListModelsResponse",
"LogprobsResult",
"Model",
"ModelServiceClient",
"Part",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
__version__ = "0.6.9" # {x-release-please-version}
__version__ = "0.0.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,10 @@ def __call__(
"method": "get",
"uri": "/v1/{name=tunedModels/*/operations/*}",
},
{
"method": "get",
"uri": "/v1/{name=generatedFiles/*}/operations/*",
},
]

request, metadata = self._interceptor.pre_get_operation(request, metadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ def __call__(
"method": "get",
"uri": "/v1/{name=tunedModels/*/operations/*}",
},
{
"method": "get",
"uri": "/v1/{name=generatedFiles/*}/operations/*",
},
]

request, metadata = self._interceptor.pre_get_operation(request, metadata)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
GenerateContentRequest,
GenerateContentResponse,
GenerationConfig,
LogprobsResult,
TaskType,
)
from .model import Model
Expand All @@ -50,6 +51,7 @@
"GenerateContentRequest",
"GenerateContentResponse",
"GenerationConfig",
"LogprobsResult",
"TaskType",
"Model",
"GetModelRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"GenerationConfig",
"GenerateContentResponse",
"Candidate",
"LogprobsResult",
"EmbedContentRequest",
"ContentEmbedding",
"EmbedContentResponse",
Expand Down Expand Up @@ -228,6 +229,58 @@ class GenerationConfig(proto.Message):
doesn't allow setting ``top_k`` on requests.

This field is a member of `oneof`_ ``_top_k``.
presence_penalty (float):
Optional. Presence penalty applied to the next token's
logprobs if the token has already been seen in the response.

This penalty is binary on/off and not dependant on the
number of times the token is used (after the first). Use
[frequency_penalty][google.ai.generativelanguage.v1.GenerationConfig.frequency_penalty]
for a penalty that increases with each use.

A positive penalty will discourage the use of tokens that
have already been used in the response, increasing the
vocabulary.

A negative penalty will encourage the use of tokens that
have already been used in the response, decreasing the
vocabulary.

This field is a member of `oneof`_ ``_presence_penalty``.
frequency_penalty (float):
Optional. Frequency penalty applied to the next token's
logprobs, multiplied by the number of times each token has
been seen in the respponse so far.

A positive penalty will discourage the use of tokens that
have already been used, proportional to the number of times
the token has been used: The more a token is used, the more
dificult it is for the model to use that token again
increasing the vocabulary of responses.

Caution: A *negative* penalty will encourage the model to
reuse tokens proportional to the number of times the token
has been used. Small negative values will reduce the
vocabulary of a response. Larger negative values will cause
the model to start repeating a common token until it hits
the
[max_output_tokens][google.ai.generativelanguage.v1.GenerationConfig.max_output_tokens]
limit: "...the the the the the...".

This field is a member of `oneof`_ ``_frequency_penalty``.
response_logprobs (bool):
Optional. If true, export the logprobs
results in response.

This field is a member of `oneof`_ ``_response_logprobs``.
logprobs (int):
Optional. Only valid if
[response_logprobs=True][google.ai.generativelanguage.v1.GenerationConfig.response_logprobs].
This sets the number of top logprobs to return at each
decoding step in the
[Candidate.logprobs_result][google.ai.generativelanguage.v1.Candidate.logprobs_result].

This field is a member of `oneof`_ ``_logprobs``.
"""

candidate_count: int = proto.Field(
Expand Down Expand Up @@ -259,6 +312,26 @@ class GenerationConfig(proto.Message):
number=7,
optional=True,
)
presence_penalty: float = proto.Field(
proto.FLOAT,
number=15,
optional=True,
)
frequency_penalty: float = proto.Field(
proto.FLOAT,
number=16,
optional=True,
)
response_logprobs: bool = proto.Field(
proto.BOOL,
number=17,
optional=True,
)
logprobs: int = proto.Field(
proto.INT32,
number=18,
optional=True,
)


class GenerateContentResponse(proto.Message):
Expand Down Expand Up @@ -414,6 +487,11 @@ class Candidate(proto.Message):
foundational LLM's training data.
token_count (int):
Output only. Token count for this candidate.
avg_logprobs (float):
Output only.
logprobs_result (google.ai.generativelanguage_v1.types.LogprobsResult):
Output only. Log-likelihood scores for the
response tokens and top tokens
"""

class FinishReason(proto.Enum):
Expand Down Expand Up @@ -494,6 +572,89 @@ class FinishReason(proto.Enum):
proto.INT32,
number=7,
)
avg_logprobs: float = proto.Field(
proto.DOUBLE,
number=10,
)
logprobs_result: "LogprobsResult" = proto.Field(
proto.MESSAGE,
number=11,
message="LogprobsResult",
)


class LogprobsResult(proto.Message):
r"""Logprobs Result

Attributes:
top_candidates (MutableSequence[google.ai.generativelanguage_v1.types.LogprobsResult.TopCandidates]):
Length = total number of decoding steps.
chosen_candidates (MutableSequence[google.ai.generativelanguage_v1.types.LogprobsResult.Candidate]):
Length = total number of decoding steps. The chosen
candidates may or may not be in top_candidates.
"""

class Candidate(proto.Message):
r"""Candidate for the logprobs token and score.

.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields

Attributes:
token (str):
The candidate’s token string value.

This field is a member of `oneof`_ ``_token``.
token_id (int):
The candidate’s token id value.

This field is a member of `oneof`_ ``_token_id``.
log_probability (float):
The candidate's log probability.

This field is a member of `oneof`_ ``_log_probability``.
"""

token: str = proto.Field(
proto.STRING,
number=1,
optional=True,
)
token_id: int = proto.Field(
proto.INT32,
number=3,
optional=True,
)
log_probability: float = proto.Field(
proto.FLOAT,
number=2,
optional=True,
)

class TopCandidates(proto.Message):
r"""Candidates with top log probabilities at each decoding step.

Attributes:
candidates (MutableSequence[google.ai.generativelanguage_v1.types.LogprobsResult.Candidate]):
Sorted by log probability in descending
order.
"""

candidates: MutableSequence["LogprobsResult.Candidate"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="LogprobsResult.Candidate",
)

top_candidates: MutableSequence[TopCandidates] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=TopCandidates,
)
chosen_candidates: MutableSequence[Candidate] = proto.RepeatedField(
proto.MESSAGE,
number=2,
message=Candidate,
)


class EmbedContentRequest(proto.Message):
Expand Down
Loading