Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| # Predefined responses dictionary | |
| responses = { | |
| # Initial choices | |
| 'portal': "Awesome! Redirecting you to the main portal. What are you interested in: Music Production, Video Production, Short Films, Film Production, or Hiring?", | |
| '1': "Awesome! Redirecting you to the main portal. What are you interested in: Music Production, Video Production, Short Films, Film Production, or Hiring?", | |
| '2': "Sure! Ask me anything—whether it's about services, pricing, collaboration, or hiring.", | |
| 'question': "Sure! Ask me anything—whether it's about services, pricing, collaboration, or hiring.", | |
| 'query': "Sure! Ask me anything—whether it's about services, pricing, collaboration, or hiring.", | |
| # Music Production | |
| 'music': "We offer music composition, lyrics writing, recording, mixing, and music video production. You can also collaborate with artists and promote your work.", | |
| 'song': "We help with songwriting, melody creation, and full audio production.", | |
| 'mixing': "Our mixing and mastering service ensures top-tier sound quality for your tracks.", | |
| # Video Production | |
| 'video': "Video Production includes commercial videos, social media content, product ads, event coverage, and full post-production services.", | |
| 'corporate': "Corporate videos are crafted for brand communication, including interviews, events, and presentations.", | |
| 'editing': "We offer professional video editing, color grading, sound design, and special effects.", | |
| # Short Films | |
| 'short film': "Short Film services include scriptwriting, storyboarding, production, editing, and film festival support.", | |
| 'storyboarding': "We help plan visual scenes with detailed storyboards before production begins.", | |
| 'festival': "We support film submissions to online platforms and festivals with strategic promotion.", | |
| # Film Production | |
| 'film production': "Our film production services guide your idea from script development to full-scale filmmaking and distribution.", | |
| # Hiring and Careers | |
| 'hiring': "Yes, we're hiring! Check the 'Join Us' or 'Careers' section on our website to apply.", | |
| 'job': "Interested in working with us? We have roles in video editing, music production, cinematography, and more. Visit the Careers section.", | |
| 'career': "Explore career opportunities on our site and apply to join our creative team!", | |
| 'internship': "We do offer internships! Please visit the Careers section to see current openings or contact us directly.", | |
| 'apply': "To apply for a role or internship, visit our 'Join Us' page and fill out the form or email us your resume.", | |
| # General Queries | |
| 'pricing': "Our pricing depends on your project needs. Contact us with your idea and we'll provide a custom quote.", | |
| 'contact': "You can reach us via our contact form, WhatsApp link, or chatbot for immediate assistance.", | |
| 'services': "We provide services in music production, video production, short films, film production, and hiring.", | |
| 'team': "We have a team of creative professionals including writers, directors, editors, sound engineers, and designers.", | |
| 'collaborate': "We're open to collaborations! Share your idea through the 'Work With Us' section or drop a message here.", | |
| 'join': "You can join our team via the Careers or Join Us portal where we list open positions." | |
| } | |
| # Define chatbot function | |
| def chatbot(message): | |
| user_message = message.lower() | |
| # Find a matching response | |
| reply = None | |
| for keyword, response in responses.items(): | |
| if keyword in user_message: | |
| reply = response | |
| break | |
| if not reply: | |
| reply = "I'm still learning! Could you please rephrase or ask about something specific from our portal?" | |
| return reply | |
| # Create Gradio interface with simpler configuration | |
| with gr.Blocks(title="Creative Services Assistant") as demo: | |
| gr.Markdown("# Creative Services Assistant") | |
| gr.Markdown("Ask me about our music production, video production, film services, or career opportunities!") | |
| chatbot_interface = gr.Chatbot() | |
| msg = gr.Textbox(placeholder="Type your message here...", show_label=False) | |
| clear = gr.Button("Clear") | |
| # Store conversation history | |
| state = gr.State([]) | |
| # Define functions for the interface | |
| def user(user_message, history): | |
| return "", history + [[user_message, None]] | |
| def bot(history, chat_history): | |
| user_message = history[-1][0] | |
| # Get bot response | |
| bot_message = chatbot(user_message) | |
| # Set response in history - THIS IS THE KEY CHANGE | |
| # Don't include the user message in the response | |
| history[-1][1] = bot_message | |
| # Add to chat history separately | |
| chat_history.append((user_message, bot_message)) | |
| return history, chat_history | |
| def clear_chatbot(): | |
| return [], [] | |
| # Set up event handlers | |
| msg.submit(user, [msg, chatbot_interface], [msg, chatbot_interface]).then( | |
| bot, [chatbot_interface, state], [chatbot_interface, state] | |
| ) | |
| clear.click(clear_chatbot, None, [chatbot_interface, state]) | |
| # Launch the app | |
| demo.launch(share=False) |