Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import os | |
| # MSC Academy Demo - Gradio Interface | |
| def chat_response(message, history): | |
| """ | |
| Função de chat simples. | |
| Substitua por integração com OpenRouter ou outro LLM. | |
| """ | |
| # Exemplo de resposta | |
| responses = { | |
| "oi": "Olá! Bem-vindo à MSC Academy. Como posso ajudar?", | |
| "olá": "Olá! Bem-vindo à MSC Academy. Como posso ajudar?", | |
| "ajuda": "Posso ajudar com: cursos, dúvidas técnicas, e muito mais!", | |
| } | |
| msg_lower = message.lower().strip() | |
| for key, response in responses.items(): | |
| if key in msg_lower: | |
| return response | |
| return f"Recebi sua mensagem: '{message}'. Em breve terei uma resposta mais inteligente!" | |
| def text_analysis(text): | |
| """Análise básica de texto.""" | |
| if not text: | |
| return "Digite algum texto para analisar." | |
| words = text.split() | |
| chars = len(text) | |
| sentences = text.count('.') + text.count('!') + text.count('?') | |
| return f"""📊 **Análise do Texto** | |
| - **Caracteres:** {chars} | |
| - **Palavras:** {len(words)} | |
| - **Sentenças:** {max(sentences, 1)} | |
| - **Média palavras/sentença:** {len(words) / max(sentences, 1):.1f} | |
| """ | |
| # Interface Gradio | |
| with gr.Blocks(title="MSC Academy Demo", theme=gr.themes.Soft()) as demo: | |
| gr.Markdown(""" | |
| # 🎓 MSC Academy Demo | |
| Bem-vindo à demonstração da MSC Academy! Explore as funcionalidades abaixo. | |
| """) | |
| with gr.Tabs(): | |
| # Tab 1: Chat | |
| with gr.TabItem("💬 Chat"): | |
| chatbot = gr.ChatInterface( | |
| chat_response, | |
| title="Assistente MSC Academy", | |
| description="Converse com nosso assistente virtual.", | |
| examples=["Olá", "Ajuda", "O que vocês oferecem?"], | |
| ) | |
| # Tab 2: Análise de Texto | |
| with gr.TabItem("📝 Análise de Texto"): | |
| gr.Markdown("### Analise seu texto") | |
| text_input = gr.Textbox( | |
| label="Texto", | |
| placeholder="Cole seu texto aqui...", | |
| lines=5 | |
| ) | |
| analyze_btn = gr.Button("Analisar", variant="primary") | |
| analysis_output = gr.Markdown() | |
| analyze_btn.click( | |
| text_analysis, | |
| inputs=text_input, | |
| outputs=analysis_output | |
| ) | |
| # Tab 3: Sobre | |
| with gr.TabItem("ℹ️ Sobre"): | |
| gr.Markdown(""" | |
| ## Sobre a MSC Academy | |
| A MSC Academy é uma plataforma de aprendizado focada em: | |
| - 🤖 Inteligência Artificial | |
| - 💻 Desenvolvimento de Software | |
| - 📊 Análise de Dados | |
| - 🚀 Tecnologias Emergentes | |
| ### Links Úteis | |
| - [Dataset MSC Academy](https://huggingface.co/datasets/Finish-him/msc-academy-data) | |
| - [Hugging Face Profile](https://huggingface.co/Finish-him) | |
| --- | |
| *Desenvolvido com ❤️ usando Gradio* | |
| """) | |
| # Lançar app | |
| if __name__ == "__main__": | |
| demo.launch() | |