Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plugins/decart/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ requires-python = ">=3.10"
license = "MIT"
dependencies = [
"vision-agents",
"decart==0.0.8",
"decart>=0.0.33",
]

[project.urls]
Expand Down
42 changes: 6 additions & 36 deletions plugins/decart/tests/test_decart_restyling.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ async def test_update_prompt_when_connected(self, mock_decart_client):
processor._realtime_client = mock_client
processor._connected = True

await processor.update_prompt("new style", enrich=False)
await processor.update_prompt("new style", enhance=False)

mock_client.set_prompt.assert_called_once_with("new style", enrich=False)
mock_client.set_prompt.assert_called_once_with("new style", enhance=False)
assert processor.initial_prompt == "new style"
await processor.close()

Expand All @@ -127,48 +127,18 @@ async def test_update_prompt_noop_when_disconnected(self, mock_decart_client):
await processor.close()

@pytest.mark.asyncio
async def test_update_prompt_uses_default_enrich(self, mock_decart_client):
"""Test update_prompt uses default enrich value when not specified."""
async def test_update_prompt_uses_default_enhance(self, mock_decart_client):
"""Test update_prompt uses default enhance value when not specified."""
with patch(
"vision_agents.plugins.decart.decart_restyling_processor.RealtimeClient"
):
processor = RestylingProcessor(api_key="test_key", enrich=True)
processor = RestylingProcessor(api_key="test_key", enhance=True)
mock_client = AsyncMock()
processor._realtime_client = mock_client

await processor.update_prompt("new style")

mock_client.set_prompt.assert_called_once_with("new style", enrich=True)
await processor.close()

@pytest.mark.asyncio
async def test_set_mirror_when_connected(self, mock_decart_client):
"""Test set_mirror updates mirror mode when connected."""
with patch(
"vision_agents.plugins.decart.decart_restyling_processor.RealtimeClient"
):
processor = RestylingProcessor(api_key="test_key", mirror=True)
mock_client = AsyncMock()
processor._realtime_client = mock_client

await processor.set_mirror(False)

mock_client.set_mirror.assert_called_once_with(False)
assert processor.mirror is False
await processor.close()

@pytest.mark.asyncio
async def test_set_mirror_noop_when_disconnected(self, mock_decart_client):
"""Test set_mirror is no-op when disconnected."""
with patch(
"vision_agents.plugins.decart.decart_restyling_processor.RealtimeClient"
):
processor = RestylingProcessor(api_key="test_key", mirror=True)
processor._realtime_client = None

await processor.set_mirror(False)

