import json import gradio as gr import pandas as pd from pages.summarization_playground import custom_css css = ''' .tooltip-wrapper { position: relative; display: inline-block; border-bottom: 1px dotted black; } .tooltip-wrapper .tooltip { visibility: hidden; width: 300px; # Increased width for longer prompts background-color: black; color: #fff; text-align: center; border-radius: 6px; padding: 5px; position: absolute; z-index: 1; bottom: 125%; left: 50%; margin-left: -150px; # Adjusted for new width opacity: 0; transition: opacity 0.3s; white-space: pre-wrap; # This allows text wrapping word-wrap: break-word; # This ensures long words don't overflow } .tooltip-wrapper:hover .tooltip { visibility: visible; opacity: 1; } ''' with open("prompt/prompt.json", "r") as file: json_data = file.read() prompts = json.loads(json_data)# Sample data for the leaderboard winning_rate = [prompt['metric']['winning_number'] for prompt in prompts] winning_rate = [num / sum(winning_rate) for num in winning_rate] data = { 'Rank': [i+1 for i in range(len(prompts))], 'Methods': [prompt['id'] for prompt in prompts], 'Rouge Score': [prompt['metric']['Rouge'] for prompt in prompts], 'Winning Rate': winning_rate, 'Authors': [prompt['author'] for prompt in prompts], 'Prompts': [prompt['prompt'] for prompt in prompts] } df = pd.DataFrame(data) df.sort_values(by='Rouge Score', ascending=False, inplace=True, ignore_index=True) df['Rank'] = range(1, len(df) + 1) # Define a list of medal emojis medals = ['🏅', '🥈', '🥉'] for i in range(3): df.loc[i, 'Authors'] = f"{medals[i]} {df.loc[i, 'Authors']}" def create_html_with_tooltip(text, tooltip): return f'''