import gradio as gr import pandas as pd import numpy as np import random def show_stars(): """ Function that shows the HTML script for stars -Janika""" stars_html = """
""" return stars_html # Random data for testing, actual data added later df = pd.DataFrame({ 'Year': np.random.randint(2000, 2024, 25), 'Reviews': np.random.randint(120, 320, 25), }) # Function to handle feedback submission -Piitu def handle_feedback(feedback, name): return f"Thank you for your feedback, {name}!" # Function to update placeholder text -Piitu def update_placeholder(name): if name: return f"Enter your feedback here, {name}..." else: return "Enter your feedback here..." # Theme theme = gr.themes.Soft( primary_hue="yellow", secondary_hue="amber", spacing_size="sm", radius_size="lg", ) with gr.Blocks(theme=theme) as demo: # Basic user interface for company's view -Janika with gr.Tab("User Interface"): with gr.Row(): with gr.Column(scale=1, min_width=300): # Summary summary_output = gr.Textbox(label="Summary") with gr.Column(scale=2, min_width=300): # Star rating star_rating = gr.HTML(value=show_stars()) # Keywords keywords_output = gr.Textbox(label="Keywords") # Testing Area -Piitu with gr.Tab("Testing Area"): with gr.Row(): name_input = gr.Textbox(label="Enter your name", placeholder="Enter your name here...") with gr.Row(): text_input = gr.Textbox(label="Please give us feedback!", placeholder="Enter your feedback here...", max_length=5000) # Update placeholder based on name input -Piitu name_input.change(fn=update_placeholder, inputs=name_input, outputs=text_input) # Send button -Piitu send_button = gr.Button("Send") # Output for feedback submission confirmation -Piitu feedback_output = gr.Textbox(label="Submission Result", interactive=False) # Link button to function that handles feedback submission -Piitu send_button.click(handle_feedback, inputs=[text_input, name_input], outputs=feedback_output) demo.launch()