-
Notifications
You must be signed in to change notification settings - Fork 60
Adding API to fetch tokenizer config for model #1052
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
Changes from all commits
707e96c
30592c8
3cc7e8a
41a305c
b95aeb6
74601c0
8997594
dbed1dd
aa0ee81
d6b728e
43f94b0
035c4ee
a5cb572
766b201
8356379
e449f0a
ef2c40e
88fa1cc
c66bdd6
a2f0ebe
be96c70
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |
| from ads.aqua.common.errors import AquaRuntimeError, AquaValueError | ||
| from ads.aqua.common.utils import ( | ||
| get_hf_model_info, | ||
| is_valid_ocid, | ||
| list_hf_models, | ||
| ) | ||
| from ads.aqua.extension.base_handler import AquaAPIhandler | ||
|
|
@@ -316,8 +317,30 @@ def post(self, *args, **kwargs): # noqa: ARG002 | |
| ) | ||
|
|
||
|
|
||
| class AquaModelTokenizerConfigHandler(AquaAPIhandler): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add the pydocs to the class?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
| def get(self, model_id): | ||
| """ | ||
| Handles requests for retrieving the Hugging Face tokenizer configuration of a specified model. | ||
| Expected request format: GET /aqua/models/<model-ocid>/tokenizer | ||
|
|
||
| """ | ||
|
|
||
| path_list = urlparse(self.request.path).path.strip("/").split("/") | ||
| # Path should be /aqua/models/ocid1.iad.ahdxxx/tokenizer | ||
| # path_list=['aqua','models','<model-ocid>','tokenizer'] | ||
| if ( | ||
| len(path_list) == 4 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The request path here is: /aqua/models/ocid1.iad.ahdxxx/tokenizer Added comments |
||
| and is_valid_ocid(path_list[2]) | ||
| and path_list[3] == "tokenizer" | ||
| ): | ||
| return self.finish(AquaModelApp().get_hf_tokenizer_config(model_id)) | ||
|
|
||
| raise HTTPError(400, f"The request {self.request.path} is invalid.") | ||
|
|
||
|
|
||
| __handlers__ = [ | ||
| ("model/?([^/]*)", AquaModelHandler), | ||
| ("model/?([^/]*)/license", AquaModelLicenseHandler), | ||
| ("model/?([^/]*)/tokenizer", AquaModelTokenizerConfigHandler), | ||
| ("model/hf/search/?([^/]*)", AquaHuggingFaceHandler), | ||
| ] | ||
Uh oh!
There was an error while loading. Please reload this page.