From 2a03469527e264ef9a546c7a50cee558f0ab7744 Mon Sep 17 00:00:00 2001 From: cygaar Date: Fri, 29 Nov 2024 15:32:45 -0500 Subject: [PATCH 1/2] fix: getEmbeddingZeroVector calls --- packages/client-discord/src/index.ts | 6 +++--- packages/client-discord/src/messages.ts | 2 +- packages/client-discord/src/voice.ts | 4 ++-- packages/client-farcaster/src/memory.ts | 2 +- packages/client-telegram/src/messageManager.ts | 4 ++-- packages/client-twitter/src/base.ts | 6 +++--- packages/client-twitter/src/interactions.ts | 2 +- packages/client-twitter/src/post.ts | 2 +- packages/client-twitter/src/utils.ts | 4 ++-- packages/core/src/knowledge.ts | 2 +- packages/core/src/memory.ts | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/client-discord/src/index.ts b/packages/client-discord/src/index.ts index 6183ba20f7..849465f9f8 100644 --- a/packages/client-discord/src/index.ts +++ b/packages/client-discord/src/index.ts @@ -257,7 +257,7 @@ export class DiscordClient extends EventEmitter { }, roomId, createdAt: timestamp, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), }; try { @@ -348,7 +348,7 @@ export class DiscordClient extends EventEmitter { }, roomId, createdAt: Date.now(), - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), }); } catch (error) { console.error("Error creating reaction removal message:", error); @@ -391,4 +391,4 @@ export const DiscordClientInterface: ElizaClient = { stop: async (_runtime: IAgentRuntime) => { console.warn("Discord client does not support stopping yet"); }, -}; \ No newline at end of file +}; diff --git a/packages/client-discord/src/messages.ts b/packages/client-discord/src/messages.ts index 6b37158fe5..1c276b65f0 100644 --- a/packages/client-discord/src/messages.ts +++ b/packages/client-discord/src/messages.ts @@ -267,7 +267,7 @@ export class MessageManager { url: m.url, }, roomId, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), createdAt: m.createdTimestamp, }; memories.push(memory); diff --git a/packages/client-discord/src/voice.ts b/packages/client-discord/src/voice.ts index f241ce0e60..c8b2bb5447 100644 --- a/packages/client-discord/src/voice.ts +++ b/packages/client-discord/src/voice.ts @@ -610,7 +610,7 @@ export class VoiceManager extends EventEmitter { }, userId: userIdUUID, roomId, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), createdAt: Date.now(), }; @@ -670,7 +670,7 @@ export class VoiceManager extends EventEmitter { inReplyTo: memory.id, }, roomId, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), }; if (responseMemory.content.text?.trim()) { diff --git a/packages/client-farcaster/src/memory.ts b/packages/client-farcaster/src/memory.ts index 0c22a438e5..c4c49081f5 100644 --- a/packages/client-farcaster/src/memory.ts +++ b/packages/client-farcaster/src/memory.ts @@ -43,7 +43,7 @@ export function createCastMemory({ hash: cast.id, }, roomId, - embedding: getEmbeddingZeroVector(runtime), + embedding: getEmbeddingZeroVector(), createdAt: cast.message.data.timestamp * 1000, }; } diff --git a/packages/client-telegram/src/messageManager.ts b/packages/client-telegram/src/messageManager.ts index a9b5f25242..10a3d233dc 100644 --- a/packages/client-telegram/src/messageManager.ts +++ b/packages/client-telegram/src/messageManager.ts @@ -405,7 +405,7 @@ export class MessageManager { roomId, content, createdAt: message.date * 1000, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), }; // Create memory @@ -468,7 +468,7 @@ export class MessageManager { inReplyTo: messageId, }, createdAt: sentMessage.date * 1000, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), }; // Set action to CONTINUE for all messages except the last one diff --git a/packages/client-twitter/src/base.ts b/packages/client-twitter/src/base.ts index 8edc44f035..336759b5fa 100644 --- a/packages/client-twitter/src/base.ts +++ b/packages/client-twitter/src/base.ts @@ -420,7 +420,7 @@ export class ClientBase extends EventEmitter { content: content, agentId: this.runtime.agentId, roomId, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), createdAt: tweet.timestamp * 1000, }); @@ -533,7 +533,7 @@ export class ClientBase extends EventEmitter { content: content, agentId: this.runtime.agentId, roomId, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), createdAt: tweet.timestamp * 1000, }); @@ -575,7 +575,7 @@ export class ClientBase extends EventEmitter { } else { await this.runtime.messageManager.createMemory({ ...message, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), }); } diff --git a/packages/client-twitter/src/interactions.ts b/packages/client-twitter/src/interactions.ts index 3d15ce5e09..f723b613ba 100644 --- a/packages/client-twitter/src/interactions.ts +++ b/packages/client-twitter/src/interactions.ts @@ -466,7 +466,7 @@ export class TwitterInteractionClient { currentTweet.userId === this.twitterUserId ? this.runtime.agentId : stringToUuid(currentTweet.userId), - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), }); } diff --git a/packages/client-twitter/src/post.ts b/packages/client-twitter/src/post.ts index b7b00f087f..b8355610f9 100644 --- a/packages/client-twitter/src/post.ts +++ b/packages/client-twitter/src/post.ts @@ -267,7 +267,7 @@ export class TwitterPostClient { source: "twitter", }, roomId, - embedding: getEmbeddingZeroVector(this.runtime), + embedding: getEmbeddingZeroVector(), createdAt: tweet.timestamp * 1000, }); } catch (error) { diff --git a/packages/client-twitter/src/utils.ts b/packages/client-twitter/src/utils.ts index 840c45c84c..1cbf4d0474 100644 --- a/packages/client-twitter/src/utils.ts +++ b/packages/client-twitter/src/utils.ts @@ -95,7 +95,7 @@ export async function buildConversationThread( currentTweet.userId === client.profile.id ? client.runtime.agentId : stringToUuid(currentTweet.userId), - embedding: getEmbeddingZeroVector(client.runtime), + embedding: getEmbeddingZeroVector(), }); } @@ -229,7 +229,7 @@ export async function sendTweet( : undefined, }, roomId, - embedding: getEmbeddingZeroVector(client.runtime), + embedding: getEmbeddingZeroVector(), createdAt: tweet.timestamp * 1000, })); diff --git a/packages/core/src/knowledge.ts b/packages/core/src/knowledge.ts index 9277b90e0b..961a17f8c8 100644 --- a/packages/core/src/knowledge.ts +++ b/packages/core/src/knowledge.ts @@ -77,7 +77,7 @@ async function set( userId: runtime.agentId, createdAt: Date.now(), content: item.content, - embedding: getEmbeddingZeroVector(runtime), + embedding: getEmbeddingZeroVector(), }); const preprocessed = preprocess(item.content.text); diff --git a/packages/core/src/memory.ts b/packages/core/src/memory.ts index b709d72d14..112352766f 100644 --- a/packages/core/src/memory.ts +++ b/packages/core/src/memory.ts @@ -70,7 +70,7 @@ export class MemoryManager implements IMemoryManager { } catch (error) { elizaLogger.error("Failed to generate embedding:", error); // Fallback to zero vector if embedding fails - memory.embedding = getEmbeddingZeroVector(this.runtime).slice(); + memory.embedding = getEmbeddingZeroVector().slice(); } return memory; From a336029525baefae539d0e4804ad170e82554ee7 Mon Sep 17 00:00:00 2001 From: cygaar Date: Fri, 29 Nov 2024 15:39:03 -0500 Subject: [PATCH 2/2] Fix eslint --- packages/adapter-postgres/src/index.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/adapter-postgres/src/index.ts b/packages/adapter-postgres/src/index.ts index 9611e7f6e3..9f3cbca633 100644 --- a/packages/adapter-postgres/src/index.ts +++ b/packages/adapter-postgres/src/index.ts @@ -3,7 +3,7 @@ import { v4 } from "uuid"; // Import the entire module as default import pg from "pg"; const { Pool } = pg; -type Pool = pg.Pool; +type PoolType = pg.Pool; import { QueryConfig, @@ -29,16 +29,14 @@ import fs from "fs"; import { fileURLToPath } from "url"; import path from "path"; -const { DatabaseError } = pg; - const __filename = fileURLToPath(import.meta.url); // get the resolved path to the file const __dirname = path.dirname(__filename); // get the name of the directory export class PostgresDatabaseAdapter - extends DatabaseAdapter + extends DatabaseAdapter implements IDatabaseCacheAdapter { - private pool: Pool; + private pool: PoolType; private readonly maxRetries: number = 3; private readonly baseDelay: number = 1000; // 1 second private readonly maxDelay: number = 10000; // 10 seconds @@ -758,7 +756,7 @@ export class PostgresDatabaseAdapter return this.withRetry(async () => { try { const relationshipId = v4(); - const result = await this.pool.query( + await this.pool.query( `INSERT INTO relationships (id, "userA", "userB", "userId") VALUES ($1, $2, $3, $4) RETURNING id`,