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

Error using Gradio JavaScript client with Vite.js #9310

Open
1 task done
Raf-sns opened this issue Sep 10, 2024 · 2 comments
Open
1 task done

Error using Gradio JavaScript client with Vite.js #9310

Raf-sns opened this issue Sep 10, 2024 · 2 comments
Labels
bug Something isn't working gradio_client Related to the one of the gradio client libraries

Comments

@Raf-sns
Copy link

Raf-sns commented Sep 10, 2024

Describe the bug

Hi,
I'm trying the Gradio JavaScript client with Vite.js.
I created a new project with vite/JavaScript/Vanilla
I ran the command npm i @gradio/client
I ran the project build with the command npm install
I created a main.js file where I copied a basic example from the documentation:

main.js

import './style.css'
import javascriptLogo from './javascript.svg'
import viteLogo from '/vite.svg'
import { Client, handle_file } from "@gradio/client";

const response = await fetch(
	"https://github.com/audio-samples/audio-samples.github.io/raw/master/samples/wav/ted_speakers/SalmanKhan/sample-1.wav"
);
const audio_file = await response.blob();

const app = await Client.connect("abidlabs/whisper");
const transcription = await app.predict("/predict", [handle_file(audio_file)]);

console.log(transcription.data);

I get the following error:
Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@gradio_client.js?v=0cabf73f' does not provide an export named 'handle_file' (at main.js? [sm]:4:18)

I am new to Node.js,
Thank you for your help or comments.
Sincerely,
Raf

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

import gradio as gr

Screenshot

No response

Logs

No response

System Info

npm i -D @gradio/client

Severity

Blocking usage of gradio

@Raf-sns Raf-sns added the bug Something isn't working label Sep 10, 2024
@pngwn
Copy link
Member

pngwn commented Sep 10, 2024

Can you please paste your package.json and vite config file in a reply (if you have them).

Thanks.

@Raf-sns
Copy link
Author

Raf-sns commented Sep 10, 2024

Hi,
Thanks for your help.
My package.json file :

{
  "name": "gradio",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "preview": "vite preview"
  },
  "devDependencies": {
    "@gradio/client": "^0.17.0",
    "vite": "^5.4.1"
  }
}

I don't have some vite.config.js file.
Regards,
Raf

@abidlabs abidlabs changed the title Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/@gradio_client.js?v=0cabf73f' does not provide an export named 'handle_file' Error using Gradio JavaScript client with Vite.js Sep 10, 2024
@abidlabs abidlabs added the gradio_client Related to the one of the gradio client libraries label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working gradio_client Related to the one of the gradio client libraries
Projects
None yet
Development

No branches or pull requests

3 participants