# components.py - Enhanced with Rating and Bookmarking Features import streamlit.components.v1 as components import html import uuid def render_response_box(response_text, response_id): """Original render response box for backward compatibility""" escaped_text = html.escape(response_text) components.html(f"""
💬 Response
{escaped_text}
Copied to clipboard ✅
""", height=320) def render_enhanced_response_box(response_text, message_id, session_id, is_bookmarked=False, rating=None, show_actions=True): """Enhanced response box with rating and bookmarking features""" escaped_text = html.escape(response_text) # Rating button states thumbs_up_class = "rating-active" if rating == 1 else "" thumbs_down_class = "rating-active" if rating == -1 else "" # Bookmark button state bookmark_icon = "🔖" if is_bookmarked else "📑" bookmark_class = "bookmark-active" if is_bookmarked else "" action_buttons = "" if show_actions: action_buttons = f"""
""" components.html(f"""
💬 AI Response {action_buttons}
{escaped_text}
Action completed ✅
""", height=400) def render_typing_animation(text, response_id): """Render typing animation for the response""" escaped_text = html.escape(text) return f'''
💬 AI Response
{escaped_text}
'''