fix: correct type definitions for AutoTokenizer and AutoModelForCausalLM#1499
fix: correct type definitions for AutoTokenizer and AutoModelForCausalLM#1499VedantMadane wants to merge 1 commit intohuggingface:mainfrom
Conversation
|
Friendly ping - is there anything I can do to help move this PR forward? Happy to make any changes if needed. |
964bb1b to
5fff56a
Compare
|
Hi @VedantMadane, we just merged our v4 branch into main, which brings a lot of type improvements. Could you check if your changes are still needed? |
5fff56a to
3912f6e
Compare
|
Thanks for the heads-up! I've checked the latest \main\ branch. It looks like the changes to \AutoTokenizer.from_pretrained\ and \PreTrainedTokenizer.from_pretrained\ (making the \options\ parameter optional) are already included. However, the explicit \rom_pretrained\ override for \AutoModelForCausalLM\ with the JSDoc for proper TypeScript return type inference is still missing. This change is still needed to ensure correct type definitions are generated. I've updated this PR to only include the necessary changes for \AutoModelForCausalLM\ by rebasing onto the latest \main. |
|
Closing as changes are no longer valid (as of v4 update) and #1495 is closed. |
Description
This PR fixes incorrect TypeScript type definitions for
AutoTokenizerandAutoModelForCausalLM.Fixes #1495
Changes
src/models.js@type {typeof PreTrainedModel.from_pretrained}with full JSDoc documentation including proper parameter and return type annotationsfrom_pretrainedoverride with proper JSDoc to ensure TypeScript correctly types the return valuesrc/tokenizers.js@param {PretrainedTokenizerOptions} optionsto@param {PretrainedTokenizerOptions} [options]to correctly mark as optionalType Generation
After running
npm run typegen, the generated.d.tsfiles now correctly show:from_pretrainedmethods with optional options parameter (?)Promise<PreTrainedTokenizer>andPromise<PreTrainedModel>)Testing
Created a TypeScript test file to validate the fixes - compilation succeeded with no errors.