Skip to content

Feat(ark): chat completion support video url #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
8 changes: 8 additions & 0 deletions volcenginesdkarkruntime/resources/chat/completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ def _process_messages(
"encryption is not supported for image url, "
"please use base64 image if you want encryption"
)
elif part.get("type", None) == "video_url":
if part["video_url"]["url"].startswith("data:"):
part["video_url"]["url"] = f(part["video_url"]["url"])
else:
warnings.warn(
"encryption is not supported for video url, "
"please use base64 video if you want encryption"
)
else:
raise TypeError(
"encryption is not supported for content type {}".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
from .chat_completion_content_part_image_param import (
ChatCompletionContentPartImageParam,
)
from .chat_completion_content_part_video_param import ChatCompletionContentPartVideoParam

__all__ = ["ChatCompletionContentPartParam"]

ChatCompletionContentPartParam = Union[
ChatCompletionContentPartTextParam, ChatCompletionContentPartImageParam
ChatCompletionContentPartTextParam, ChatCompletionContentPartImageParam, ChatCompletionContentPartVideoParam
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from __future__ import annotations

from typing_extensions import Literal, Required, TypedDict

__all__ = ["ChatCompletionContentPartVideoParam", "VideoURL"]


class VideoURL(TypedDict, total=False):
url: Required[str]
"""Either a URL of the video or the base64 encoded video data."""

fps: float
"""The frame rate of the video."""

detail: Literal["low", "high"]
"""Specifies the detail level of the video."""


class ChatCompletionContentPartVideoParam(TypedDict, total=False):
video_url: Required[VideoURL]

type: Required[Literal["video_url"]]
"""The type of the content part."""