Spaces:
Runtime error
Runtime error
feat: use the customized submit function
Browse files6 unmodified lines789101112217 unmodified lines23023123223323423523614 unmodified lines2512522532542552562576 unmodified linesimport randomimport gradio as grfrom huggingface_hub import Repository, InferenceClientfrom utils import force_git_push217 unmodified linesrtl=True,show_share_button=True,show_copy_button=True,layout="panel",bubble_full_width = False)textbox = gr.Textbox(14 unmodified linesplaceholder="Who are you?",)chat_interface = gr.ChatInterface(generate,chatbot=chatbot,textbox=textbox,6 unmodified lines78910111213141516217 unmodified lines23423523623723823924014 unmodified lines2552562572582592602612622632642652662672682692702712722732742752762772782792802812822832846 unmodified linesimport randomimport gradio as grfrom gradio.helpers import special_argsfrom gradio.routes import Requestimport anyiofrom huggingface_hub import Repository, InferenceClientfrom utils import force_git_push217 unmodified linesrtl=True,show_share_button=True,show_copy_button=True,#layout="panel",bubble_full_width = False)textbox = gr.Textbox(14 unmodified linesplaceholder="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, historychat_interface = ChatInterface(generate,chatbot=chatbot,textbox=textbox,
app.py+29-2