-
Notifications
You must be signed in to change notification settings - Fork 237
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
Add count_text_tokens, and expose operations. #76
Conversation
0d8ccdb
to
16c10b9
Compare
@@ -114,6 +114,31 @@ def get_tuned_model( | |||
return model_types.decode_tuned_model(result) | |||
|
|||
|
|||
def get_base_model_name( | |||
model: model_types.AnyModelNameOptions, client: glm.ModelServiceClient | None = None | |||
): |
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.
): | |
) -> str: |
873d6af
to
c2af4d5
Compare
Merge #78 first. |
c4f087c
to
d4fa2e2
Compare
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.
Yay text counting :)
tests/test_text.py
Outdated
|
||
response = text_service.count_text_tokens(model, "Tell me a story about a magic backpack.") | ||
self.assertEqual({"token_count": 7}, response) | ||
if len(self.observed_requests) > 1: |
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.
Can we make the guard condition here something that makes it clear why it's optional? e.g. if make_model_name(model).startswith("tunedModel/"): ...
or an extra param like should_look_up_model=bool
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.
Done.
9b27bd4
to
106b974
Compare
* Add count_text_tokens, and expose operations. * Format and fix pytype errors. * use get_base_model_name in create_tuned_model * Resolve comments
Description of the change
Motivation
These should have been in v1beta2.
Type of change
Feature
Checklist
git pull --rebase upstream main
).