nananie143 commited on
Commit
c0cebd8
·
verified ·
1 Parent(s): f8017ae

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +28 -19
app.py CHANGED
@@ -123,11 +123,14 @@ class ChatInterface:
123
  # Analyze message intent
124
  intent = await self._analyze_intent(message)
125
 
126
- if intent["type"] == "query":
 
 
 
127
  response = await self._handle_query(message)
128
- elif intent["type"] == "objective":
129
  response = await self._handle_objective(message)
130
- elif intent["type"] == "status":
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"Error processing message: {str(e)}", history
143
 
144
  async def _analyze_intent(self, message: str) -> Dict[str, Any]:
145
  """Analyze user message intent."""
146
- # Use reasoning engine to analyze intent
147
- analysis = await self.orchestrator.reasoning_engine.reason(
148
- query=message,
149
- context={
150
- "chat_history": self.chat_history,
151
- "active_objectives": self.active_objectives
152
- }
153
- )
154
-
155
- return {
156
- "type": analysis.get("intent_type", "general"),
157
- "confidence": analysis.get("confidence", 0.5),
158
- "entities": analysis.get("entities", []),
159
- "action_required": analysis.get("action_required", False)
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."""