Skip to content

fix: correct type definitions for AutoTokenizer and AutoModelForCausalLM#1499

Open
VedantMadane wants to merge 1 commit intohuggingface:mainfrom
VedantMadane:fix/type-definitions-auto-classes
Open

fix: correct type definitions for AutoTokenizer and AutoModelForCausalLM#1499
VedantMadane wants to merge 1 commit intohuggingface:mainfrom
VedantMadane:fix/type-definitions-auto-classes

Conversation

@VedantMadane
Copy link

Description

This PR fixes incorrect TypeScript type definitions for AutoTokenizer and AutoModelForCausalLM.

Fixes #1495

Changes

src/models.js

  • PretrainedMixin.from_pretrained: Replaced @type {typeof PreTrainedModel.from_pretrained} with full JSDoc documentation including proper parameter and return type annotations
  • AutoModelForCausalLM: Added explicit from_pretrained override with proper JSDoc to ensure TypeScript correctly types the return value

src/tokenizers.js

  • PreTrainedTokenizer.from_pretrained: Changed @param {PretrainedTokenizerOptions} options to @param {PretrainedTokenizerOptions} [options] to correctly mark as optional
  • AutoTokenizer.from_pretrained: Same fix - marked options parameter as optional

Type Generation

After running npm run typegen, the generated .d.ts files now correctly show:

  • from_pretrained methods with optional options parameter (?)
  • Proper return types (Promise<PreTrainedTokenizer> and Promise<PreTrainedModel>)

Testing

Created a TypeScript test file to validate the fixes - compilation succeeded with no errors.

@VedantMadane
Copy link
Author

Friendly ping - is there anything I can do to help move this PR forward? Happy to make any changes if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect Type Definitions for AutoTokenizer and AutoModelForCausalLM

1 participant