-
Notifications
You must be signed in to change notification settings - Fork 457
fix TypeError in count_tokens & count_tokens_async #123
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
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? |
|
||
async def count_tokens_async( | ||
self, contents: content_types.ContentsType | ||
) -> 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe here should be self._async_client.count_tokens
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
).