Spaces:
Runtime error
Question on 'Use via API'
Hi! Thank you for making this great work available! I have two questions on querying the demo via the API。
What's the difference between the endpoints with fn_index=3, fn_index=4, fn_index=6?
In the 'Use via API' doc, I'm not sure what it means by
"Null", # str (filepath to JSON file) in 'IDEFICS' Chatbot component
. Do I need to replace the "Null" with some specific JSON file and if so, where can I find it? If I run the code snippet below, I get an[Errno 2] No such file or directory: 'Null'
Any help will be much appreciated!
from gradio_client import Client
client = Client("https://huggingfacem4-idefics-playground.hf.space/")
result = client.predict(
"HuggingFaceM4/idefics-80b-instruct", # str (Option from: ['HuggingFaceM4/idefics-80b-instruct'])
in 'Model' Dropdown component
"Howdy!", # str in 'Text input' Textbox component
"null", # str (filepath to JSON file)
in 'IDEFICS' Chatbot component
"https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image)
in 'Image input' Image component
"Greedy", # str in 'Decoding strategy' Radio component
0, # int | float (numeric value between 0.0 and 5.0)
in 'Sampling temperature' Slider component
8, # int | float (numeric value between 8 and 1024)
in 'Maximum number of new tokens to generate' Slider component
0.01, # int | float (numeric value between 0.01 and 5.0)
in 'Repetition penalty' Slider component
0.01, # int | float (numeric value between 0.01 and 0.99)
in 'Top P' Slider component
fn_index=3
)
print(result)
Hi! Thank you for making this great work available! I have two questions on querying the demo via the API。
What's the difference between the endpoints with fn_index=3, fn_index=4, fn_index=6?
In the 'Use via API' doc, I'm not sure what it means by
"Null", # str (filepath to JSON file) in 'IDEFICS' Chatbot component
. Do I need to replace the "Null" with some specific JSON file and if so, where can I find it? If I run the code snippet below, I get an[Errno 2] No such file or directory: 'Null'
Any help will be much appreciated!
from gradio_client import Client client = Client("https://huggingfacem4-idefics-playground.hf.space/") result = client.predict( "HuggingFaceM4/idefics-80b-instruct", # str (Option from: ['HuggingFaceM4/idefics-80b-instruct']) in 'Model' Dropdown component "Howdy!", # str in 'Text input' Textbox component "null", # str (filepath to JSON file) in 'IDEFICS' Chatbot component "https://raw.githubusercontent.com/gradio-app/gradio/main/test/test_files/bus.png", # str (filepath or URL to image) in 'Image input' Image component "Greedy", # str in 'Decoding strategy' Radio component 0, # int | float (numeric value between 0.0 and 5.0) in 'Sampling temperature' Slider component 8, # int | float (numeric value between 8 and 1024) in 'Maximum number of new tokens to generate' Slider component 0.01, # int | float (numeric value between 0.01 and 5.0) in 'Repetition penalty' Slider component 0.01, # int | float (numeric value between 0.01 and 0.99) in 'Top P' Slider component fn_index=3 ) print(result)
I have the same problem. Also, I try to replace "null" by None. but still not working
perhaps @jbilcke-hf who (as far as i remember) used the idefics_payground space as an API recently could guide here?
Running into this same issue
Putting a path to a blank JSON in this field outputs this result:
Loaded as API: https://huggingfacem4-idefics-playground.hf.space/ ✔
('', None, '/tmp/gradio/tmp3w803ful.json')
@ysharma @jbilcke-hf Do you have any insights?
Hi,
For my own use case I had other issues with the NodeJS version of the Gradio client:
node_modules/@gradio/client/dist/index.js:705
return data.map((d, i) => {
^
TypeError: Cannot read properties of null (reading 'is_file')
at node_modules/@gradio/client/dist/index.js:713:43
at Array.map (<anonymous>)
at transform_output (node_modules/@gradio/client/dist/index.js:705:15)
so in the end and to unstuck myself, I used Puppeeter to call IDEFICS, but this is too hacky so I can't reasonably recommend it to anyone (it relies on the UI and has a lot of memory and latency overhead)
I think the best here would be to fork the Space or open a new PR to modify the code and expose a new function in the Gradio space dedicated to API usage, with a simpler API (no temp file paths but return the value in plain text etc)