diff --git a/README_IT.md b/README_IT.md index ab74ca0ec41..c38b92ec956 100644 --- a/README_IT.md +++ b/README_IT.md @@ -89,4 +89,4 @@ pnpm install --include=optional sharp ## Cronologia Stelle -[![Grafico Cronologia Stelle](https://api.star-history.com/svg?repos=ai16z/eliza&type=Date)](https://star-history.com/#ai16z/eliza&Date) \ No newline at end of file +[![Grafico Cronologia Stelle](https://api.star-history.com/svg?repos=ai16z/eliza&type=Date)](https://star-history.com/#ai16z/eliza&Date) diff --git a/agent/src/index.ts b/agent/src/index.ts index cad8cff4885..c4d058b0a51 100644 --- a/agent/src/index.ts +++ b/agent/src/index.ts @@ -96,7 +96,7 @@ export async function loadCharacters( } catch (e) { console.error(`Error loading character from ${path}: ${e}`); // don't continue to load if a specified file is not found - process.exit(1) + process.exit(1); } } } diff --git a/docs/docs/core/agents.md b/docs/docs/core/agents.md index 77f7bc1330a..e99c0805d66 100644 --- a/docs/docs/core/agents.md +++ b/docs/docs/core/agents.md @@ -252,6 +252,7 @@ await memoryManager.createMemory({ roomId, }); ``` + --- ## Further Reading diff --git a/docs/docs/core/evaluators.md b/docs/docs/core/evaluators.md index b684dacdb60..9a239fccb4e 100644 --- a/docs/docs/core/evaluators.md +++ b/docs/docs/core/evaluators.md @@ -10,7 +10,7 @@ sidebar_position: 5 ## Overview - Evaluators enable agents to: +Evaluators enable agents to: - Build long-term memory - Track goal progress diff --git a/packages/core/src/runtime.ts b/packages/core/src/runtime.ts index 6813573a897..853efc38d51 100644 --- a/packages/core/src/runtime.ts +++ b/packages/core/src/runtime.ts @@ -42,7 +42,7 @@ import { type Memory, } from "./types.ts"; import { stringToUuid } from "./uuid.ts"; -import { v4 as uuidv4 } from 'uuid'; +import { v4 as uuidv4 } from "uuid"; /** * Represents the runtime environment for an agent, handling message processing, diff --git a/packages/core/src/test_resources/createRuntime.ts b/packages/core/src/test_resources/createRuntime.ts index d1ad826a6ba..64e77e25f2d 100644 --- a/packages/core/src/test_resources/createRuntime.ts +++ b/packages/core/src/test_resources/createRuntime.ts @@ -1,14 +1,12 @@ -import { SqliteDatabaseAdapter, loadVecExtensions } from "@ai16z/adapter-sqlite"; +import { + SqliteDatabaseAdapter, + loadVecExtensions, +} from "@ai16z/adapter-sqlite"; import { SqlJsDatabaseAdapter } from "@ai16z/adapter-sqljs"; import { SupabaseDatabaseAdapter } from "@ai16z/adapter-supabase"; import { DatabaseAdapter } from "../database.ts"; import { AgentRuntime } from "../runtime.ts"; -import { - Action, - Evaluator, - ModelProviderName, - Provider, -} from "../types.ts"; +import { Action, Evaluator, ModelProviderName, Provider } from "../types.ts"; import { SUPABASE_ANON_KEY, SUPABASE_URL, diff --git a/packages/core/src/test_resources/testSetup.ts b/packages/core/src/test_resources/testSetup.ts index badfd3cc6a7..31482461609 100644 --- a/packages/core/src/test_resources/testSetup.ts +++ b/packages/core/src/test_resources/testSetup.ts @@ -3,9 +3,9 @@ import path from "path"; // Load test environment variables const envPath = path.resolve(__dirname, "../../.env.test"); -console.log('Current directory:', __dirname); -console.log('Trying to load env from:', envPath); +console.log("Current directory:", __dirname); +console.log("Trying to load env from:", envPath); const result = dotenv.config({ path: envPath }); if (result.error) { - console.error('Error loading .env.test:', result.error); + console.error("Error loading .env.test:", result.error); } diff --git a/packages/core/src/tests/env.test.ts b/packages/core/src/tests/env.test.ts index 369884bdf3e..a89edeb08cf 100644 --- a/packages/core/src/tests/env.test.ts +++ b/packages/core/src/tests/env.test.ts @@ -1,21 +1,21 @@ -import { describe, it, expect } from 'vitest'; -import fs from 'fs'; -import path from 'path'; +import { describe, it, expect } from "vitest"; +import fs from "fs"; +import path from "path"; -describe('Environment Setup', () => { - it('should verify .env.test file exists', () => { +describe("Environment Setup", () => { + it("should verify .env.test file exists", () => { const possiblePaths = [ - path.join(process.cwd(), '.env.test'), - path.join(process.cwd(), 'packages/core/.env.test'), - path.join(__dirname, '../../.env.test'), - path.join(__dirname, '../.env.test'), - path.join(__dirname, '.env.test'), + path.join(process.cwd(), ".env.test"), + path.join(process.cwd(), "packages/core/.env.test"), + path.join(__dirname, "../../.env.test"), + path.join(__dirname, "../.env.test"), + path.join(__dirname, ".env.test"), ]; - console.log('Current working directory:', process.cwd()); - console.log('__dirname:', __dirname); - - const existingPaths = possiblePaths.filter(p => { + console.log("Current working directory:", process.cwd()); + console.log("__dirname:", __dirname); + + const existingPaths = possiblePaths.filter((p) => { const exists = fs.existsSync(p); console.log(`Path ${p} exists: ${exists}`); return exists; @@ -23,4 +23,4 @@ describe('Environment Setup', () => { expect(existingPaths.length).toBeGreaterThan(0); }); -}); \ No newline at end of file +}); diff --git a/packages/core/src/tests/goals.test.ts b/packages/core/src/tests/goals.test.ts index 26d3fee77ac..1e821974079 100644 --- a/packages/core/src/tests/goals.test.ts +++ b/packages/core/src/tests/goals.test.ts @@ -19,7 +19,7 @@ import { State, } from "../types"; -import { describe, test, expect, beforeEach, vi } from 'vitest'; +import { describe, test, expect, beforeEach, vi } from "vitest"; // Mock the database adapter export const mockDatabaseAdapter = { @@ -180,9 +180,7 @@ const sampleGoal: Goal = { describe("getGoals", () => { it("retrieves goals successfully", async () => { - (mockDatabaseAdapter.getGoals).mockResolvedValue([ - sampleGoal, - ]); + mockDatabaseAdapter.getGoals.mockResolvedValue([sampleGoal]); const result = await getGoals({ runtime: mockRuntime, @@ -199,7 +197,7 @@ describe("getGoals", () => { }); it("handles failure to retrieve goals", async () => { - (mockDatabaseAdapter.getGoals).mockRejectedValue( + mockDatabaseAdapter.getGoals.mockRejectedValue( new Error("Failed to retrieve goals") ); @@ -225,9 +223,7 @@ describe("formatGoalsAsString", () => { describe("updateGoal", () => { it("updates a goal successfully", async () => { - (mockDatabaseAdapter.updateGoal).mockResolvedValue( - undefined - ); + mockDatabaseAdapter.updateGoal.mockResolvedValue(undefined); await expect( updateGoal({ runtime: mockRuntime, goal: sampleGoal }) @@ -236,7 +232,7 @@ describe("updateGoal", () => { }); it("handles failure to update a goal", async () => { - (mockDatabaseAdapter.updateGoal).mockRejectedValue( + mockDatabaseAdapter.updateGoal.mockRejectedValue( new Error("Failed to update goal") ); @@ -248,9 +244,7 @@ describe("updateGoal", () => { describe("createGoal", () => { it("creates a goal successfully", async () => { - (mockDatabaseAdapter.createGoal).mockResolvedValue( - undefined - ); + mockDatabaseAdapter.createGoal.mockResolvedValue(undefined); await expect( createGoal({ runtime: mockRuntime, goal: sampleGoal }) @@ -259,7 +253,7 @@ describe("createGoal", () => { }); it("handles failure to create a goal", async () => { - (mockDatabaseAdapter.createGoal).mockRejectedValue( + mockDatabaseAdapter.createGoal.mockRejectedValue( new Error("Failed to create goal") ); diff --git a/packages/core/src/tests/messages.test.ts b/packages/core/src/tests/messages.test.ts index e82c4690bdd..ce93e07db43 100644 --- a/packages/core/src/tests/messages.test.ts +++ b/packages/core/src/tests/messages.test.ts @@ -5,7 +5,7 @@ import { formatTimestamp, } from "../messages.ts"; import { IAgentRuntime, Actor, Content, Memory, UUID } from "../types.ts"; -import { describe, test, expect, vi, beforeAll } from 'vitest'; +import { describe, test, expect, vi, beforeAll } from "vitest"; describe("Messages Library", () => { let runtime: IAgentRuntime; @@ -42,7 +42,9 @@ describe("Messages Library", () => { const roomId: UUID = "room1234-1234-1234-1234-123456789abc" as UUID; // Using vi.mocked() type assertion instead of jest.Mock casting - vi.mocked(runtime.databaseAdapter.getParticipantsForRoom).mockResolvedValue([userId]); + vi.mocked( + runtime.databaseAdapter.getParticipantsForRoom + ).mockResolvedValue([userId]); vi.mocked(runtime.databaseAdapter.getAccountById).mockResolvedValue({ id: userId, name: "Test User", diff --git a/packages/core/src/tests/models.test.ts b/packages/core/src/tests/models.test.ts index 6cc554cbe37..2277ff6a923 100644 --- a/packages/core/src/tests/models.test.ts +++ b/packages/core/src/tests/models.test.ts @@ -1,6 +1,6 @@ import { getModel, getEndpoint } from "../models.ts"; import { ModelProviderName, ModelClass } from "../types.ts"; -import { describe, test, expect, vi } from 'vitest'; +import { describe, test, expect, vi } from "vitest"; vi.mock("../settings", () => { return { @@ -12,7 +12,7 @@ vi.mock("../settings", () => { OPENROUTER_API_KEY: "mock-openrouter-key", }, loadEnv: vi.fn(), - } + }; }); describe("Model Provider Tests", () => { diff --git a/packages/core/src/tests/relationships.test.ts b/packages/core/src/tests/relationships.test.ts index 5b52dc0c9ba..ad65e8e282b 100644 --- a/packages/core/src/tests/relationships.test.ts +++ b/packages/core/src/tests/relationships.test.ts @@ -5,7 +5,7 @@ import { formatRelationships, } from "../relationships"; import { IAgentRuntime, type Relationship, type UUID } from "../types"; -import { describe, expect, vi } from 'vitest'; +import { describe, expect, vi } from "vitest"; // Mock runtime and databaseAdapter const mockDatabaseAdapter = { diff --git a/packages/core/src/tests/token.test.ts b/packages/core/src/tests/token.test.ts index b464043f2fa..d6d98ec255f 100644 --- a/packages/core/src/tests/token.test.ts +++ b/packages/core/src/tests/token.test.ts @@ -2,8 +2,8 @@ import { createRuntime } from "../test_resources/createRuntime"; import { TokenProvider, WalletProvider } from "@ai16z/plugin-solana"; import { Connection, PublicKey } from "@solana/web3.js"; -import { describe, test, expect, beforeEach, vi } from 'vitest'; -import NodeCache from 'node-cache'; +import { describe, test, expect, beforeEach, vi } from "vitest"; +import NodeCache from "node-cache"; describe("TokenProvider Tests", async () => { let tokenProvider: TokenProvider; @@ -13,14 +13,14 @@ describe("TokenProvider Tests", async () => { vi.clearAllMocks(); const { runtime } = await createRuntime({ - env: process.env, - conversationLength: 10, + env: process.env, + conversationLength: 10, }); const walletProvider = new WalletProvider( - new Connection(runtime.getSetting("RPC_URL")), - new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY")) - ); + new Connection(runtime.getSetting("RPC_URL")), + new PublicKey(runtime.getSetting("WALLET_PUBLIC_KEY")) + ); // Create new instance of TokenProvider tokenProvider = new TokenProvider( "2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh", @@ -31,31 +31,30 @@ describe("TokenProvider Tests", async () => { (tokenProvider as any).cache.flushAll(); (tokenProvider as any).cache.close(); (tokenProvider as any).cache = new NodeCache(); - + // Mock the getCachedData method instead - vi.spyOn(tokenProvider as any, 'getCachedData').mockReturnValue(null); + vi.spyOn(tokenProvider as any, "getCachedData").mockReturnValue(null); }); test("should fetch token security data", async () => { - // Mock the response for the fetchTokenSecurity call const mockFetchResponse = { - success: true, - data: { - ownerBalance: "100", - creatorBalance: "50", - ownerPercentage: 10, - creatorPercentage: 5, - top10HolderBalance: "200", - top10HolderPercent: 20, - }, + success: true, + data: { + ownerBalance: "100", + creatorBalance: "50", + ownerPercentage: 10, + creatorPercentage: 5, + top10HolderBalance: "200", + top10HolderPercent: 20, + }, }; - + // Mock fetchWithRetry function const fetchSpy = vi - .spyOn(tokenProvider as any, "fetchWithRetry") - .mockResolvedValue(mockFetchResponse); - + .spyOn(tokenProvider as any, "fetchWithRetry") + .mockResolvedValue(mockFetchResponse); + // Run the fetchTokenSecurity method const securityData = await tokenProvider.fetchTokenSecurity(); // Check if the data returned is correct @@ -70,7 +69,9 @@ describe("TokenProvider Tests", async () => { // Ensure the mock was called with correct URL expect(fetchSpy).toHaveBeenCalledWith( - expect.stringContaining("https://public-api.birdeye.so/defi/token_security?address=2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh"), + expect.stringContaining( + "https://public-api.birdeye.so/defi/token_security?address=2weMjPLLybRMMva1fM3U31goWWrCpF59CHWNhnCJ9Vyh" + ) ); }); }); diff --git a/packages/core/src/tests/videoGeneration.test.ts b/packages/core/src/tests/videoGeneration.test.ts index e331e8168ee..e691b584e04 100644 --- a/packages/core/src/tests/videoGeneration.test.ts +++ b/packages/core/src/tests/videoGeneration.test.ts @@ -1,18 +1,18 @@ import { IAgentRuntime, Memory, State } from "@ai16z/eliza"; import { videoGenerationPlugin } from "../index"; -import { describe, it, expect, beforeEach, vi } from 'vitest'; +import { describe, it, expect, beforeEach, vi } from "vitest"; // Mock the fetch function global.fetch = vi.fn(); // Mock the fs module -vi.mock('fs', () => ({ +vi.mock("fs", () => ({ writeFileSync: vi.fn(), existsSync: vi.fn(), mkdirSync: vi.fn(), })); -describe('Video Generation Plugin', () => { +describe("Video Generation Plugin", () => { let mockRuntime: IAgentRuntime; let mockCallback: ReturnType; @@ -22,8 +22,8 @@ describe('Video Generation Plugin', () => { // Setup mock runtime mockRuntime = { - getSetting: vi.fn().mockReturnValue('mock-api-key'), - agentId: 'mock-agent-id', + getSetting: vi.fn().mockReturnValue("mock-api-key"), + agentId: "mock-agent-id", composeState: vi.fn().mockResolvedValue({}), } as unknown as IAgentRuntime; @@ -33,30 +33,34 @@ describe('Video Generation Plugin', () => { (global.fetch as ReturnType).mockImplementation(() => Promise.resolve({ ok: true, - json: () => Promise.resolve({ - id: 'mock-generation-id', - status: 'completed', - assets: { - video: 'https://example.com/video.mp4' - } - }), - text: () => Promise.resolve(''), + json: () => + Promise.resolve({ + id: "mock-generation-id", + status: "completed", + assets: { + video: "https://example.com/video.mp4", + }, + }), + text: () => Promise.resolve(""), }) ); }); - it('should validate when API key is present', async () => { + it("should validate when API key is present", async () => { const mockMessage = {} as Memory; - const result = await videoGenerationPlugin.actions[0].validate(mockRuntime, mockMessage); + const result = await videoGenerationPlugin.actions[0].validate( + mockRuntime, + mockMessage + ); expect(result).toBe(true); - expect(mockRuntime.getSetting).toHaveBeenCalledWith('LUMA_API_KEY'); + expect(mockRuntime.getSetting).toHaveBeenCalledWith("LUMA_API_KEY"); }); - it('should handle video generation request', async () => { + it("should handle video generation request", async () => { const mockMessage = { content: { - text: 'Generate a video of a sunset' - } + text: "Generate a video of a sunset", + }, } as Memory; const mockState = {} as State; @@ -71,39 +75,43 @@ describe('Video Generation Plugin', () => { // Check initial callback expect(mockCallback).toHaveBeenCalledWith( expect.objectContaining({ - text: expect.stringContaining('I\'ll generate a video based on your prompt') + text: expect.stringContaining( + "I'll generate a video based on your prompt" + ), }) ); // Check final callback with video expect(mockCallback).toHaveBeenCalledWith( expect.objectContaining({ - text: 'Here\'s your generated video!', + text: "Here's your generated video!", attachments: expect.arrayContaining([ expect.objectContaining({ - source: 'videoGeneration' - }) - ]) + source: "videoGeneration", + }), + ]), }), - expect.arrayContaining([expect.stringMatching(/generated_video_.*\.mp4/)]) + expect.arrayContaining([ + expect.stringMatching(/generated_video_.*\.mp4/), + ]) ); }); - it('should handle API errors gracefully', async () => { + it("should handle API errors gracefully", async () => { // Mock API error (global.fetch as ReturnType).mockImplementationOnce(() => Promise.resolve({ ok: false, status: 500, - statusText: 'Internal Server Error', - text: () => Promise.resolve('API Error'), + statusText: "Internal Server Error", + text: () => Promise.resolve("API Error"), }) ); const mockMessage = { content: { - text: 'Generate a video of a sunset' - } + text: "Generate a video of a sunset", + }, } as Memory; const mockState = {} as State; @@ -118,9 +126,9 @@ describe('Video Generation Plugin', () => { // Check error callback expect(mockCallback).toHaveBeenCalledWith( expect.objectContaining({ - text: expect.stringContaining('Video generation failed'), - error: true + text: expect.stringContaining("Video generation failed"), + error: true, }) ); }); -}); \ No newline at end of file +}); diff --git a/packages/core/vitest.config.ts b/packages/core/vitest.config.ts index 2ce1d5d7f32..9109fb8329b 100644 --- a/packages/core/vitest.config.ts +++ b/packages/core/vitest.config.ts @@ -1,16 +1,16 @@ -import { defineConfig } from 'vitest/config'; -import path from 'path'; +import { defineConfig } from "vitest/config"; +import path from "path"; export default defineConfig({ test: { - setupFiles: ['./src/test_resources/testSetup.ts'], - environment: 'node', + setupFiles: ["./src/test_resources/testSetup.ts"], + environment: "node", globals: true, testTimeout: 120000, }, resolve: { alias: { - '@': path.resolve(__dirname, './src'), + "@": path.resolve(__dirname, "./src"), }, }, -}); \ No newline at end of file +}); diff --git a/packages/plugin-video-generation/src/constants.ts b/packages/plugin-video-generation/src/constants.ts index 4f7428d8f76..78723f905bf 100644 --- a/packages/plugin-video-generation/src/constants.ts +++ b/packages/plugin-video-generation/src/constants.ts @@ -1,4 +1,4 @@ export const LUMA_CONSTANTS = { - API_URL: 'https://api.lumalabs.ai/dream-machine/v1/generations', - API_KEY_SETTING: "LUMA_API_KEY" // The setting name to fetch from runtime -}; \ No newline at end of file + API_URL: "https://api.lumalabs.ai/dream-machine/v1/generations", + API_KEY_SETTING: "LUMA_API_KEY", // The setting name to fetch from runtime +}; diff --git a/packages/plugin-video-generation/src/index.ts b/packages/plugin-video-generation/src/index.ts index 0723485263b..de23d005a10 100644 --- a/packages/plugin-video-generation/src/index.ts +++ b/packages/plugin-video-generation/src/index.ts @@ -8,7 +8,7 @@ import { State, } from "@ai16z/eliza/src/types.ts"; import fs from "fs"; -import { LUMA_CONSTANTS } from './constants'; +import { LUMA_CONSTANTS } from "./constants"; const generateVideo = async (prompt: string, runtime: IAgentRuntime) => { const API_KEY = runtime.getSetting(LUMA_CONSTANTS.API_KEY_SETTING); @@ -17,13 +17,13 @@ const generateVideo = async (prompt: string, runtime: IAgentRuntime) => { elizaLogger.log("Starting video generation with prompt:", prompt); const response = await fetch(LUMA_CONSTANTS.API_URL, { - method: 'POST', + method: "POST", headers: { - 'Authorization': `Bearer ${API_KEY}`, - 'accept': 'application/json', - 'Content-Type': 'application/json' + Authorization: `Bearer ${API_KEY}`, + accept: "application/json", + "Content-Type": "application/json", }, - body: JSON.stringify({ prompt }) + body: JSON.stringify({ prompt }), }); if (!response.ok) { @@ -31,69 +31,79 @@ const generateVideo = async (prompt: string, runtime: IAgentRuntime) => { elizaLogger.error("Luma API error:", { status: response.status, statusText: response.statusText, - error: errorText + error: errorText, }); - throw new Error(`Luma API error: ${response.statusText} - ${errorText}`); + throw new Error( + `Luma API error: ${response.statusText} - ${errorText}` + ); } const data = await response.json(); - elizaLogger.log("Generation request successful, received response:", data); + elizaLogger.log( + "Generation request successful, received response:", + data + ); // Poll for completion let status = data.status; let videoUrl = null; const generationId = data.id; - while (status !== 'completed' && status !== 'failed') { - await new Promise(resolve => setTimeout(resolve, 5000)); // Wait 5 seconds - - const statusResponse = await fetch(`${LUMA_CONSTANTS.API_URL}/${generationId}`, { - method: 'GET', - headers: { - 'Authorization': `Bearer ${API_KEY}`, - 'accept': 'application/json' + while (status !== "completed" && status !== "failed") { + await new Promise((resolve) => setTimeout(resolve, 5000)); // Wait 5 seconds + + const statusResponse = await fetch( + `${LUMA_CONSTANTS.API_URL}/${generationId}`, + { + method: "GET", + headers: { + Authorization: `Bearer ${API_KEY}`, + accept: "application/json", + }, } - }); + ); if (!statusResponse.ok) { const errorText = await statusResponse.text(); elizaLogger.error("Status check error:", { status: statusResponse.status, statusText: statusResponse.statusText, - error: errorText + error: errorText, }); - throw new Error('Failed to check generation status: ' + errorText); + throw new Error( + "Failed to check generation status: " + errorText + ); } const statusData = await statusResponse.json(); elizaLogger.log("Status check response:", statusData); status = statusData.state; - if (status === 'completed') { + if (status === "completed") { videoUrl = statusData.assets?.video; } } - if (status === 'failed') { - throw new Error('Video generation failed'); + if (status === "failed") { + throw new Error("Video generation failed"); } if (!videoUrl) { - throw new Error('No video URL in completed response'); + throw new Error("No video URL in completed response"); } return { success: true, - data: videoUrl + data: videoUrl, }; } catch (error) { elizaLogger.error("Video generation error:", error); return { success: false, - error: error.message || 'Unknown error occurred' + error: error.message || "Unknown error occurred", }; } -} +}; const videoGeneration: Action = { name: "GENERATE_VIDEO", @@ -106,7 +116,7 @@ const videoGeneration: Action = { "ANIMATE", "CREATE_ANIMATION", "VIDEO_CREATE", - "VIDEO_MAKE" + "VIDEO_MAKE", ], description: "Generate a video based on a text prompt", validate: async (runtime: IAgentRuntime, message: Memory) => { @@ -126,8 +136,11 @@ const videoGeneration: Action = { // Clean up the prompt by removing mentions and commands let videoPrompt = message.content.text - .replace(/<@\d+>/g, '') // Remove mentions - .replace(/generate video|create video|make video|render video/gi, '') // Remove commands + .replace(/<@\d+>/g, "") // Remove mentions + .replace( + /generate video|create video|make video|render video/gi, + "" + ) // Remove commands .trim(); if (!videoPrompt || videoPrompt.length < 5) { @@ -155,30 +168,33 @@ const videoGeneration: Action = { // Save video file fs.writeFileSync(videoFileName, Buffer.from(arrayBuffer)); - callback({ - text: "Here's your generated video!", - attachments: [ - { - id: crypto.randomUUID(), - url: result.data, - title: "Generated Video", - source: "videoGeneration", - description: videoPrompt, - text: videoPrompt, - }, - ], - }, [videoFileName]); // Add the video file to the attachments + callback( + { + text: "Here's your generated video!", + attachments: [ + { + id: crypto.randomUUID(), + url: result.data, + title: "Generated Video", + source: "videoGeneration", + description: videoPrompt, + text: videoPrompt, + }, + ], + }, + [videoFileName] + ); // Add the video file to the attachments } else { callback({ text: `Video generation failed: ${result.error}`, - error: true + error: true, }); } } catch (error) { elizaLogger.error(`Failed to generate video. Error: ${error}`); callback({ text: `Video generation failed: ${error.message}`, - error: true + error: true, }); } }, @@ -192,24 +208,26 @@ const videoGeneration: Action = { user: "{{agentName}}", content: { text: "I'll create a video of a cat playing piano for you", - action: "GENERATE_VIDEO" + action: "GENERATE_VIDEO", }, - } + }, ], [ { user: "{{user1}}", - content: { text: "Can you make a video of a sunset at the beach?" }, + content: { + text: "Can you make a video of a sunset at the beach?", + }, }, { user: "{{agentName}}", content: { text: "I'll generate a beautiful beach sunset video for you", - action: "GENERATE_VIDEO" + action: "GENERATE_VIDEO", }, - } - ] - ] + }, + ], + ], } as Action; export const videoGenerationPlugin: Plugin = { @@ -218,4 +236,4 @@ export const videoGenerationPlugin: Plugin = { actions: [videoGeneration], evaluators: [], providers: [], -}; \ No newline at end of file +}; diff --git a/packages/plugin-video-generation/tsup.config.ts b/packages/plugin-video-generation/tsup.config.ts index 4b66bbcbbde..58ed52c4990 100644 --- a/packages/plugin-video-generation/tsup.config.ts +++ b/packages/plugin-video-generation/tsup.config.ts @@ -14,6 +14,6 @@ export default defineConfig({ "@node-llama-cpp", "https", "http", - "agentkeepalive" + "agentkeepalive", ], -}); \ No newline at end of file +}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 62636ae689d..d9569673304 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20783,7 +20783,7 @@ snapshots: extract-zip@2.0.1: dependencies: - debug: 4.3.7(supports-color@5.5.0) + debug: 4.3.4 get-stream: 5.2.0 yauzl: 2.10.0 optionalDependencies: @@ -22894,7 +22894,7 @@ snapshots: log-symbols@4.1.0: dependencies: - chalk: 4.1.2 + chalk: 4.1.0 is-unicode-supported: 0.1.0 log-symbols@6.0.0: