Spaces:
Runtime error
Runtime error
feat: use the customized submit function
Browse files6 unmodified lines78910111213141516217 unmodified lines23423523623323723823924014 unmodified lines2552562572582592602612622632642652662672682692702712722732742752762772782792802542812822832846 unmodified linesimport random
import gradio as grfrom gradio.helpers import special_argsfrom gradio.routes import Requestimport anyio
from huggingface_hub import Repository, InferenceClientfrom utils import force_git_push
217 unmodified lines rtl=True, show_share_button=True, show_copy_button=True, layout="panel", #layout="panel", bubble_full_width = False)
textbox = gr.Textbox(14 unmodified lines placeholder="Who are you?", )
class ChatInterface(gr.ChatInterface(): async def _submit_fn( self, message: str, history_with_input: list[list[str | None]], request: Request, *args, ) -> tuple[list[list[str | None]], list[list[str | None]]]: history = history_with_input[:-1] inputs, _, _ = special_args( self.fn, inputs=[message, history, *args], request=request )
if self.is_async: response = await self.fn(*inputs) else: response = await anyio.to_thread.run_sync( self.fn, *inputs, limiter=self.limiter )
history.append([message, response]) return history, history
chat_interface = gr.ChatInterface(chat_interface = ChatInterface( generate, chatbot=chatbot, textbox=textbox,app.py+29-2