assert processor.mirror is True
mock_client.set_prompt.assert_called_once_with("new style", enhance=True)
await processor.close()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def __init__(
api_key: Optional[str] = None,
model: RealTimeModels = "mirage_v2",
initial_prompt: str = "Cyberpunk city",
enrich: bool = True,
mirror: bool = True,
enhance: bool = True,
width: int = 1280, # Model preferred
height: int = 720,
**kwargs,
Expand All @@ -76,8 +75,7 @@ def __init__(
api_key: Decart API key. Uses DECART_API_KEY env var if not provided.
model: Decart model name (default: "mirage_v2").
initial_prompt: Initial style prompt text.
enrich: Whether to enrich prompt (default: True).
mirror: Mirror mode for front camera (default: True).
enhance: Whether to enhance prompt (default: True).
width: Output video width (default: 1280).
height: Output video height (default: 720).
**kwargs: Additional arguments passed to parent class.
Expand All @@ -92,8 +90,7 @@ def __init__(

self.model_name = model
self.initial_prompt = initial_prompt
self.enrich = enrich
self.mirror = mirror
self.enhance = enhance
self.width = width
self.height = height

Expand Down Expand Up @@ -124,45 +121,23 @@ def publish_video_track(self) -> VideoStreamTrack:
return self._video_track

async def update_prompt(
self, prompt_text: str, enrich: Optional[bool] = None
self, prompt_text: str, enhance: Optional[bool] = None
) -> None:
"""
Updates the prompt used for the Decart real-time client. This method allows
changing the current prompt and optionally specifies whether to enrich the
prompt content. The operation is performed asynchronously and requires an
active connection to the Decart client.

If the `enrich` parameter is not provided, the method uses the default
`self.enrich` value.

Parameters:
prompt_text: str
The text of the new prompt to be applied.
enrich: Optional[bool]
Specifies whether to enrich the prompt content. If not provided,
defaults to the object's `enrich` attribute.

Returns:
None
"""Updates the prompt used for the Decart real-time client.

Args:
prompt_text: The text of the new prompt to be applied.
enhance: Whether to enhance the prompt. Defaults to self.enhance.
"""
if not self._realtime_client:
logger.debug("Cannot set prompt: not connected to Decart")
return

enrich_value = enrich if enrich is not None else self.enrich
await self._realtime_client.set_prompt(prompt_text, enrich=enrich_value)
enhance_value = enhance if enhance is not None else self.enhance
await self._realtime_client.set_prompt(prompt_text, enhance=enhance_value)
self.initial_prompt = prompt_text
logger.info(f"Updated Decart prompt: {prompt_text[:50]}...")

async def set_mirror(self, enabled: bool) -> None:
if not self._realtime_client:
logger.debug("Cannot set mirror: not connected to Decart")
return

await self._realtime_client.set_mirror(enabled)
self.mirror = enabled
logger.debug(f"Updated Decart mirror mode: {enabled}")

async def _connect_to_decart(self, local_track: MediaStreamTrack) -> None:
if self._connecting:
logger.debug("Already connecting to Decart, skipping")
Expand All @@ -178,9 +153,8 @@ async def _connect_to_decart(self, local_track: MediaStreamTrack) -> None:
initial_state = ModelState(
prompt=Prompt(
text=self.initial_prompt,
enrich=self.enrich,
enhance=self.enhance,
),
mirror=self.mirror,
)

self._realtime_client = await RealtimeClient.connect(
Expand Down
2 changes: 1 addition & 1 deletion plugins/deepgram/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ requires-python = ">=3.10"
license = "MIT"
dependencies = [
"vision-agents",
"deepgram-sdk>=6.0.1,<6.1.0",
"deepgram-sdk>=6.0.1,<6.2.0",
]

[project.urls]
Expand Down
4 changes: 2 additions & 2 deletions plugins/deepgram/vision_agents/plugins/deepgram/tts.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,13 @@ async def stream_audio(self, text: str, *_, **__) -> AsyncIterator[PcmData]:
self._stop_event.clear()

try:
await socket.send_text(SpeakV1Text(text=text))
await socket.send_text(SpeakV1Text(type="Speak", text=text))
await socket.send_flush()
except (websockets.exceptions.ConnectionClosed, ConnectionError):
logger.warning("Deepgram TTS websocket dropped, reconnecting")
await self._reset_connection()
socket = await self._ensure_connection()
await socket.send_text(SpeakV1Text(text=text))
await socket.send_text(SpeakV1Text(type="Speak", text=text))
await socket.send_flush()

self._generation += 1
Expand Down
2 changes: 1 addition & 1 deletion plugins/turbopuffer/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ requires-python = ">=3.10"
license = "MIT"
dependencies = [
"vision-agents",
"turbopuffer>=1.17.0,<1.18",
"turbopuffer>=1.17.0,<1.22",
"langchain-google-genai>=4.2.1",
"langchain-text-splitters>=1.1.1",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ async def add_documents(self, documents: list[Document]) -> int:

ns = self._client.namespace(self._namespace_name)
await ns.write(
upsert_rows=rows,
upsert_rows=rows, # type: ignore[arg-type]
distance_metric="cosine_distance",
schema=HYBRID_SCHEMA, # type: ignore[arg-type]
)
Expand Down
24 changes: 12 additions & 12 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading