Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JS inference API code snippet #495

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Fix JS inference API code snippet #495

wants to merge 1 commit into from

Conversation

xenova
Copy link
Contributor

@xenova xenova commented Feb 21, 2024

Fixes the following issues:

  1. JS code snippets missing "Content-Type": "application/json",, leading to an error
  2. Align closer to python snippet (e.g., API_URL outside of query)
  3. Indentation in certain nodes, e.g., here.
    image

TODOs/questions

  • Is there a way to preview the outputs to make sure it renders correctly?
  • For some reason, the python snippet still outputs API_URL and headers if body is empty, so I've done the same here (for now)

body: data,
}
);
${fetchSnippet(accessToken)}
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we should change snipperFile since it doesn't send a json body but raw bytes from a file (typically an audio or image file).

: "";

return `const API_URL = "https://api-inference.huggingface.co/models/${model.id}"
const HEADERS = {"Authorization": ${accessToken ? `"Bearer ${accessToken}"` : `f"Bearer {API_TOKEN}"`}}
Copy link
Contributor

Choose a reason for hiding this comment

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

If we define HEADERS here, shouldn't we reuse it in fetchSnippet?
To do that, you would need to define "json headers" and "non-json headers" separately and inject the correct one depending on the task.

@xenova xenova marked this pull request as draft March 6, 2024 16:15
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.

None yet

3 participants