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
34.24k stars 2.6k forks source link

Expected 3 arguments for function ChatInterface #10057

Open csanadpoda opened 1 day ago

csanadpoda commented 1 day ago

Describe the bug

I'm trying to use Chatinterface as follows:

        gr.ChatInterface(
            type="messages",
            fn=partial(chat, args=args),
            chatbot=chatbot,
            textbox=message_box,
            theme="soft",
            cache_examples=True,
        )

This causes a warning when I'm running the solution.


> Gradio version: 5.6.0
> Application is starting...
> /usr/local/lib/python3.10/dist-packages/gradio/utils.py:999: UserWarning: Expected 3 arguments for function <function ChatInterface._setup_api.<locals>.api_fn at 0x7f225c67c8b0>, received 2.
> warnings.warn(
> /usr/local/lib/python3.10/dist-packages/gradio/utils.py:1003: UserWarning: Expected at least 3 arguments for function <function ChatInterface._setup_api.<locals>.api_fn at 0x7f225c67c8b0>, received 2.

This is a bit confusing as the docs for 5.6.0 explicitly say

Only one parameter is required: fn, which takes a function that governs the response of the chatbot based on the user input and chat history.

Have you searched existing issues? 🔎

Reproduction

import gradio as gr

gr.ChatInterface(
            type="messages",
            fn=partial(chat, args=args),
            chatbot=chatbot,
            textbox=message_box,
            theme="soft",
            cache_examples=True,
        )
#use whatever chat fn

Screenshot

No response

Logs

No response

System Info

Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 5.6.0
gradio_client version: 1.4.3

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
anyio: 4.6.0
audioop-lts is not installed.
fastapi: 0.115.5
ffmpy: 0.4.0
gradio-client==1.4.3 is not installed.
httpx: 0.27.2
huggingface-hub: 0.25.2
jinja2: 3.1.2
markupsafe: 2.1.2
numpy: 1.24.3
orjson: 3.10.7
packaging: 23.1
pandas: 2.2.3
pillow: 9.3.0
pydantic: 2.9.2
pydub: 0.25.1
python-multipart==0.0.12 is not installed.
pyyaml: 6.0
ruff: 0.6.9
safehttpx: 0.1.1
semantic-version: 2.10.0
starlette: 0.41.3
tomlkit==0.12.0 is not installed.
typer: 0.12.1
typing-extensions: 4.12.2
urllib3: 2.2.3
uvicorn: 0.31.1
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.

gradio_client dependencies in your environment:

fsspec: 2023.6.0
httpx: 0.27.2
huggingface-hub: 0.25.2
packaging: 23.1
typing-extensions: 4.12.2
websockets: 12.0

Severity

I can work around it

abidlabs commented 11 hours ago

Can you provide a complete minimal repro? Here, chat is not defined so not clear what the underlying issue is. Thanks!