diff --git a/week2/community-contributions/day_5_figma_assistance.ipynb b/week2/community-contributions/day_5_figma_assistance.ipynb index bb30876..d563a0a 100644 --- a/week2/community-contributions/day_5_figma_assistance.ipynb +++ b/week2/community-contributions/day_5_figma_assistance.ipynb @@ -98,86 +98,8 @@ " print(f\"Error generating audio with OpenAI: {str(e)}\")\n", " return None\n", "\n", - "# def talker_gemini(message):\n", - "# \"\"\"Generate audio from text using Gemini TTS\"\"\"\n", - "# try:\n", - "# # Try the newer Gemini 2.0 TTS API\n", - "# model = google.generativeai.GenerativeModel(gemini_model)\n", - " \n", - "# # Truncate message for TTS\n", - "# truncated_message = truncate_for_tts(message)\n", - " \n", - "# # Generate audio using Gemini with simplified config\n", - "# response = model.generate_content(\n", - "# truncated_message,\n", - "# generation_config={\n", - "# \"response_modalities\": [\"AUDIO\"]\n", - "# }\n", - "# )\n", - " \n", - "# # Check if response has audio data\n", - "# if hasattr(response, 'audio_data') and response.audio_data:\n", - "# output_filename = \"output_audio_gemini.wav\"\n", - "# with open(output_filename, \"wb\") as f:\n", - "# f.write(response.audio_data)\n", - "# return output_filename\n", - "# else:\n", - "# print(\"Gemini response does not contain audio data\")\n", - "# raise Exception(\"No audio data in Gemini response\")\n", - " \n", - "# except Exception as e:\n", - "# print(f\"Error generating audio with Gemini: {str(e)}\")\n", - "# print(\"Gemini TTS not available, using OpenAI TTS with different voice\")\n", - "# # Use OpenAI TTS but with a different voice to distinguish\n", - "# try:\n", - "# # Truncate message for TTS\n", - "# truncated_message = truncate_for_tts(message)\n", - " \n", - "# response = client.audio.speech.create(\n", - "# model=\"tts-1\",\n", - "# voice=\"alloy\", # Different voice to indicate it's for Gemini responses\n", - "# input=truncated_message\n", - "# )\n", - "# audio_stream = BytesIO(response.content)\n", - "# output_filename = \"output_audio_gemini_fallback.mp3\"\n", - "# with open(output_filename, \"wb\") as f:\n", - "# f.write(audio_stream.read())\n", - "# return output_filename\n", - "# except Exception as fallback_error:\n", - "# print(f\"Fallback TTS also failed: {str(fallback_error)}\")\n", - "# return None\n", - "\n", - "# def talker_claude(message):\n", - "# \"\"\"Generate audio from text using Claude TTS (fallback to OpenAI)\"\"\"\n", - "# try:\n", - "# # Truncate message for TTS\n", - "# truncated_message = truncate_for_tts(message)\n", - " \n", - "# # Claude doesn't have native TTS, so we'll use OpenAI TTS\n", - "# # but with a different filename to distinguish\n", - "# response = client.audio.speech.create(\n", - "# model=\"tts-1\",\n", - "# voice=\"nova\", # Different voice for Claude responses\n", - "# input=truncated_message\n", - "# )\n", - "\n", - "# audio_stream = BytesIO(response.content)\n", - "# output_filename = \"output_audio_claude.mp3\"\n", - "# with open(output_filename, \"wb\") as f:\n", - "# f.write(audio_stream.read())\n", - "\n", - "# return output_filename\n", - "# except Exception as e:\n", - "# print(f\"Error generating audio for Claude: {str(e)}\")\n", - "# return None\n", - "\n", "def talker(message, model_choice):\n", " \"\"\"Generate audio from text using selected model\"\"\"\n", - " # if model_choice == \"Google Gemini (2.0 Flash)\":\n", - " # return talker_gemini(message)\n", - " # elif model_choice == \"Claude (Sonnet 4)\":\n", - " # return talker_claude(message)\n", - " # else:\n", " return talker_openai(message)\n", "\n", "def get_figma_help_openai(user_question, chat_history):\n", @@ -287,16 +209,13 @@ " else:\n", " return \"Please select a valid model.\"\n", "\n", - "\n", "custom_css = \"\"\"\n", - "\n", "/* Chat area styling */\n", ".styled-chat {\n", " border-radius: 15px !important;\n", " box-shadow: 0 4px 12px var(--shadow-color) !important;\n", " border: 1px solid var(--border-color) !important;\n", " padding: 10px;\n", - " # background-color: #fff;\n", "}\n", "\n", "/* Audio player styling */\n", @@ -307,45 +226,136 @@ " padding: 10px;\n", " background-color: var(--background-fill-secondary) !important;\n", "}\n", + "\n", + "/* Header styling */\n", + ".header-container {\n", + " text-align: center;\n", + " padding: 20px;\n", + " background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);\n", + " border-radius: 15px;\n", + " margin-bottom: 20px;\n", + "}\n", + "\n", + ".header-title {\n", + " color: white;\n", + " margin: 0;\n", + " font-size: 2.5em;\n", + "}\n", + "\n", + ".header-subtitle {\n", + " color: #f0f0f0;\n", + " margin: 10px 0 0 0;\n", + " font-size: 1.2em;\n", + "}\n", + "\n", + "/* Features section styling */\n", + ".features-container {\n", + " background: #f8f9fa;\n", + " padding: 20px;\n", + " border-radius: 10px;\n", + " border-left: 4px solid #667eea;\n", + "}\n", + "\n", + ".features-title {\n", + " color: #333;\n", + " margin-top: 0;\n", + "}\n", + "\n", + ".features-grid {\n", + " display: grid;\n", + " grid-template-columns: 1fr 1fr;\n", + " gap: 15px;\n", + " margin-top: 15px;\n", + "}\n", + "\n", + ".feature-item {\n", + " color: #333;\n", + " margin: 10px 0;\n", + "}\n", + "\n", + ".feature-title {\n", + " color: #667eea;\n", + "}\n", + "\n", + ".feature-description {\n", + " color: #666;\n", + "}\n", + "\n", + "/* Pro tip styling */\n", + ".protip-container {\n", + " text-align: center;\n", + " margin-top: 20px;\n", + " padding: 15px;\n", + " background: #e8f4f8;\n", + " border-radius: 8px;\n", + "}\n", + "\n", + ".protip-text {\n", + " margin: 0;\n", + " color: #2c5aa0 !important;\n", + " font-weight: 500;\n", + "}\n", + "\n", + "/* Quick start questions styling */\n", + ".quickstart-container {\n", + " background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);\n", + " padding: 15px 20px;\n", + " border-radius: 10px;\n", + " margin: 20px 0;\n", + "}\n", + "\n", + ".quickstart-title {\n", + " color: white !important;\n", + " margin: 0;\n", + " font-size: 1.3em;\n", + " text-align: center;\n", + "}\n", + "\n", + ".quickstart-subtitle {\n", + " color: #f0f8ff !important;\n", + " margin: 5px 0 0 0;\n", + " text-align: center;\n", + " font-size: 0.9em;\n", + "}\n", "\"\"\"\n", "\n", "# Create Gradio interface\n", - "with gr.Blocks(title=\"Figma Onboarding Assistant\", theme=gr.themes.Soft(),css=custom_css) as demo:\n", - " gr.Markdown(\n", + "with gr.Blocks(title=\"Figma Onboarding Assistant\", theme=gr.themes.Soft(), css=custom_css) as demo:\n", + " gr.HTML(\n", " \"\"\"\n", - "
Your AI-powered Figma learning companion
\n", + "Your AI-powered Figma learning companion
\n", "🚀 Getting Started
\n",
- " Interface overview, basic navigation
🛠️ Tools & Features
\n",
- " Pen tool, shapes, text, layers
📐 Auto Layout
\n",
- " Responsive design techniques
🔗 Prototyping
\n",
- " Interactions and animations
🚀 Getting Started
\n",
+ " Interface overview, basic navigation
🛠️ Tools & Features
\n",
+ " Pen tool, shapes, text, layers
📐 Auto Layout
\n",
+ " Responsive design techniques
🔗 Prototyping
\n",
+ " Interactions and animations
🧩 Components
\n",
- " Creating reusable elements
👥 Collaboration
\n",
- " Sharing and team workflows
📚 Design Systems
\n",
- " Libraries and style guides
⚡ Shortcuts
\n",
- " Productivity tips and tricks
🧩 Components
\n",
+ " Creating reusable elements
👥 Collaboration
\n",
+ " Sharing and team workflows
📚 Design Systems
\n",
+ " Libraries and style guides
⚡ Shortcuts
\n",
+ " Productivity tips and tricks
💡 Pro tip: Ask specific questions like \\\"How do I create a button component?\\\" for the best results!
\n", + "💡 Pro tip: Ask specific questions like \"How do I create a button component?\" for the best results!
\n", "Click any question below to get started instantly!
\n", + "Click any question below to get started instantly!
\n", "Your AI-powered Figma learning companion
\n", - "🚀 Getting Started
\n",
- " Interface overview, basic navigation
🛠️ Tools & Features
\n",
- " Pen tool, shapes, text, layers
📐 Auto Layout
\n",
- " Responsive design techniques
🔗 Prototyping
\n",
- " Interactions and animations
🧩 Components
\n",
- " Creating reusable elements
👥 Collaboration
\n",
- " Sharing and team workflows
📚 Design Systems
\n",
- " Libraries and style guides
⚡ Shortcuts
\n",
- " Productivity tips and tricks
💡 Pro tip: Ask specific questions like \"How do I create a button component?\" for the best results!
\n", - "Click any question below to get started instantly!
\n", - "