|
|
|
import streamlit as st |
|
from typing import Dict, List, Tuple |
|
import logging |
|
|
|
logger = logging.getLogger(__name__) |
|
|
|
class AIdeaTextChatbot: |
|
def __init__(self, lang_code: str): |
|
self.lang_code = lang_code |
|
self.conversation_history = [] |
|
self.context = { |
|
'current_analysis': None, |
|
'last_question': None, |
|
'user_profile': None |
|
} |
|
|
|
def process_message(self, message: str, context: Dict = None) -> str: |
|
""" |
|
Procesa el mensaje del usuario y genera una respuesta |
|
""" |
|
try: |
|
|
|
if context: |
|
self.context.update(context) |
|
|
|
|
|
intent = self._analyze_intent(message) |
|
|
|
|
|
response = self._generate_response(intent, message) |
|
|
|
|
|
self._update_history(message, response) |
|
|
|
return response |
|
|
|
except Exception as e: |
|
logger.error(f"Error procesando mensaje: {str(e)}") |
|
return self._get_fallback_response() |
|
|
|
def _analyze_intent(self, message: str) -> str: |
|
""" |
|
Analiza la intenci贸n del mensaje del usuario |
|
""" |
|
|
|
pass |
|
|
|
def _generate_response(self, intent: str, message: str) -> str: |
|
""" |
|
Genera una respuesta basada en la intenci贸n |
|
""" |
|
|
|
pass |
|
|
|
def get_conversation_history(self) -> List[Tuple[str, str]]: |
|
""" |
|
Retorna el historial de conversaci贸n |
|
""" |
|
return self.conversation_history |