Skip to content

Commit

Permalink
docs: Update the docstring for compute_tokens method.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 662196374
  • Loading branch information
happy-qiao authored and copybara-github committed Aug 12, 2024
1 parent 0ea5191 commit 849e8d4
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions vertexai/generative_models/_generative_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ async def count_tokens_async(
def compute_tokens(
self, contents: ContentsType
) -> gapic_llm_utility_service_types.ComputeTokensResponse:
"""Counts tokens.
"""Computes tokens.
Args:
contents: Contents to send to the model.
Expand All @@ -837,9 +837,13 @@ def compute_tokens(
* List[Content]
Returns:
A CountTokensResponse object that has the following attributes:
total_tokens: The total number of tokens counted across all instances from the request.
total_billable_characters: The total number of billable characters counted across all instances from the request.
A ComputeTokensResponse object that has the following attributes:
tokens_info: Lists of tokens_info from the input.
The input `contents: ContentsType` could have
multiple string instances and each tokens_info
item represents each string instance. Each token
info consists tokens list, token_ids list and
a role.
"""
return self._llm_utility_client.compute_tokens(
request=gapic_llm_utility_service_types.ComputeTokensRequest(
Expand All @@ -852,7 +856,7 @@ def compute_tokens(
async def compute_tokens_async(
self, contents: ContentsType
) -> gapic_llm_utility_service_types.ComputeTokensResponse:
"""Counts tokens asynchronously.
"""Computes tokens asynchronously.
Args:
contents: Contents to send to the model.
Expand All @@ -864,9 +868,13 @@ async def compute_tokens_async(
* List[Content]
Returns:
And awaitable for a CountTokensResponse object that has the following attributes:
total_tokens: The total number of tokens counted across all instances from the request.
total_billable_characters: The total number of billable characters counted across all instances from the request.
And awaitable for a ComputeTokensResponse object that has the following attributes:
tokens_info: Lists of tokens_info from the input.
The input `contents: ContentsType` could have
multiple string instances and each tokens_info
item represents each string instance. Each token
info consists tokens list, token_ids list and
a role.
"""
return await self._llm_utility_async_client.compute_tokens(
request=gapic_llm_utility_service_types.ComputeTokensRequest(
Expand Down

0 comments on commit 849e8d4

Please sign in to comment.