mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 21:42:27 +08:00
feat(video): implement OpenAI video creation support
Add video creation functionality using OpenAI SDK. Update types to match OpenAI's video API and implement the actual creation method in the OpenAI client.
This commit is contained in:
parent
612d3756cf
commit
a1fde0db38
@ -153,9 +153,9 @@ export class OpenAIResponseAPIClient extends OpenAIBaseClient<
|
||||
return await sdk.responses.create(payload, options)
|
||||
}
|
||||
|
||||
public async createVideo(params: CreateVideoParams) {
|
||||
// TODO: implement it
|
||||
throw new Error('Not implemented')
|
||||
public async createVideo(params: CreateVideoParams): Promise<OpenAI.Videos.Video> {
|
||||
const sdk = await this.getSdkInstance()
|
||||
return await sdk.videos.create(params.params, params.options)
|
||||
}
|
||||
|
||||
private async handlePdfFile(file: FileMetadata): Promise<OpenAI.Responses.ResponseInputFile | undefined> {
|
||||
|
||||
@ -181,12 +181,11 @@ export default class AiProvider {
|
||||
}
|
||||
|
||||
public async createVideo(params: CreateVideoParams): Promise<CreateVideoResult> {
|
||||
throw new Error('Not implemented')
|
||||
// if (this.apiClient instanceof OpenAIResponseAPIClient) {
|
||||
// return this.apiClient.createVideo(params)
|
||||
// } else {
|
||||
// throw new Error('Video generation is not supported by this provider')
|
||||
// }
|
||||
if (this.apiClient instanceof OpenAIResponseAPIClient) {
|
||||
return this.apiClient.createVideo(params)
|
||||
} else {
|
||||
throw new Error('Video generation is not supported by this provider')
|
||||
}
|
||||
}
|
||||
|
||||
public getBaseURL(): string {
|
||||
|
||||
@ -1,10 +1,6 @@
|
||||
export type CreateVideoRequest = {
|
||||
type: 'openai'
|
||||
}
|
||||
import OpenAI from '@cherrystudio/openai'
|
||||
|
||||
export type CreateVideoParams = {
|
||||
providerId: string
|
||||
modelId: string
|
||||
}
|
||||
// Only OpenAI for now.
|
||||
export type CreateVideoParams = { params: OpenAI.VideoCreateParams; options?: OpenAI.RequestOptions }
|
||||
|
||||
export type CreateVideoResult = {}
|
||||
export type CreateVideoResult = OpenAI.Videos.Video
|
||||
|
||||
Loading…
Reference in New Issue
Block a user