azettl commited on
Commit
e2948fc
Β·
verified Β·
1 Parent(s): 9e45878

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -26
app.py CHANGED
@@ -101,28 +101,24 @@ class OpenFloorResearchAgent:
101
  def handle_utterance_event(self, envelope: Envelope) -> Envelope:
102
  """Handle research requests from AI experts"""
103
  print(f"πŸ” DEBUG: {self.tool.name} - Starting handle_utterance_event")
104
- print(f"πŸ” DEBUG: Envelope has {len(envelope.events)} events")
105
 
106
  # Extract the query from the utterance
107
- for i, event in enumerate(envelope.events):
108
- print(f"πŸ” DEBUG: Event {i}: {type(event)} - hasattr eventType: {hasattr(event, 'eventType')}")
109
-
110
- if hasattr(event, 'eventType'):
111
- print(f"πŸ” DEBUG: Event {i} eventType: {event.eventType}")
112
 
113
- if event.eventType == 'utterance':
114
- print(f"πŸ” DEBUG: Found utterance event, getting parameters...")
115
- dialog_event = event.parameters.get('dialogEvent')
116
- print(f"πŸ” DEBUG: dialog_event: {type(dialog_event)}")
117
 
118
- if dialog_event and hasattr(dialog_event, 'features'):
119
- print(f"πŸ” DEBUG: dialog_event has features")
120
- text_feature = dialog_event.features.get('text')
121
- print(f"πŸ” DEBUG: text_feature: {type(text_feature)}")
122
 
123
- if text_feature and hasattr(text_feature, 'tokens'):
124
- print(f"πŸ” DEBUG: text_feature has {len(text_feature.tokens)} tokens")
125
- query_text = ' '.join([token.get('value', '') for token in text_feature.tokens])
126
 
127
  print(f"πŸ” DEBUG: {self.tool.name} received query: '{query_text}'")
128
 
@@ -138,16 +134,7 @@ class OpenFloorResearchAgent:
138
 
139
  # Create response envelope
140
  return self._create_response_envelope(envelope, research_result, query_text)
141
- else:
142
- print(f"πŸ” DEBUG: text_feature doesn't have tokens or is None")
143
- else:
144
- print(f"πŸ” DEBUG: dialog_event doesn't have features or is None")
145
- else:
146
- print(f"πŸ” DEBUG: Event {i} is not utterance, skipping")
147
- else:
148
- print(f"πŸ” DEBUG: Event {i} doesn't have eventType attribute")
149
 
150
- print(f"πŸ” DEBUG: No valid utterance event found, returning error")
151
  return self._create_error_response(envelope, "Could not extract query from request")
152
 
153
  def _create_response_envelope(self, original_envelope: Envelope, research_result: str, query: str) -> Envelope:
 
101
  def handle_utterance_event(self, envelope: Envelope) -> Envelope:
102
  """Handle research requests from AI experts"""
103
  print(f"πŸ” DEBUG: {self.tool.name} - Starting handle_utterance_event")
 
104
 
105
  # Extract the query from the utterance
106
+ for event in envelope.events:
107
+ if hasattr(event, 'eventType') and event.eventType == 'utterance':
108
+ dialog_event = event.parameters.get('dialogEvent')
 
 
109
 
110
+ if dialog_event and isinstance(dialog_event, dict):
111
+ # dialog_event is a dict, not an object - use dict access
112
+ features = dialog_event.get('features')
113
+ print(f"πŸ” DEBUG: features: {features}")
114
 
115
+ if features and 'text' in features:
116
+ text_feature = features['text']
117
+ print(f"πŸ” DEBUG: text_feature: {text_feature}")
 
118
 
119
+ if 'tokens' in text_feature:
120
+ tokens = text_feature['tokens']
121
+ query_text = ' '.join([token.get('value', '') for token in tokens])
122
 
123
  print(f"πŸ” DEBUG: {self.tool.name} received query: '{query_text}'")
124
 
 
134
 
135
  # Create response envelope
136
  return self._create_response_envelope(envelope, research_result, query_text)
 
 
 
 
 
 
 
 
137
 
 
138
  return self._create_error_response(envelope, "Could not extract query from request")
139
 
140
  def _create_response_envelope(self, original_envelope: Envelope, research_result: str, query: str) -> Envelope: