Aalexbit-codemod

move-sampling-to-model-options

Move TanStack AI root sampling props into provider-native modelOptions

tanstacktanstack-aimodelOptionsmigrationtransformation
Public
2 executions

Run locally

npx codemod move-sampling-to-model-options

move-sampling-to-model-options

Moves root-level temperature / topP / maxTokens off chat() / ai() / generate() / createChatOptions() into provider-native modelOptions, renaming each key per provider resolved from adapter: <factory>(...).

For ollama, renamed keys nest under modelOptions.options. Calls with an unresolvable adapter, non-literal modelOptions, or a key conflict are left untouched and reported.

Callee and adapter-factory origin use JSSG semantic analysis (definition()), so this also covers cases the jscodeshift port misses:

  • Helper import aliasesimport { chat as runChat } from '@tanstack/ai'
  • Helper barrel re-exportsexport { chat } from '@tanstack/ai' then import from ./ai
  • Adapter factory aliases / barrelsimport { openaiText as createOpenAI } or export { openaiText as createOpenAI } from '@tanstack/ai-openai'

Object rebuilds preserve spreads and string/computed keys (no silent property drops when moving sampling props).

Run

bash

Development

bash

License

MIT

Ready to contribute?

Build your own codemod and share it with the community.