-
Notifications
You must be signed in to change notification settings - Fork 314
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move inference snippets logic to inference package (#1247)
_Original slack message from @Wauplin ([private link](https://huggingface.slack.com/archives/C04PJ0H35UM/p1740673808170509)):_ > I have an annoying problem I don't know how to handle in `@hugingface.js`. I'm working on updating the inference snippets under `@tasks` . Now that we have a `makeUrl` helper for each provider (see [cohere example](https://github.com/huggingface/huggingface.js/blob/b5230f9cbe71348014f39fd3a8149979cc10c196/packages/inference/src/providers/cohere.ts#L34)), I want to use it in the CURL snippets to display to correct URL (for now it's hardcoded [here](https://github.com/huggingface/huggingface.js/blob/b5230f9cbe71348014f39fd3a8149979cc10c196/packages/tasks/src/snippets/curl.ts#L46) which is incorrect for some providers). To do that, I need to make `@tasks` depend on `@inference` . But `@inference` is already depending on `@tasks` especially to type inference inputs/outputs. Is this something npm/pnpm is able to settle (in Python it's not ^^). > > The other solution I'm thinking about is to start having a `@snippets` package depending on both `@tasks` and `@inference` but I'd like to avoid that as much as possible 🙈 Any idea? => after some discussions we went for "let's move the `snippets` code to `inference`" which this PR does. @julien-c @coyotte508⚠️ **This is a breaking change for @huggingface.js/tasks.** Will require to make a major release? ---- In practice I had to move only parts of the `./snippets` folder: - the type definitions + utils remains in `@tasks` since it is used to generate some local app snippets - only the js/python/curl -specific parts are moved to `@inference` => i.e. only the logic to generate the snippets, not the helpers
- Loading branch information
Showing
10 changed files
with
60 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 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
16 changes: 10 additions & 6 deletions
16
packages/tasks/src/snippets/curl.ts → packages/inference/src/snippets/curl.ts
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import * as curl from "./curl.js"; | ||
import * as python from "./python.js"; | ||
import * as js from "./js.js"; | ||
|
||
export { curl, python, js }; |
16 changes: 10 additions & 6 deletions
16
packages/tasks/src/snippets/js.ts → packages/inference/src/snippets/js.ts
This file contains 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
16 changes: 10 additions & 6 deletions
16
packages/tasks/src/snippets/python.ts → packages/inference/src/snippets/python.ts
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,7 +1,3 @@ | ||
import * as inputs from "./inputs.js"; | ||
import * as curl from "./curl.js"; | ||
import * as python from "./python.js"; | ||
import * as js from "./js.js"; | ||
export * from "./common.js"; | ||
export * from "./inputs.js"; | ||
export * from "./types.js"; | ||
|
||
export { inputs, curl, python, js }; |