Spaces:
Running
Running
apirrone commited on
Commit ·
cef3dfb
1
Parent(s): 53b21ed
idle tool call not triggering a spoken response
Browse files
src/reachy_mini_conversation_demo/openai_realtime_test.py
CHANGED
|
@@ -34,6 +34,7 @@ class OpenaiRealtimeHandler(AsyncStreamHandler):
|
|
| 34 |
|
| 35 |
self.last_activity_time = asyncio.get_event_loop().time()
|
| 36 |
self.start_time = asyncio.get_event_loop().time()
|
|
|
|
| 37 |
|
| 38 |
def copy(self):
|
| 39 |
"""Create a copy of the handler."""
|
|
@@ -180,11 +181,14 @@ class OpenaiRealtimeHandler(AsyncStreamHandler):
|
|
| 180 |
}
|
| 181 |
)
|
| 182 |
|
| 183 |
-
|
| 184 |
-
response
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
|
|
|
|
|
|
|
|
|
| 188 |
|
| 189 |
# re synchronize the head wobble after a tool call that may have taken some time
|
| 190 |
self.deps.head_wobbler.reset()
|
|
@@ -245,7 +249,7 @@ class OpenaiRealtimeHandler(AsyncStreamHandler):
|
|
| 245 |
async def send_idle_signal(self, idle_duration) -> None:
|
| 246 |
"""Send an idle signal to the openai server."""
|
| 247 |
print("[DEBUG] Sending idle signal")
|
| 248 |
-
|
| 249 |
timestamp_msg = f"[Idle time update: {self.format_timestamp()} - No activity for {idle_duration:.1f}s] You've been idle for a while. Feel free to get creative - dance, show an emotion, look around, do nothing, or just be yourself!"
|
| 250 |
if not self.connection:
|
| 251 |
print("[DEBUG] No connection, cannot send idle signal")
|
|
|
|
| 34 |
|
| 35 |
self.last_activity_time = asyncio.get_event_loop().time()
|
| 36 |
self.start_time = asyncio.get_event_loop().time()
|
| 37 |
+
self.is_idle_tool_call = False
|
| 38 |
|
| 39 |
def copy(self):
|
| 40 |
"""Create a copy of the handler."""
|
|
|
|
| 181 |
}
|
| 182 |
)
|
| 183 |
|
| 184 |
+
if not self.is_idle_tool_call:
|
| 185 |
+
await self.connection.response.create(
|
| 186 |
+
response={
|
| 187 |
+
"instructions": "Use the tool result just returned and answer concisely in speech."
|
| 188 |
+
}
|
| 189 |
+
)
|
| 190 |
+
else:
|
| 191 |
+
self.is_idle_tool_call = False
|
| 192 |
|
| 193 |
# re synchronize the head wobble after a tool call that may have taken some time
|
| 194 |
self.deps.head_wobbler.reset()
|
|
|
|
| 249 |
async def send_idle_signal(self, idle_duration) -> None:
|
| 250 |
"""Send an idle signal to the openai server."""
|
| 251 |
print("[DEBUG] Sending idle signal")
|
| 252 |
+
self.is_idle_tool_call = True
|
| 253 |
timestamp_msg = f"[Idle time update: {self.format_timestamp()} - No activity for {idle_duration:.1f}s] You've been idle for a while. Feel free to get creative - dance, show an emotion, look around, do nothing, or just be yourself!"
|
| 254 |
if not self.connection:
|
| 255 |
print("[DEBUG] No connection, cannot send idle signal")
|