-
Notifications
You must be signed in to change notification settings - Fork 27
Add input tokens field #117
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
Merged
vhaldemar
merged 9 commits into
yandex-cloud:master
from
GBocharov:add-input_tokens-field
Jul 9, 2025
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bbb7e41
regenerate cassets try 1
GBocharov 37ee584
add input_tokens field, cassets updated
GBocharov 861174f
add examples, add doc string
GBocharov 1efd6da
lint fix
GBocharov ba070de
useless import removed
GBocharov 2511172
fix doc string
GBocharov d7a6899
[pre-commit.ci lite] apply automatic fixes
pre-commit-ci-lite[bot] 55ef380
regenerate cassets
GBocharov 57d97dd
Merge remote-tracking branch 'origin/add-input_tokens-field' into add…
GBocharov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,10 +6,10 @@ | |
|
|
||
|
|
||
| def main() -> None: | ||
| sdk = YCloudML(folder_id='b1ghsjum2v37c2un8h64') | ||
| sdk = YCloudML(folder_id='yc.fomo.storage.prod.service') | ||
| sdk.setup_default_logging() | ||
|
|
||
| model = sdk.models.text_classifiers('cls://b1ghsjum2v37c2un8h64/bt14f74au2ap3q0f9ou4') | ||
| model = sdk.models.text_classifiers(model_name='yandexgpt-lite', model_version='rc@tamrap1sjscq6e9flit3p') | ||
|
|
||
| # result will contain predictions with a predefined classes | ||
| # and most powerful prediction will be "mathematics": 0.92 | ||
|
|
@@ -18,6 +18,7 @@ def main() -> None: | |
| for prediction in result: | ||
| print(prediction) | ||
|
|
||
| print(f'input_tokens= {result.input_tokens}') | ||
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,8 @@ | |
| class TextClassifiersModelResultBase(BaseResult, Sequence, Generic[TextClassificationResponseT]): | ||
| predictions: tuple[TextClassificationLabel, ...] | ||
| model_version: str | ||
| #: doc Number of input tokens provided to the model. | ||
|
||
| input_tokens: int | ||
|
|
||
| @classmethod | ||
| def _from_proto(cls, *, proto: ProtoMessage, sdk: BaseSDK) -> Self: # pylint: disable=unused-argument | ||
|
|
@@ -42,6 +44,7 @@ def _from_proto(cls, *, proto: ProtoMessage, sdk: BaseSDK) -> Self: # pylint: d | |
| return cls( | ||
| predictions=predictions, | ||
| model_version=proto.model_version, | ||
| input_tokens = proto.input_tokens | ||
| ) | ||
|
|
||
| def __len__(self) -> int: | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 don't really like this folder_id in the code.
I also don't like old version(
It is okay for now, but I will bump the related ticket