Skip to content

Commit 7029f91

Browse files
committed
add create call shortcut
1 parent e4be124 commit 7029f91

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

agents-core/vision_agents/core/agents/agents.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
import time
66
import uuid
77
from dataclasses import asdict
8-
from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypeGuard
8+
from typing import TYPE_CHECKING, Any, Dict, List, Optional, TypeGuard, Coroutine
99
from uuid import uuid4
1010

1111
import getstream.models
1212
from aiortc import VideoStreamTrack
13+
from getstream.video.async_call import Call
1314
from getstream.video.rtc import Call
1415

1516
from getstream.video.rtc.pb.stream.video.sfu.models.models_pb2 import TrackType
@@ -693,6 +694,13 @@ async def create_user(self) -> None:
693694

694695
return None
695696

697+
async def create_call(self, call_type: str, call_id: str) -> Call:
698+
"""Shortcut for creating a call/room etc."""
699+
call = self.edge.client.video.call(call_type, call_id)
700+
response = await call.get_or_create(data={"created_by_id": self.agent_user.id})
701+
702+
return call
703+
696704
def _on_vad_audio(self, event: VADAudioEvent):
697705
self.logger.debug(f"Vad audio event {self._truncate_for_logging(event)}")
698706

examples/other_examples/openai_realtime_webrtc/openai_realtime_example.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ async def join_call(agent: Agent, call_type: str, call_id: str, **kwargs) -> Non
4242
# ensure the agent user is created
4343
await agent.create_user()
4444
# Create a call
45-
call = agent.edge.client.video.call(call_type, call_id)
46-
# Ensure the call exists server-side before joining
47-
await call.get_or_create(data={"created_by_id": agent.agent_user.id})
45+
call = await agent.create_call(call_type, call_id)
4846

4947
logger.info("🤖 Starting OpenAI Realtime Agent...")
5048

0 commit comments

Comments
 (0)