Skip to content
This repository has been archived by the owner on Mar 2, 2023. It is now read-only.

Expected request with Content-Type: application/json #18

Open
Quatton opened this issue Mar 2, 2023 · 3 comments
Open

Expected request with Content-Type: application/json #18

Quatton opened this issue Mar 2, 2023 · 3 comments

Comments

@Quatton
Copy link

Quatton commented Mar 2, 2023

I tried

import HuggingFace from "huggingface";

const hf = new HuggingFace(process.env.HUGGINGFACE_TOKEN!);

hf.textGeneration({
  model: "google/flan-t5-xxl",
  inputs: "Hello world",
}).then((res) => {
  console.log(res);
})

First I got

SyntaxError: Unexpected token E in JSON at position 0
    at JSON.parse (<anonymous>)
...

Then I tried logging the res.text() and found:

Expected request with `Content-Type: application/json`

I think we should add that to request.

@TimMikeladze
Copy link
Owner

Hey @Quatton

Just a heads up, this package has been folded into the official hugginface.js repoand is already several updates ahead, specifically with fixes around handing binary responses. Consider downloading the latest version from there.

This bug may already been resolved in that version. I will be archiving this repo and deprecating the huggingface package in the very near future.

I'm keeping this issue open for the time being and will investigate / have a conclusion on this before archiving this repo.

@Quatton
Copy link
Author

Quatton commented Mar 2, 2023

Aw... Thank you!

@Quatton
Copy link
Author

Quatton commented Mar 2, 2023

Update:
I have tried the @huggingface/inference package, but the response was still Unexpected token E in JSON at position 0 (which is Expected request with Content-Type: application/json`.)

Upon investigation, this only occurs if I use google/flan-t5-xxl as a model, while gpt2 works perfectly fine.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants