Skip to content

Conversation

SBrandeis
Copy link
Contributor

No description provided.

Copy link
Member

@julien-c julien-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would maybe add one example of how a third-party provider can define their own snippet for one particular task

cc @julien-c 

Goal is to easily review inference snippets changes by generating and
committing the expected snippets that will be shown on the Hub. For now
mostly adapter for `"hf-inference"` provider + added 1 example with
`"replicate"`. In practice, we can add more examples once merged to
#1129

**How to use:**
1. Go to `@tasks-gen`

2. Edit `packages/tasks-gen/scripts/generate-snippets-fixtures.ts` to
add new examples
3. Run
```
pnpm run generate-snippets-fixtures
```
4. Use git diff to check difference => commit them

Afterwards, run tests (also done in CI)
```
pnpm test
```


**Note:** I haven't properly checked the snippets themselves. Will do it
once merged when reviewing
#1129.

---------

Co-authored-by: Julien Chaumond <[email protected]>
@julien-c julien-c marked this pull request as ready for review January 24, 2025 14:03
@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@SBrandeis SBrandeis self-assigned this Jan 24, 2025
content: `async function query(data) {
const client = new HfInference("${accessToken || `{API_TOKEN}`}");
const image = await client.textToImage({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

root-level await statements are not supported by all the usual JS runtimes

provider: InferenceProvider
): InferenceSnippet[] => {
return [
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep this?
If yes, let's add install instructions to other snippets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this = snippet.setup installation instructions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(removed it)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes fine to remove imo

@SBrandeis SBrandeis changed the title wip: inference snippets for 3rd party providers [Inference] Update snippets Jan 24, 2025
@SBrandeis SBrandeis merged commit 86abcb2 into main Jan 24, 2025
6 checks passed
@SBrandeis SBrandeis deleted the inference/providers-snippets branch January 24, 2025 15:50
Copy link
Contributor

@Wauplin Wauplin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 (only checked Python snippets)

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.

4 participants