fix TypeError in count_tokens & count_tokens_async#123
fix TypeError in count_tokens & count_tokens_async#123markmcd merged 1 commit intogoogle-gemini:mainfrom
Conversation
async def count_tokens(
self,
request: Optional[Union[generative_service.CountTokensRequest, dict]] = None,
*,
model: Optional[str] = None,
contents: Optional[MutableSequence[content.Content]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
if you don't use keyword args : model=model, contents=contents, but position args, this will lead to : TypeError: count_tokens() takes from 1 to 2 positional arguments but 3 were given
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
hhh find the same problem with you, but you submit the issue before I did. |
|
We need the CLA signed before we can merge this. |
signed |
|
Thanks for the contribution :) |
|
@MarkDaoust - I think this is worth a new package release, wdyt? |
| ) -> glm.CountTokensResponse: | ||
| contents = content_types.to_contents(contents) | ||
| return await self._client.count_tokens(self.model_name, contents) | ||
| return await self._client.count_tokens(model=self.model_name, contents=contents) |
There was a problem hiding this comment.
maybe here should be self._async_client.count_tokens
There was a problem hiding this comment.
I'm sending a PR for this, thanks.
Yes, I'm planning to release a 0.3.2 Monday. After #120 is merged. |
async def count_tokens( self, request: Optional[Union[generative_service.CountTokensRequest, dict]] = None, *, model: Optional[str] = None, contents: Optional[MutableSequence[content.Content]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, metadata: Sequence[Tuple[str, str]] = (),if you don't use keyword args : model=model, contents=contents, but position args, this will lead to : TypeError: count_tokens() takes from 1 to 2 positional arguments but 3 were given
Description of the change
Motivation
Type of change
Choose one: (Bug fix | Feature request | Documentation | Other)
Checklist
git pull --rebase upstream main).