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

Client does not support default parameters in functions #3540

Closed
1 task done
dbalabka opened this issue Mar 20, 2023 · 3 comments · Fixed by #7732
Closed
1 task done

Client does not support default parameters in functions #3540

dbalabka opened this issue Mar 20, 2023 · 3 comments · Fixed by #7732
Assignees
Labels
bug Something isn't working gradio_client Related to the one of the gradio client libraries

Comments

@dbalabka
Copy link

dbalabka commented Mar 20, 2023

  • I have searched to see if a similar issue already exists.

Is your feature request related to a problem? Please describe.
Adding new input into gr.Interface leads to backward incompatible changes in API and leads to the following error:

{
  "error": "list index out of range"
}

In my particular case, I've added:

gr.Radio(["vtt", "txt", "srt", "tsv", "json"], value='vtt', label='Caption file format'),

This input has a default value and does not require input. Still, it leads to 500 Internal Server Error

Describe the solution you'd like
The simplest solution is to allow skipping the values with default values.

Additional context
Gradio version is 3.21.0

@abidlabs abidlabs changed the title Impossible to make BC changes in API Impossible to make backwards-compatible changes in API Mar 20, 2023
@abidlabs abidlabs added the enhancement New feature or request label Mar 20, 2023
@abidlabs
Copy link
Member

Hi @dbalabka I think the issue here is that setting a value in the gr.Radio does not make it a default value in your function. It only makes it the initially populated value in your UI. This is by design. If you want it to be the default value in your function, simply set it as such in your Python function. E.g. something like this:

def my_function(name, choice="vtt"):
   pass

Then your API should be backwards compatible. Lmk if this solves your problem.

@abidlabs abidlabs added pending clarification and removed enhancement New feature or request labels Mar 21, 2023
@dbalabka
Copy link
Author

@abidlabs, the default value present in the function's parameter :

def transcribe(
        language = 'auto',
        audio = None,
        audio_file = None,
        output_format = 'vtt',
)

Anyway, the API should not return the 500 error. It should be classified as 400 Bad requests instead.

@abidlabs abidlabs added bug Something isn't working and removed pending clarification labels Mar 27, 2023
@abidlabs abidlabs added this to the 3.x milestone Mar 27, 2023
@abidlabs abidlabs assigned aliabid94 and abidlabs and unassigned aliabid94 Apr 9, 2023
@abidlabs abidlabs changed the title Impossible to make backwards-compatible changes in API Client does not support default parameters in functions May 2, 2023
@abidlabs abidlabs added the gradio_client Related to the one of the gradio client libraries label May 2, 2023
@abidlabs abidlabs removed this from the 3.x milestone May 9, 2023
@abidlabs abidlabs removed their assignment Jan 3, 2024
@abidlabs abidlabs self-assigned this Mar 15, 2024
@abidlabs abidlabs added this to the Clients 1.0 📡 milestone Mar 15, 2024
@dbalabka
Copy link
Author

Thanks @abidlabs

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
3 participants