Merge pull request #3006 from pipecat-ai/aleix/vision-image-backwards-compatibility

restore vision/image backwards compatibility
This commit is contained in:
Aleix Conchillo Flaqué
2025-11-07 09:19:38 -08:00
committed by GitHub
5 changed files with 51 additions and 1 deletions

View File

@@ -108,6 +108,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Restore backwards compatibility for vision/image features (broken in 0.0.92)
when using non-universal context and assistant aggregators.
- Fixed `DeepgramSTTService._disconnect()` to properly await `is_connected()`
method call, which is an async coroutine in the Deepgram SDK.

View File

@@ -1215,12 +1215,32 @@ class UserImageRequestFrame(SystemFrame):
text: An optional text associated to the image request.
append_to_context: Whether the requested image should be appended to the LLM context.
video_source: Specific video source to capture from.
context: [DEPRECATED] Optional context for the image request.
function_name: [DEPRECATED] Name of function that generated this request (if any).
tool_call_id: [DEPRECATED] Tool call ID if generated by function call.
"""
user_id: str
text: Optional[str] = None
append_to_context: Optional[bool] = None
video_source: Optional[str] = None
context: Optional[Any] = None
function_name: Optional[str] = None
tool_call_id: Optional[str] = None
def __post_init__(self):
super().__post_init__()
if self.context or self.function_name or self.tool_call_id:
import warnings
with warnings.catch_warnings():
warnings.simplefilter("always")
warnings.warn(
"`UserImageRequestFrame` fields `context`, `function_name` and `tool_call_id` are deprecated.",
DeprecationWarning,
stacklevel=2,
)
def __str__(self):
return f"{self.name}(user: {self.user_id}, text: {self.text}, append_to_context: {self.append_to_context}, {self.video_source})"
@@ -1299,11 +1319,27 @@ class UserImageRawFrame(InputImageRawFrame):
user_id: Identifier of the user who provided this image.
text: An optional text associated to this image.
append_to_context: Whether the requested image should be appended to the LLM context.
request: [DEPRECATED] The original image request frame if this is a response.
"""
user_id: str = ""
text: Optional[str] = None
append_to_context: Optional[bool] = None
request: Optional[UserImageRequestFrame] = None
def __post_init__(self):
super().__post_init__()
if self.request:
import warnings
with warnings.catch_warnings():
warnings.simplefilter("always")
warnings.warn(
"`UserImageRawFrame` field `request` is deprecated.",
DeprecationWarning,
stacklevel=2,
)
def __str__(self):
pts = format_pts(self.pts)

View File

@@ -509,7 +509,14 @@ class LLMService(AIService):
DeprecationWarning,
)
await self.push_frame(
UserImageRequestFrame(user_id=user_id, text=text_content),
UserImageRequestFrame(
user_id=user_id,
text=text_content,
# Deprecated fields below.
function_name=function_name,
tool_call_id=tool_call_id,
context=text_content,
),
FrameDirection.UPSTREAM,
)

View File

@@ -1844,6 +1844,8 @@ class DailyInputTransport(BaseInputTransport):
format=video_frame.color_format,
text=request_frame.text if request_frame else None,
append_to_context=request_frame.append_to_context if request_frame else None,
# Deprecated fields below.
request=request_frame,
)
frame.transport_source = video_source
await self.push_video_frame(frame)

View File

@@ -672,6 +672,8 @@ class SmallWebRTCInputTransport(BaseInputTransport):
format=video_frame.format,
text=request_text,
append_to_context=add_to_context,
# Deprecated fields below.
request=request_frame,
)
image_frame.transport_source = video_source
# Push the frame to the pipeline