Skip to content

Commit 5d39547

Browse files
authored
Fixed bug with init and user_id (#720)
1 parent d7fb50d commit 5d39547

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/elevenlabs/conversational_ai/conversation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ def _create_initiation_message(self):
403403
"source": "python_sdk",
404404
"version": __version__,
405405
},
406-
**({"user_id": self.config.user_id} if self.config.user_id else {}),
406+
**({"user_id": self.user_id} if self.user_id else {}),
407407
}
408408
)
409409

tests/test_async_convai.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,11 @@ async def test_async_conversation_basic_flow():
7171
agent_response_callback = AsyncMock()
7272
test_user_id = "test_user_123"
7373

74-
# Setup the conversation
75-
config = ConversationInitiationData(user_id=test_user_id)
74+
# Setup the conversation with user_id passed directly to the constructor
7675
conversation = AsyncConversation(
7776
client=mock_client,
7877
agent_id=TEST_AGENT_ID,
79-
config=config,
78+
user_id=test_user_id,
8079
requires_auth=False,
8180
audio_interface=MockAsyncAudioInterface(),
8281
callback_agent_response=agent_response_callback,
@@ -109,7 +108,7 @@ async def test_async_conversation_basic_flow():
109108
assert init_message["user_id"] == test_user_id
110109
agent_response_callback.assert_called_once_with("Hello there!")
111110
assert conversation._conversation_id == TEST_CONVERSATION_ID
112-
assert conversation.config.user_id == test_user_id
111+
assert conversation.user_id == test_user_id
113112

114113

115114
@pytest.mark.asyncio

tests/test_convai.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@ def test_conversation_basic_flow():
5959
agent_response_callback = MagicMock()
6060
test_user_id = "test_user_123"
6161

62-
# Setup the conversation
63-
config = ConversationInitiationData(user_id=test_user_id)
62+
# Setup the conversation with user_id passed directly to the constructor
6463
conversation = Conversation(
6564
client=mock_client,
6665
agent_id=TEST_AGENT_ID,
67-
config=config,
66+
user_id=test_user_id,
6867
requires_auth=False,
6968
audio_interface=MockAudioInterface(),
7069
callback_agent_response=agent_response_callback,
@@ -99,7 +98,7 @@ def test_conversation_basic_flow():
9998
assert init_message["user_id"] == test_user_id
10099
agent_response_callback.assert_called_once_with("Hello there!")
101100
assert conversation._conversation_id == TEST_CONVERSATION_ID
102-
assert conversation.config.user_id == test_user_id
101+
assert conversation.user_id == test_user_id
103102

104103

105104
def test_conversation_with_auth():

0 commit comments

Comments
 (0)