Spaces:
Running
Running
Update app.py
Browse files
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
|
108 |
-
|
109 |
-
|
110 |
-
if hasattr(event, 'eventType'):
|
111 |
-
print(f"π DEBUG: Event {i} eventType: {event.eventType}")
|
112 |
|
113 |
-
if
|
114 |
-
|
115 |
-
|
116 |
-
print(f"π DEBUG:
|
117 |
|
118 |
-
if
|
119 |
-
|
120 |
-
text_feature
|
121 |
-
print(f"π DEBUG: text_feature: {type(text_feature)}")
|
122 |
|
123 |
-
if
|
124 |
-
|
125 |
-
query_text = ' '.join([token.get('value', '') for token in
|
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:
|