File size: 989 Bytes
7acdd8f
a6692e9
a8a771c
a6692e9
 
 
 
 
 
4d32974
a6692e9
3ffcf44
a6692e9
 
 
 
82afe26
a6692e9
 
 
 
 
 
 
 
 
4d32974
 
d3c72fb
a6692e9
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import gradio as gr
from ai_model import query_ai_model  # Import AI model query function

# Function to handle chatbot conversation
def gradio_chatbot(text, history):
    history.append((text, None))
    response = asyncio.run(query_ai_model(text))
    history[-1] = (text, response)
    return history

# Gradio interface
def create_gradio_interface():
    chatbot = gr.Chatbot()
    textbox = gr.Textbox(placeholder="Ask a question and press Enter", show_label=False)
    
    # Set up the Gradio interface layout
    with gr.Blocks() as demo:
        gr.HTML("<h1>Unified Gemini Chatbot</h1>")
        chatbot.render()
        textbox.render()

        # Bind input textbox to chatbot response
        textbox.submit(
            fn=gradio_chatbot,
            inputs=[textbox, chatbot],
            outputs=chatbot
        )

    return demo

# Launch Gradio interface
def run_gradio_interface():
    interface = create_gradio_interface()
    interface.launch(share=True, debug=True)