Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import requests | |
| import json | |
| from datetime import datetime | |
| # Enhanced company data with more comprehensive information | |
| company_knowledge = { | |
| "company_info": """ | |
| YAH Tech is a venture studio and app development company founded by Adedoyin Ifeoluwa James. | |
| We build profitable and impactful systems that drive economic growth through flexible, scalable technology. | |
| Our mission is to create technology solutions that solve real-world problems while generating sustainable revenue. | |
| We specialize in web development, mobile apps, AI solutions, and digital transformation services. | |
| """, | |
| "founder_info": """ | |
| Adedoyin Ifeoluwa James is an entrepreneur and technology innovator. | |
| He is the founder and CEO of both YAH Tech and Yahcorps. | |
| With a passion for economic development, he focuses on creating systems that combine profitability with social impact. | |
| His vision is to leverage technology as a catalyst for sustainable economic growth in Africa and beyond. | |
| """, | |
| "services": """ | |
| YAH Tech offers: | |
| • Custom Software Development | |
| • Mobile App Development (iOS & Android) | |
| • AI and Machine Learning Solutions | |
| • Web Applications & E-commerce | |
| • Digital Transformation Consulting | |
| • Venture Building & Tech Incubation | |
| """, | |
| "contact": """ | |
| You can reach YAH Tech through: | |
| Email: contact@yahtech.com | |
| Website: www.yahtech.com | |
| LinkedIn: linkedin.com/company/yahtech | |
| """ | |
| } | |
| # Enhanced response system with general knowledge | |
| def get_enhanced_response(user_message, chat_history): | |
| user_message_lower = user_message.lower() | |
| # Company-specific queries | |
| if any(keyword in user_message_lower for keyword in ['yah tech', 'adedoyin', 'founder', 'ceo', 'company']): | |
| if 'service' in user_message_lower or 'what do you do' in user_message_lower: | |
| return company_knowledge['services'] | |
| elif 'contact' in user_message_lower or 'email' in user_message_lower or 'website' in user_message_lower: | |
| return company_knowledge['contact'] | |
| elif 'founder' in user_message_lower or 'adedoyin' in user_message_lower: | |
| return company_knowledge['founder_info'] | |
| else: | |
| return company_knowledge['company_info'] | |
| # General knowledge and everyday questions | |
| elif any(keyword in user_message_lower for keyword in ['hello', 'hi', 'hey']): | |
| return "Hello! I'm YAH Tech AI assistant. How can I help you today? Feel free to ask about YAH Tech, our services, or any general questions!" | |
| elif any(keyword in user_message_lower for keyword in ['how are you', 'how do you do']): | |
| return "I'm functioning well, thank you! I'm here to assist you with information about YAH Tech and answer your general questions. What would you like to know?" | |
| elif any(keyword in user_message_lower for keyword in ['time', 'date']): | |
| current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S") | |
| return f"The current date and time is: {current_time}" | |
| elif any(keyword in user_message_lower for keyword in ['weather']): | |
| return "I don't have real-time weather data, but I recommend checking a weather service for current conditions in your area." | |
| elif any(keyword in user_message_lower for keyword in ['thank you', 'thanks']): | |
| return "You're welcome! Is there anything else I can help you with?" | |
| elif any(keyword in user_message_lower for keyword in ['bye', 'goodbye', 'see you']): | |
| return "Goodbye! Thank you for chatting with YAH Tech AI. Feel free to return if you have more questions!" | |
| elif any(keyword in user_message_lower for keyword in ['what can you do', 'help']): | |
| return """I can help you with: | |
| • Information about YAH Tech and our services | |
| • Details about our founder Adedoyin Ifeoluwa James | |
| • Answer general questions and have conversations | |
| • Provide basic assistance with everyday queries | |
| • Discuss technology, entrepreneurship, and business | |
| What would you like to know?""" | |
| elif any(keyword in user_message_lower for keyword in ['technology', 'tech']): | |
| return "Technology is transforming every industry! At YAH Tech, we believe in leveraging cutting-edge technologies like AI, cloud computing, and mobile platforms to create innovative solutions that drive growth and efficiency." | |
| elif any(keyword in user_message_lower for keyword in ['entrepreneur', 'business']): | |
| return "Entrepreneurship is about identifying opportunities and creating value. Successful businesses often combine innovation with market needs. YAH Tech operates as a venture studio, helping to build and scale new technology ventures." | |
| # Fallback response for unknown queries | |
| else: | |
| return f"I understand you're asking about: '{user_message}'. While I'm primarily focused on YAH Tech information, I can tell you that this seems like an interesting topic. For detailed information, you might want to consult specialized resources. Is there anything specific about YAH Tech or general technology/business topics I can help with?" | |
| def chat_interface(message, chat_history): | |
| bot_response = get_enhanced_response(message, chat_history) | |
| # Format the conversation | |
| chat_history.append([message, bot_response]) | |
| return "", chat_history | |
| # Custom CSS for ChatGPT-like appearance | |
| custom_css = """ | |
| .chat-container { | |
| max-height: 500px; | |
| overflow-y: auto; | |
| border: 1px solid #e0e0e0; | |
| border-radius: 10px; | |
| padding: 20px; | |
| background: #f9f9f9; | |
| } | |
| .user-message { | |
| background: #007bff; | |
| color: white; | |
| padding: 10px 15px; | |
| border-radius: 18px 18px 0 18px; | |
| margin: 5px 0; | |
| max-width: 80%; | |
| margin-left: auto; | |
| } | |
| .bot-message { | |
| background: #e9ecef; | |
| color: #333; | |
| padding: 10px 15px; | |
| border-radius: 18px 18px 18px 0; | |
| margin: 5px 0; | |
| max-width: 80%; | |
| margin-right: auto; | |
| } | |
| .chat-input { | |
| border-radius: 25px; | |
| padding: 12px 20px; | |
| border: 2px solid #007bff; | |
| } | |
| .send-button { | |
| border-radius: 25px; | |
| background: #007bff; | |
| color: white; | |
| border: none; | |
| padding: 12px 30px; | |
| } | |
| .title { | |
| text-align: center; | |
| color: #2c3e50; | |
| font-weight: bold; | |
| margin-bottom: 20px; | |
| } | |
| .gradio-container { | |
| max-width: 800px !important; | |
| margin: 0 auto; | |
| } | |
| """ | |
| with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo: | |
| gr.Markdown( | |
| """ | |
| # <div class="title">YAH Tech AI Assistant</div> | |
| <div style="text-align: center; color: #666; margin-bottom: 20px;"> | |
| Powered by advanced AI • Ask me about YAH Tech or general questions | |
| </div> | |
| """ | |
| ) | |
| chatbot = gr.Chatbot( | |
| label="Chat", | |
| elem_classes="chat-container", | |
| show_label=False, | |
| height=500 | |
| ) | |
| with gr.Row(): | |
| msg = gr.Textbox( | |
| placeholder="Type your message here...", | |
| show_label=False, | |
| scale=4, | |
| elem_classes="chat-input" | |
| ) | |
| send = gr.Button("Send", variant="primary", scale=1, elem_classes="send-button") | |
| clear = gr.Button("Clear", variant="secondary", scale=1) | |
| # Footer | |
| gr.Markdown( | |
| """ | |
| <div style="text-align: center; margin-top: 20px; color: #888; font-size: 12px;"> | |
| YAH Tech AI Assistant • Building the future of technology | |
| </div> | |
| """ | |
| ) | |
| def clear_chat(): | |
| return [] | |
| msg.submit( | |
| chat_interface, | |
| inputs=[msg, chatbot], | |
| outputs=[msg, chatbot] | |
| ) | |
| send.click( | |
| chat_interface, | |
| inputs=[msg, chatbot], | |
| outputs=[msg, chatbot] | |
| ) | |
| clear.click( | |
| clear_chat, | |
| outputs=[chatbot] | |
| ) | |
| if __name__ == "__main__": | |
| demo.launch( | |
| share=False, | |
| server_name="0.0.0.0", | |
| server_port=7860 | |
| ) | |