gradio-app / gradio

Build and share delightful machine learning apps, all in Python. 🌟 Star to support our work!
http://www.gradio.app
Apache License 2.0
30.56k stars 2.27k forks source link

gradio_client with remote HF private instance #8564

Closed tomerkulla closed 5 days ago

tomerkulla commented 1 week ago

Describe the bug

Hello I trying to request my private HF space gradio via python gardio_client and I'm getting error that my MultimodalTextbox is str while it's defently dict

this is the init on the HF space side:

demo = gr.ChatInterface(fn=bot_streaming, title="Heello",  description="Hello",
  | stop_btn="Stop Generation", multimodal=True)

this is how I call it on python script side:

gradioClient = Client("...", hf_token="....")

result2 = gradioClient.predict(
        {"text":"sample text","files":[file("examples/image2.jpg")]},
        api_name="/chat"
)

the error I get on the script side:

line 1228, in _predict
    raise AppError(
gradio_client.exceptions.AppError: The upstream Gradio app has raised an exception: MultimodalTextbox expects a dictionary with optional keys 'text' and 'files'. Received str

on the HF logs side I get something similar:

ValueError: MultimodalTextbox expects a dictionary with optional keys 'text' and 'files'. Received str
{'text': 'sample text', 'files': [{'path': '/tmp/gradio/92bcb021af1315abcd6ab08f98c8da2b340fed5e/image2.jpg', 'url': '/file=/tmp/gradio/92bcb021af1315abcd6ab08f98c8da2b340fed5e/image2.jpg', 'size': None, 'orig_name': 'image2.jpg', 'mime_type': None, 'is_stream': False, 'meta': {'_type': 'gradio.FileData'}}]}
Setting `pad_token_id` to `eos_token_id`:2 for open-end generation.

Have you searched existing issues? 🔎

Reproduction

mentioned above

Screenshot

No response

Logs

No response

System Info

on script side:
gradio==4.36.1
gradio_client==1.0.1

on HF space side: (not sure if I can upgrade the version there?)
gradio==4.22.0

Severity

Blocking usage of gradio

abidlabs commented 6 days ago

Hi @tomerkulla I'm not able to reproduce this when I test on main:

import gradio as gr

_, url, _ = gr.ChatInterface(lambda x,y: x).launch(inline=False, show_error=True)

from gradio_client import Client, file

gradioClient = Client(url)

result2 = gradioClient.predict(
        {"text":"sample text","files":[file("cheetah.jpg")]},
        api_name="/chat"
)
abidlabs commented 5 days ago

I'm going to close this for now, but can reopen if still an issue.