Open taoari opened 3 days ago
When set type="messages" for ChatInterface. In the GUI, history is in messages format, but from API call, history is in tuples format.
import gradio as gr def echo(message, history): print(message, history) return message demo = gr.ChatInterface(fn=echo, type='messages', title="Echo Bot") demo.launch()
from gradio_client import Client client = Client("http://localhost:7860/") result = client.predict( message="Hello!!", api_name="/chat" ) print(result) result = client.predict( message="Hello again!!", api_name="/chat" ) print(result)
The following is from Gradio Web:
hello [] hello2 [{'role': 'user', 'metadata': {'title': None}, 'content': 'hello'}, {'role': 'assistant', 'metadata': {'title': None}, 'content': 'hello'}]
The following is from gradio_client:
Hello!! [] Hello again!! [['Hello!!', 'Hello!!']]
where history format is inconsistent.
No response
Gradio Environment Information: ------------------------------ Operating System: Darwin gradio version: 4.44.0 gradio_client version: 1.3.0 ------------------------------------------------ gradio dependencies in your environment: aiofiles: 23.2.1 anyio: 4.4.0 fastapi: 0.112.2 ffmpy: 0.4.0 gradio-client==1.3.0 is not installed. httpx: 0.27.0 huggingface-hub: 0.24.6 importlib-resources: 6.4.0 jinja2: 3.1.4 markupsafe: 2.1.5 matplotlib: 3.9.2 numpy: 1.26.4 orjson: 3.10.7 packaging: 24.1 pandas: 2.2.2 pillow: 10.4.0 pydantic: 2.8.2 pydub: 0.25.1 python-multipart: 0.0.9 pyyaml: 6.0.2 ruff: 0.6.2 semantic-version: 2.10.0 tomlkit==0.12.0 is not installed. typer: 0.12.5 typing-extensions: 4.11.0 urllib3: 2.2.2 uvicorn: 0.30.6 authlib; extra == 'oauth' is not installed. itsdangerous; extra == 'oauth' is not installed. gradio_client dependencies in your environment: fsspec: 2024.5.0 httpx: 0.27.0 huggingface-hub: 0.24.6 packaging: 24.1 typing-extensions: 4.11.0 websockets: 12.0
Blocking usage of gradio
Thanks @taoari for flagging this!
Describe the bug
When set type="messages" for ChatInterface. In the GUI, history is in messages format, but from API call, history is in tuples format.
Have you searched existing issues? ๐
Reproduction
The following is from Gradio Web:
The following is from gradio_client:
where history format is inconsistent.
Screenshot
No response
Logs
No response
System Info
Severity
Blocking usage of gradio