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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -21
app.py CHANGED
@@ -100,30 +100,54 @@ class OpenFloorResearchAgent:
100
 
101
  def handle_utterance_event(self, envelope: Envelope) -> Envelope:
102
  """Handle research requests from AI experts"""
 
 
 
103
  # Extract the query from the utterance
104
- for event in envelope.events:
105
- if hasattr(event, 'eventType') and event.eventType == 'utterance':
106
- dialog_event = event.parameters.get('dialogEvent')
107
- if dialog_event and hasattr(dialog_event, 'features'):
108
- text_feature = dialog_event.features.get('text')
109
- if text_feature and hasattr(text_feature, 'tokens'):
110
- query_text = ' '.join([token.get('value', '') for token in text_feature.tokens])
111
-
112
- print(f"πŸ” DEBUG: {self.tool.name} received query: '{query_text}'")
113
-
114
- # Perform the research
115
- import time
116
- start_time = time.time()
117
- research_result = self.tool.search(query_text)
118
- end_time = time.time()
119
-
120
- print(f"πŸ” DEBUG: {self.tool.name} completed in {end_time - start_time:.2f}s")
121
- print(f"πŸ” DEBUG: Result length: {len(research_result)} chars")
122
- print(f"πŸ” DEBUG: Result preview: {research_result[:200]}...")
123
 
124
- # Create response envelope
125
- return self._create_response_envelope(envelope, research_result, query_text)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
 
127
  return self._create_error_response(envelope, "Could not extract query from request")
128
 
129
  def _create_response_envelope(self, original_envelope: Envelope, research_result: str, query: str) -> Envelope:
 
100
 
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
+
129
+ # Perform the research
130
+ import time
131
+ start_time = time.time()
132
+ research_result = self.tool.search(query_text)
133
+ end_time = time.time()
134
+
135
+ print(f"πŸ” DEBUG: {self.tool.name} completed in {end_time - start_time:.2f}s")
136
+ print(f"πŸ” DEBUG: Result length: {len(research_result)} chars")
137
+ print(f"πŸ” DEBUG: Result preview: {research_result[:200]}...")
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: