Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files
app.py
CHANGED
|
@@ -123,11 +123,14 @@ class ChatInterface:
|
|
| 123 |
# Analyze message intent
|
| 124 |
intent = await self._analyze_intent(message)
|
| 125 |
|
| 126 |
-
|
|
|
|
|
|
|
|
|
|
| 127 |
response = await self._handle_query(message)
|
| 128 |
-
elif
|
| 129 |
response = await self._handle_objective(message)
|
| 130 |
-
elif
|
| 131 |
response = await self._handle_status_request(message)
|
| 132 |
else:
|
| 133 |
response = await self._handle_general_chat(message)
|
|
@@ -139,25 +142,31 @@ class ChatInterface:
|
|
| 139 |
|
| 140 |
except Exception as e:
|
| 141 |
logger.error(f"Error processing message: {str(e)}")
|
| 142 |
-
return f"
|
| 143 |
|
| 144 |
async def _analyze_intent(self, message: str) -> Dict[str, Any]:
|
| 145 |
"""Analyze user message intent."""
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
|
| 162 |
async def _handle_query(self, message: str) -> str:
|
| 163 |
"""Handle information queries."""
|
|
|
|
| 123 |
# Analyze message intent
|
| 124 |
intent = await self._analyze_intent(message)
|
| 125 |
|
| 126 |
+
# Convert UnifiedResult to dict if needed
|
| 127 |
+
intent_type = getattr(intent, "type", None) or intent.get("type", "general")
|
| 128 |
+
|
| 129 |
+
if intent_type == "query":
|
| 130 |
response = await self._handle_query(message)
|
| 131 |
+
elif intent_type == "objective":
|
| 132 |
response = await self._handle_objective(message)
|
| 133 |
+
elif intent_type == "status":
|
| 134 |
response = await self._handle_status_request(message)
|
| 135 |
else:
|
| 136 |
response = await self._handle_general_chat(message)
|
|
|
|
| 142 |
|
| 143 |
except Exception as e:
|
| 144 |
logger.error(f"Error processing message: {str(e)}")
|
| 145 |
+
return f"I apologize, but I encountered an error. Please try again.", history
|
| 146 |
|
| 147 |
async def _analyze_intent(self, message: str) -> Dict[str, Any]:
|
| 148 |
"""Analyze user message intent."""
|
| 149 |
+
try:
|
| 150 |
+
# Use reasoning engine to analyze intent
|
| 151 |
+
result = await self.orchestrator.reasoning_engine.reason(
|
| 152 |
+
query=message,
|
| 153 |
+
context={
|
| 154 |
+
"chat_history": self.chat_history,
|
| 155 |
+
"active_objectives": self.active_objectives
|
| 156 |
+
}
|
| 157 |
+
)
|
| 158 |
+
|
| 159 |
+
# Convert UnifiedResult to dict if needed
|
| 160 |
+
if hasattr(result, "to_dict"):
|
| 161 |
+
return result.to_dict()
|
| 162 |
+
elif hasattr(result, "__dict__"):
|
| 163 |
+
return result.__dict__
|
| 164 |
+
else:
|
| 165 |
+
return {"type": "general"}
|
| 166 |
+
|
| 167 |
+
except Exception as e:
|
| 168 |
+
logger.error(f"Error analyzing intent: {str(e)}")
|
| 169 |
+
return {"type": "general"}
|
| 170 |
|
| 171 |
async def _handle_query(self, message: str) -> str:
|
| 172 |
"""Handle information queries."""
|