-
-
Notifications
You must be signed in to change notification settings - Fork 13.9k
✨ feat: support video input for SiliconCloud provider #9988
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
base: next
Are you sure you want to change the base?
Conversation
|
@AnotiaWang is attempting to deploy a commit to the LobeHub OSS Team on Vercel. A member of the Team first needs to authorize it. |
Reviewer's GuideThis PR adds support for video input in the SiliconCloud provider by introducing base64 conversion utilities, integrating a message transformation hook in the runtime, updating model definitions to include video capabilities (including two new models), and documenting a new environment variable for video encoding. ER diagram for updated SiliconCloud chat modelserDiagram
AIChatModelCard {
string id
string displayName
string description
int contextWindowTokens
bool enabled
string type
}
Abilities {
bool functionCall
bool vision
bool video
bool reasoning
}
Pricing {
string currency
}
Units {
string name
float rate
string strategy
string unit
}
AIChatModelCard ||--o| Abilities : has
AIChatModelCard ||--o| Pricing : has
Pricing ||--|{ Units : contains
Class diagram for SiliconCloud provider video input supportclassDiagram
class SiliconCloudModelCard {
+id: string
}
class convertVideoToBase64 {
+convertVideoToBase64(videoUrl: string): Promise<string>
}
class transformMessages {
+transformMessages(messages: any[]): Promise<any[]>
}
SiliconCloudModelCard <.. transformMessages
transformMessages o-- convertVideoToBase64
class OpenAICompatibleFactoryOptions {
+transformMessages?: (messages: ChatCompletionMessageParam[]) => Promise<ChatCompletionMessageParam[]> | ChatCompletionMessageParam[]
}
class createOpenAICompatibleRuntime {
+createOpenAICompatibleRuntime<T>()
}
createOpenAICompatibleRuntime o-- OpenAICompatibleFactoryOptions
OpenAICompatibleFactoryOptions <.. transformMessages
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Thank you for raising your pull request and contributing to our Community |
TestGru AssignmentSummary
Files
Tip You can |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `packages/model-runtime/src/providers/siliconcloud/index.ts:32-73` </location>
<code_context>
const transformedMessages = await Promise.all(
messages.map(async (message) => {
if (typeof message.content === 'string') {
return message;
}
// 转换消息内容数组
if (Array.isArray(message.content)) {
const convertedContent = await Promise.all(
message.content.map(async (content: any) => {
if (content.type === 'video_url') {
const isBase64 = content.video_url.url.startsWith('data:');
if (!isBase64 && process.env.LLM_VISION_VIDEO_USE_BASE64 === '1') {
try {
const convertedUrl = await convertVideoToBase64(content.video_url.url);
return {
...content,
video_url: { url: convertedUrl },
};
} catch (error) {
console.warn('Failed to convert video to base64:', error);
return content;
}
}
}
return content;
}),
);
return {
...message,
content: convertedContent,
};
}
return message;
}),
);
return transformedMessages;
</code_context>
<issue_to_address>
**suggestion (code-quality):** Inline variable that is immediately returned ([`inline-immediately-returned-variable`](https://docs.sourcery.ai/Reference/Rules-and-In-Line-Suggestions/TypeScript/Default-Rules/inline-immediately-returned-variable))
```suggestion
return await Promise.all(
messages.map(async (message) => {
if (typeof message.content === 'string') {
return message;
}
// 转换消息内容数组
if (Array.isArray(message.content)) {
const convertedContent = await Promise.all(
message.content.map(async (content: any) => {
if (content.type === 'video_url') {
const isBase64 = content.video_url.url.startsWith('data:');
if (!isBase64 && process.env.LLM_VISION_VIDEO_USE_BASE64 === '1') {
try {
const convertedUrl = await convertVideoToBase64(content.video_url.url);
return {
...content,
video_url: { url: convertedUrl },
};
} catch (error) {
console.warn('Failed to convert video to base64:', error);
return content;
}
}
}
return content;
}),
);
return {
...message,
content: convertedContent,
};
}
return message;
}),
);
```
<br/><details><summary>Explanation</summary>Something that we often see in people's code is assigning to a result variable
and then immediately returning it.
Returning the result directly shortens the code and removes an unnecessary
variable, reducing the mental load of reading the function.
Where intermediate variables can be useful is if they then get used as a
parameter or a condition, and the name can act like a comment on what the
variable represents. In the case where you're returning it from a function, the
function name is there to tell you what the result is, so the variable name
is unnecessary.
</details>
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## next #9988 +/- ##
==========================================
+ Coverage 81.73% 81.74% +0.01%
==========================================
Files 886 888 +2
Lines 55986 56085 +99
Branches 7634 7662 +28
==========================================
+ Hits 45760 45847 +87
- Misses 10226 10238 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
💻 Change Type
🔗 Related Issue
🔀 Description of Change
新增模型
硅基流动新增了 MiniMax M2 和 KAT-Dev 模型
新增功能
LLM_VISION_VIDEO_USE_BASE64环境变量,启用后会将视频转换成 Base64 直接发送给模型,否则使用视频链接transformMessages字段,允许 provider 自行组装消息内容🧪 How to Test
📸 Screenshots / Videos
📝 Additional Information
Summary by Sourcery
Enable video input handling in the SiliconCloud provider, expose a hook for custom message transformations, add an environment variable to control video Base64 conversion, and introduce two new chat models (MiniMax M2 and KAT-Dev).
New Features:
Documentation: