response / README.md
ramya-deepika's picture
readme.md
11a483e verified
|
Raw
History Blame Contribute Delete
1.06 kB

import gradio as gr

Assuming 'client', 'system', and 'respond' are defined elsewhere in your script

def clear_chat(): global chat chat = client.chata.create( model="gemini-2.5-flash", config={ "system_instruction": system } ) # Gradio blocks click functions expect returned updates to match the outputs list. # We return empty lists/None to clear the chatbot and state. return [], None

with gr.Blocks(title="AI Study Tutor") as demo: gr.Markdown("# Study Mate AI") gr.Markdown("Ask any study-related question")

# Note: If using an external state variable, you'll want to manage it in the interface
chotbot = gr.ChatInterface(
    fn=respond,
)

clear_btn = gr.Button("Clear Chat")

# Make sure the button variable matches (clear_btn) and Python's True is capitalized
clear_btn.click(
    fn=clear_chat,
    inputs=None,
    outputs=[chotbot, chotbot] # Adjust outputs based on what clear_chat returns
)

demo.launch(share=True)