Repository: gradio-app/gradio
Pull request: Fix accidental bug that prevented custom textboxes from being passed to chatinterface
## Description

Closes: #7781

## 🎯 PRs Should Target Issues

Before your create a PR, please check to see if there is [an existing issue](https://github.com/gradio-app/gradio/issues) for this change. If not, please create an issue before you create this PR, unless the fix is very small. 

Not adhering to this guideline will result in the PR being closed. 

## Tests

1. PRs will only be merged if tests pass on CI. To run the tests locally, please set up [your Gradio environment locally](https://github.com/gradio-app/gradio/blob/main/CONTRIBUTING.md) and run the tests: `bash scripts/run_all_tests.sh`

2. You may need to run the linters: `bash scripts/format_backend.sh` and `bash scripts/format_frontend.sh`
  


Problem statement:
Gradio gr.TextBox customization stopped working in gr.ChatInterface
### Describe the bug

The way to customize the textbox in gr.ChatInterface has stopped working since the new update.
The error I get is
```
Traceback (most recent call last):
  File "Test", line 268, in <module>
    c1 = gr.ChatInterface(chat,
         ^^^^^^^^^^^^^^^^^^^^^^
  File "Test\venv\Lib\site-packages\gradio\chat_interface.py", line 212, in __init__
    raise TypeError(
TypeError: Expected a gr.Textbox or gr.MultimodalTextbox component, but got <class 'gradio.components.textbox.Textbox'>
```

### Have you searched existing issues?  🔎

- [X] I have searched and found no existing issues

### Reproduction

```
import gradio as gr
def chat():
    return "Hello"
c1 = gr.ChatInterface(chat,
    chatbot=gr.Chatbot(height=400),
    textbox=gr.Textbox(placeholder="Type Message", container=False, scale=7),
    title="Test",
    examples=["Good Morning!", "Google en passant", "what is 899*99/21"],
    clear_btn="Clear",)
demo = gr.TabbedInterface([c1], ["Test"],theme=gr.themes.Soft())
demo.launch()
```

### Screenshot

_No response_

### Logs

_No response_

### System Info

```shell
Gradio Environment Information:
------------------------------
Operating System: Windows
gradio version: 4.22.0
gradio_client version: 0.13.0

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.2.0
fastapi: 0.109.2
ffmpy: 0.3.1
gradio-client==0.13.0 is not installed.
httpx: 0.26.0
huggingface-hub: 0.20.2
importlib-resources: 6.1.1
jinja2: 3.1.3
markupsafe: 2.1.3
matplotlib: 3.8.2
numpy: 1.26.2
orjson: 3.9.10
packaging: 23.2
pandas: 2.1.4
pillow: 10.2.0
pydantic: 2.5.3
pydub: 0.25.1
python-multipart: 0.0.9
pyyaml: 6.0.1
ruff: 0.2.2
semantic-version: 2.10.0
tomlkit==0.12.0 is not installed.
typer: 0.9.0
typing-extensions: 4.9.0
uvicorn: 0.25.0
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2023.12.2
httpx: 0.26.0
huggingface-hub: 0.20.2
packaging: 23.2
typing-extensions: 4.9.0
websockets: 11.0.3
```


### Severity

I can work around it

Hints from issue discussion:
Simple mistake @Rivridis - will have a fix soon

Commit message: add changeset

Patch to review:
diff --git a/.changeset/gold-suns-hang.md b/.changeset/gold-suns-hang.md
new file mode 100644
index 0000000000..01f196a48a
--- /dev/null
+++ b/.changeset/gold-suns-hang.md
@@ -0,0 +1,5 @@
+---
+"gradio": patch
+---
+
+fix:Fix accidental bug that prevented custom textboxes from being passed to chatinterface
diff --git a/gradio/chat_interface.py b/gradio/chat_interface.py
index 7999e4dab1..e0ea5d3d66 100644
--- a/gradio/chat_interface.py
+++ b/gradio/chat_interface.py
@@ -206,7 +206,7 @@ def __init__(
                         textbox.container = False
                         textbox.show_label = False
                         textbox_ = textbox.render()
-                        if not isinstance(textbox_, Textbox) or not isinstance(
+                        if not isinstance(textbox_, Textbox) and not isinstance(
                             textbox_, MultimodalTextbox
                         ):
                             raise TypeError(
diff --git a/test/test_chat_interface.py b/test/test_chat_interface.py
index 69d29847f7..924940d51d 100644
--- a/test/test_chat_interface.py
+++ b/test/test_chat_interface.py
@@ -56,6 +56,25 @@ def test_concurrency_limit(self):
         fns = [fn for fn in chat.fns if fn.name in {"_submit_fn", "_api_submit_fn"}]
         assert all(fn.concurrency_limit == 10 for fn in fns)
 
+    def test_custom_textbox(self):
+        def chat():
+            return "Hello"
+
+        gr.ChatInterface(
+            chat,
+            chatbot=gr.Chatbot(height=400),
+            textbox=gr.Textbox(placeholder="Type Message", container=False, scale=7),
+            title="Test",
+            clear_btn="Clear",
+        )
+        gr.ChatInterface(
+            chat,
+            chatbot=gr.Chatbot(height=400),
+            textbox=gr.MultimodalTextbox(container=False, scale=7),
+            title="Test",
+            clear_btn="Clear",
+        )
+
     def test_events_attached(self):
         chatbot = gr.ChatInterface(double)
         dependencies = chatbot.dependencies


Code review comments:
diff_hunk: @@ -206,7 +206,7 @@ def __init__(
                         textbox.container = False
                         textbox.show_label = False
                         textbox_ = textbox.render()
-                        if not isinstance(textbox_, Textbox) or not isinstance(
+                        if not isinstance(textbox_, Textbox) and not isinstance(
                             textbox_, MultimodalTextbox
                         ):
path: gradio/chat_interface.py
text: @user1:
nit: for conciseness:
```suggestion
                        if not isinstance(textbox_, (Textbox, MultimodalTextbox))
```

@author:
Yea agreed - thanks!