Closed nav1402 closed 1 year ago
Hi @nav1402 can you please provide a full, self-contained example we can test to reproduce this issue?
We used the code mentioned. Callingfunction has some raw text and text is sent to open ai LLM API. However in this it doesn’t even call the calling function as it doesn’t print any print statements inside calling function . This usually happen when there is time gap between 2 questions in the chatbot. Not sure if there is timeout issue here. This is causing user experience issues.
@abidlabs
The code here is incomplete. For example, chatbot
is not defined.
I did put complete code previously but somehow it got cropped. Attached shows how we need to reenter the prompt twice.
def addText(user_message, history):
return "", history + [[user_message, None]]
def callingfunction(history):
return "Test"
with gr.Blocks() as demo:
gr.Markdown("##Chatbot")
with gr.Tabs():
# Generating Code
with gr.TabItem("Testing"):
chatbot = gr.Chatbot()
text_input_3 = gr.Textbox(
label='Chatbot Assistant',
placeholder="Enter your message here"
)
clear = gr.Button("Clear")
txt_msg = text_input_3.submit(addText, [text_input_3, chatbot], [text_input_3, chatbot], queue=False).then(
callingfunction, chatbot, chatbot
)
txt_msg.then(
lambda: gr.update(
value="",
interactive=True,
placeholder="Enter your question",
show_label=True,
label="Enter your question",
),
None,
text_input_3,
queue=False,
)
clear.click(lambda: None, None, chatbot, queue=False)
demo.launch()
@abidlabs
Hi @nav1402 this is still incomplete code. For example, the method user()
is not defined. Can you please provide the complete code so that I can run it on my end?
I have updated the code. Complete code has lot of custom logic.
@abidlabs
Complete code has lot of custom logic
I understand. But we will need some sort of self-contained example we can run on our own end to investigate the bug. Right now, getting:
NameError: name 'chatgpt' is not defined
Can you please ensure that your code actually fully runs?
The other thing I will recommend to you is to check out the ChatInterface
class, which provides a clean abstraction over a lot of this code, and might solve the issue you are facing. The ChatInterface
is described here: https://www.gradio.app/guides/creating-a-chatbot-fast
Closing for lack of follow up
Describe the bug
Sometimes chat question doesn't provide any response and come out immediately and I need to reenter the question again. Is there a existing fix for this problem?
Have you searched existing issues? 🔎
Reproduction
text_input = gr.Textbox( label='Chatbot Assistant', placeholder="Enter your message here" )
)
Screenshot
No response
Logs
No response
System Info
Severity
Blocking usage of gradio