Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -70,18 +70,37 @@ class GeradorTrilhaAprendizado:
|
|
| 70 |
logging.error(f"Processing error: {str(e)}")
|
| 71 |
return ("", "", self._formatar_historico(), f"❌ Erro: {str(e)}")
|
| 72 |
|
|
|
|
|
|
|
| 73 |
def _gerar_trilha_personalizada(self, transcricao: str, nivel: str, area: str, duracao: str) -> str:
|
| 74 |
try:
|
| 75 |
palavras_chave = self._extrair_palavras_chave(transcricao)
|
| 76 |
modulos = self._get_modulos_por_area(area, nivel)
|
| 77 |
duracao_meses = int(duracao.split()[0])
|
| 78 |
tempo_por_modulo = duracao_meses / len(modulos)
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 80 |
return f"""
|
| 81 |
🎯 Objetivos Identificados:
|
| 82 |
{self._formatar_objetivos(palavras_chave, area)}
|
| 83 |
|
| 84 |
📚 Trilha Personalizada para {area.title()} - Nível {nivel}:
|
|
|
|
|
|
|
| 85 |
{self._formatar_modulos(modulos, tempo_por_modulo)}
|
| 86 |
|
| 87 |
🚀 Projetos Práticos Sugeridos:
|
|
@@ -96,6 +115,7 @@ class GeradorTrilhaAprendizado:
|
|
| 96 |
except Exception as e:
|
| 97 |
logging.error(f"Error generating learning path: {str(e)}")
|
| 98 |
return "Erro ao gerar trilha de aprendizado"
|
|
|
|
| 99 |
|
| 100 |
def _extrair_palavras_chave(self, texto: str) -> List[str]:
|
| 101 |
try:
|
|
|
|
| 70 |
logging.error(f"Processing error: {str(e)}")
|
| 71 |
return ("", "", self._formatar_historico(), f"❌ Erro: {str(e)}")
|
| 72 |
|
| 73 |
+
# Core change needed in _gerar_trilha_personalizada method:
|
| 74 |
+
|
| 75 |
def _gerar_trilha_personalizada(self, transcricao: str, nivel: str, area: str, duracao: str) -> str:
|
| 76 |
try:
|
| 77 |
palavras_chave = self._extrair_palavras_chave(transcricao)
|
| 78 |
modulos = self._get_modulos_por_area(area, nivel)
|
| 79 |
duracao_meses = int(duracao.split()[0])
|
| 80 |
tempo_por_modulo = duracao_meses / len(modulos)
|
| 81 |
+
|
| 82 |
+
# Generate customized content using the model
|
| 83 |
+
prompt = f"""
|
| 84 |
+
Gere uma trilha de aprendizado para a área de {area} (nível {nivel}), duração de {duracao}.
|
| 85 |
+
Objetivos do usuário: {transcricao}
|
| 86 |
+
Palavras-chave identificadas: {', '.join(palavras_chave)}
|
| 87 |
+
"""
|
| 88 |
+
|
| 89 |
+
generated_content = self.generator(
|
| 90 |
+
prompt,
|
| 91 |
+
max_length=500,
|
| 92 |
+
num_return_sequences=1,
|
| 93 |
+
temperature=0.7
|
| 94 |
+
)[0]['generated_text']
|
| 95 |
+
|
| 96 |
+
# Combine generated content with structured data
|
| 97 |
return f"""
|
| 98 |
🎯 Objetivos Identificados:
|
| 99 |
{self._formatar_objetivos(palavras_chave, area)}
|
| 100 |
|
| 101 |
📚 Trilha Personalizada para {area.title()} - Nível {nivel}:
|
| 102 |
+
{generated_content}
|
| 103 |
+
|
| 104 |
{self._formatar_modulos(modulos, tempo_por_modulo)}
|
| 105 |
|
| 106 |
🚀 Projetos Práticos Sugeridos:
|
|
|
|
| 115 |
except Exception as e:
|
| 116 |
logging.error(f"Error generating learning path: {str(e)}")
|
| 117 |
return "Erro ao gerar trilha de aprendizado"
|
| 118 |
+
|
| 119 |
|
| 120 |
def _extrair_palavras_chave(self, texto: str) -> List[str]:
|
| 121 |
try:
|