Closed suchitra-30 closed 2 weeks ago
Hi @suchitra-30 can you please properly format the code in your issue by wrapping it inside triple backslashes and properly indenting so that we can try to reproduce the issue?
I have added in notebook with format - https://notepad.pw/XlR7rvKuGuSCRZFdsrEV, please check @abidlabs as in comment box its removing indentation
You have included private API keys, I highly encourage you to remove them if they are valid!
Its not valid still i have removed them with dummy value "xxxxxxxxxxxxx"
Hi @suchitra-30 ! The Cancel
button that comes with gr.Interface
is only meant to clear the UI. If you want to add custom functionality, I suggest you create your demo with the Blocks api and create a clear button that does what you would like!
@freddyaboulton, thank you for your guidance. I was wondering if there's a way to remove the default clear button from my code. Is that a possibility? Also, could you please share any blogs or resources that explain how to integrate a blog API in response to a chatbot?
Hi @suchitra-30 !
There isn't a way to remove the clear button from an interface I believe. So you would have to use the Blocks interface.
There is a series of guides in the gradio website about building chatbots. I recommend them! Here is the first one.
There are also ready-to-use templates in huggingface spaces for building chatbot demos that interface with the LLM via API.
Describe the bug
So basically i have made custom chatbot in which i have just added two input and one output but then it shows clear button and submit button default . Now i want to call my delete api on clear button click i have tried many ways but it will show me extra clear button which does the functionality but there default clear button is not working how can i use that to call my function here is the screenshot -
code - import gradio as gr import requests
API_KEY = "sec_jIePzZH" UPLOAD_URL = "https://api.chatpdf.com/v1/sources/add-file" CHAT_URL = "https://api.chatpdf.com/v1/chats/message"
def upload_pdf(pdf_file): files = {'file': ('file.pdf', pdf_file, 'application/octet-stream')} headers = {'x-api-key': API_KEY} response = requests.post(UPLOAD_URL, headers=headers, files=files) print(response.json()) if response.status_code == 200: print(response.json()["sourceId"]) return response.json()["sourceId"] else: return None
Function to send message to PDF
def send_message(source_id, message, include_references=False):
payload = {
Define the callback function for the chatbot
def chat_with_pdf(text, pdf_file, include_references=False):
Check if PDF file is provided
text_input = gr.Textbox("text", label="Enter your message here") file_input = gr.File(label="Upload PDF", type="binary")
with gr.Blocks() as chatbot_interface: chatbot = gr.Interface( fn=chat_with_pdf, inputs=[text_input, file_input], outputs="text", title="Multimodal Chatbot: PDF & Text", )
chatbot_interface.launch()
print("Chatbot interface launched successfully!")
Have you searched existing issues? 🔎
Reproduction
Screenshot
Logs
No response
System Info
Severity
I can work around it