Skip to content

Commit 4dd4d1f

Browse files
committed
fix
1 parent 35a8e9f commit 4dd4d1f

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/elevenlabs/conversational_ai/conversation.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import base64
33
import json
44
import threading
5-
from typing import Callable, Optional, Awaitable, Union, Any, Literal
5+
from typing import Callable, Optional, Awaitable, Union, Any, Literal, Dict, Tuple
66
import asyncio
77
from concurrent.futures import ThreadPoolExecutor
88
from enum import Enum
@@ -119,7 +119,7 @@ class ClientTools:
119119
"""
120120

121121
def __init__(self) -> None:
122-
self.tools: dict[str, tuple[Union[Callable[[dict], Any], Callable[[dict], Awaitable[Any]]], bool]] = {}
122+
self.tools: Dict[str, Tuple[Union[Callable[[dict], Any], Callable[[dict], Awaitable[Any]]], bool]] = {}
123123
self.lock = threading.Lock()
124124
self._loop = None
125125
self._thread = None
@@ -196,6 +196,9 @@ def execute_tool(self, tool_name: str, parameters: dict, callback: Callable[[dic
196196
"""
197197
if not self._running.is_set():
198198
raise RuntimeError("ClientTools event loop is not running")
199+
200+
if self._loop is None:
201+
raise RuntimeError("Event loop is not available")
199202

200203
async def _execute_and_callback():
201204
try:

tests/test_convai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,5 @@ def test_conversation_with_contextual_update():
191191
conversation.wait_for_session_end()
192192

193193
# Assertions
194-
expected = json.dumps({"type": "contextual_update", "text": "User appears to be looking at pricing page"})
194+
expected = json.dumps({"type": "contextual_update", "content": "User appears to be looking at pricing page"})
195195
mock_ws.send.assert_any_call(expected)

0 commit comments

Comments
 (0)