Skip to content
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

fix: pass runtime to video service #535

Merged
merged 2 commits into from
Nov 23, 2024
Merged
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
5 changes: 4 additions & 1 deletion packages/client-discord/src/attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ export class AttachmentManager {
}

if (videoService.isVideoUrl(attachment.url)) {
const videoInfo = await videoService.processVideo(attachment.url);
const videoInfo = await videoService.processVideo(
attachment.url,
this.runtime
);
return {
id: attachment.id,
url: attachment.url,
Expand Down
7 changes: 5 additions & 2 deletions packages/client-discord/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,15 +693,18 @@ export class MessageManager {
if (
this.runtime
.getService<IVideoService>(ServiceType.VIDEO)
.isVideoUrl(url)
?.isVideoUrl(url)
) {
const videoService = this.runtime.getService<IVideoService>(
ServiceType.VIDEO
);
if (!videoService) {
throw new Error("Video service not found");
}
const videoInfo = await videoService.processVideo(url);
const videoInfo = await videoService.processVideo(
url,
this.runtime
);

attachments.push({
id: `youtube-${Date.now()}`,
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,6 @@ export interface ITranscriptionService extends Service {

export interface IVideoService extends Service {
isVideoUrl(url: string): boolean;
processVideo(url: string): Promise<Media>;
fetchVideoInfo(url: string): Promise<Media>;
downloadVideo(videoInfo: Media): Promise<string>;
processVideo(url: string, runtime: IAgentRuntime): Promise<Media>;
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-node/src/services/video.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class VideoService extends Service implements IVideoService {

public async processVideo(
url: string,
runtime?: IAgentRuntime
runtime: IAgentRuntime
): Promise<Media> {
this.queue.push(url);
this.processQueue(runtime);
Expand Down