Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,15 +15,17 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '../..'))
|
|
| 15 |
|
| 16 |
try:
|
| 17 |
from components.ai_core import AICore
|
| 18 |
-
from
|
| 19 |
-
from
|
| 20 |
from components.search_engine import SearchEngine
|
|
|
|
| 21 |
except ImportError:
|
| 22 |
# Fallback for container environment
|
| 23 |
from src.components.ai_core import AICore
|
| 24 |
from src.aegis_integration import AegisBridge
|
| 25 |
from src.aegis_integration.config import AEGIS_CONFIG
|
| 26 |
from src.components.search_engine import SearchEngine
|
|
|
|
| 27 |
|
| 28 |
# Configure logging
|
| 29 |
logging.basicConfig(level=logging.INFO)
|
|
@@ -131,6 +133,9 @@ except Exception as e:
|
|
| 131 |
logger.error(f"Error initializing model: {e}")
|
| 132 |
sys.exit(1)
|
| 133 |
|
|
|
|
|
|
|
|
|
|
| 134 |
def process_message(message: str, history: list) -> tuple:
|
| 135 |
"""Process chat messages with improved context management"""
|
| 136 |
try:
|
|
@@ -161,10 +166,7 @@ def process_message(message: str, history: list) -> tuple:
|
|
| 161 |
|
| 162 |
except Exception as e:
|
| 163 |
logger.error(f"Error in chat: {str(e)}\n{traceback.format_exc()}")
|
| 164 |
-
error_msg = (
|
| 165 |
-
"I apologize, but I encountered an error processing your request. "
|
| 166 |
-
"Please try again with a different query."
|
| 167 |
-
)
|
| 168 |
history.append({"role": "user", "content": message})
|
| 169 |
history.append({"role": "assistant", "content": error_msg})
|
| 170 |
return "", history
|
|
|
|
| 15 |
|
| 16 |
try:
|
| 17 |
from components.ai_core import AICore
|
| 18 |
+
from components.aegis_integration import AegisBridge
|
| 19 |
+
from components.aegis_integration.config import AEGIS_CONFIG
|
| 20 |
from components.search_engine import SearchEngine
|
| 21 |
+
from components.response_templates import get_response_templates
|
| 22 |
except ImportError:
|
| 23 |
# Fallback for container environment
|
| 24 |
from src.components.ai_core import AICore
|
| 25 |
from src.aegis_integration import AegisBridge
|
| 26 |
from src.aegis_integration.config import AEGIS_CONFIG
|
| 27 |
from src.components.search_engine import SearchEngine
|
| 28 |
+
from src.components.response_templates import get_response_templates
|
| 29 |
|
| 30 |
# Configure logging
|
| 31 |
logging.basicConfig(level=logging.INFO)
|
|
|
|
| 133 |
logger.error(f"Error initializing model: {e}")
|
| 134 |
sys.exit(1)
|
| 135 |
|
| 136 |
+
# Initialize response templates for variety
|
| 137 |
+
response_templates = get_response_templates()
|
| 138 |
+
|
| 139 |
def process_message(message: str, history: list) -> tuple:
|
| 140 |
"""Process chat messages with improved context management"""
|
| 141 |
try:
|
|
|
|
| 166 |
|
| 167 |
except Exception as e:
|
| 168 |
logger.error(f"Error in chat: {str(e)}\n{traceback.format_exc()}")
|
| 169 |
+
error_msg = response_templates.get_error_response()
|
|
|
|
|
|
|
|
|
|
| 170 |
history.append({"role": "user", "content": message})
|
| 171 |
history.append({"role": "assistant", "content": error_msg})
|
| 172 |
return "", history
|