bun_python icon indicating copy to clipboard operation
bun_python copied to clipboard

Provide documentation for instructions to call a python function with named parameters

Open mighty-phoenix opened this issue 11 months ago • 2 comments

Could not download 'speaker-diarization-3.1' pipeline.
It might be because the pipeline is private or gated so make
sure to authenticate. Visit https://hf.co/settings/tokens to
create your access token and retry with:

   >>> Pipeline.from_pretrained('speaker-diarization-3.1',
   ...                          use_auth_token=YOUR_AUTH_TOKEN)

I tried several patterns and failed to figure how to call the function correctly. Here is the code I was trying:

// Assign speaker labels
const diarizeModel = this.whisperx.DiarizationPipeline("speaker-diarization-3.1", {use_auth_token: process.env.HF_TOKEN})

I also tried using kw to pass the use_auth_token param but still failed.

const diarizeModel = this.whisperx.DiarizationPipeline("speaker-diarization-3.1", kw`use_auth_token=${process.env.HF_TOKEN}`)

Quick advice would be highly appreciated. Thanks!

mighty-phoenix avatar Jan 28 '25 14:01 mighty-phoenix

@codehz

mighty-phoenix avatar Jan 28 '25 14:01 mighty-phoenix

try basic test code:

const { Test } = python.runModule(`
class Test:
  def test(self, *args, **kwargs):
    return all([len(args) == 3, "name" in kwargs])
`);
    const t = new Test();

    const d = python.dict({ a: 1, b: 2 });
    const v = t.test(1, 2, kw`name=${"vampire"}`, d);
    console.log(v)

codehz avatar Jan 28 '25 15:01 codehz