Skip to content

Commit

Permalink
Merge pull request #535 from 0xFlicker/fix-videoservice-cache
Browse files Browse the repository at this point in the history
fix: pass runtime to video service
  • Loading branch information
jkbrooks authored Nov 23, 2024
2 parents 4e85200 + c64074a commit b08f3f7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
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

0 comments on commit b08f3f7

Please sign in to comment.