Skip to content

Commit

Permalink
fix: update lockfile and fix lint findings (#2128)
Browse files Browse the repository at this point in the history
* typo fix: close object

* update lockfile
  • Loading branch information
odilitime authored Jan 10, 2025
1 parent 87d8eca commit 7187c74
Show file tree
Hide file tree
Showing 25 changed files with 113 additions and 114 deletions.
34 changes: 17 additions & 17 deletions packages/adapter-postgres/src/__tests__/vector-extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import pg from 'pg';
import fs from 'fs';
import path from 'path';
import { describe, test, expect, beforeEach, afterEach, vi, beforeAll } from 'vitest';
import { DatabaseAdapter, elizaLogger, type Memory, type Content, EmbeddingProvider } from '@elizaos/core';
import { elizaLogger, type Memory, type Content } from '@elizaos/core';

// Increase test timeout
vi.setConfig({ testTimeout: 15000 });
Expand Down Expand Up @@ -41,7 +41,7 @@ vi.mock('@elizaos/core', () => ({
const parseVectorString = (vectorStr: string): number[] => {
if (!vectorStr) return [];
// Remove brackets and split by comma
return vectorStr.replace(/[\[\]]/g, '').split(',').map(Number);
return vectorStr.replace(/[[\]]/g, '').split(',').map(Number);
};

describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
user: 'postgres',
password: 'postgres'
});

const setupClient = await setupPool.connect();
try {
await cleanDatabase(setupClient);
Expand All @@ -133,13 +133,13 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
user: 'postgres',
password: 'postgres'
});

testClient = await testPool.connect();
elizaLogger.debug('Database connection established');

await cleanDatabase(testClient);
elizaLogger.debug('Database cleaned');

adapter = new PostgresDatabaseAdapter({
host: 'localhost',
port: 5433,
Expand Down Expand Up @@ -254,7 +254,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
elizaLogger.debug('Attempting initialization with error...');
await expect(adapter.init()).rejects.toThrow('Schema read error');
elizaLogger.success('Error thrown as expected');

// Verify no tables were created
elizaLogger.debug('Verifying rollback...');
const { rows } = await testClient.query(`
Expand All @@ -277,19 +277,19 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
describe('Memory Operations with Vector', () => {
const TEST_UUID = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee';
const TEST_TABLE = 'test_memories';

beforeEach(async () => {
elizaLogger.info('Setting up memory operations test...');
try {
// Ensure clean state and proper initialization
await adapter.init();

// Verify vector extension and search path
await testClient.query(`
SET search_path TO public, extensions;
SELECT set_config('app.use_openai_embedding', 'true', false);
`);

// Create necessary account and room first
await testClient.query('BEGIN');
try {
Expand All @@ -298,19 +298,19 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
VALUES ($1, 'test@test.com')
ON CONFLICT (id) DO NOTHING
`, [TEST_UUID]);

await testClient.query(`
INSERT INTO rooms (id)
VALUES ($1)
ON CONFLICT (id) DO NOTHING
`, [TEST_UUID]);

await testClient.query('COMMIT');
} catch (error) {
await testClient.query('ROLLBACK');
throw error;
}

} catch (error) {
elizaLogger.error('Memory operations setup failed:', {
error: error instanceof Error ? error.message : String(error)
Expand All @@ -324,7 +324,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
const content: Content = {
text: 'test content'
};

const memory: Memory = {
id: TEST_UUID,
content,
Expand Down Expand Up @@ -383,7 +383,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
await testClient.query('ROLLBACK');
throw error;
}

// Act
const results = await adapter.searchMemoriesByEmbedding(embedding, {
tableName: TEST_TABLE,
Expand All @@ -405,7 +405,7 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
const content: Content = {
text: 'test content'
};

const memory: Memory = {
id: TEST_UUID,
content,
Expand All @@ -430,4 +430,4 @@ describe('PostgresDatabaseAdapter - Vector Extension Validation', () => {
}
}, { timeout: 30000 }); // Increased timeout for retry attempts
});
});
});
2 changes: 1 addition & 1 deletion packages/adapter-sqljs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ export class SqlJsDatabaseAdapter
return JSON.parse(cachedResult);
}

let sql = `
const sql = `
WITH vector_scores AS (
SELECT id,
1 / (1 + vec_distance_L2(embedding, ?)) as vector_score
Expand Down
2 changes: 1 addition & 1 deletion packages/client-direct/src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function createApiRouter(
return;
}

let character = agent?.character;
const character = agent?.character;
if (character?.settings?.secrets) {
delete character.settings.secrets;
}
Expand Down
82 changes: 40 additions & 42 deletions packages/client-direct/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,12 @@ export class DirectClient {

// hyperfi specific parameters
let nearby = [];
let messages = [];
let availableEmotes = [];

if (body.nearby) {
nearby = body.nearby;
}
if (body.messages) {
messages = body.messages;
// loop on the messages and record the memories
// might want to do this in parallel
for (const msg of body.messages) {
Expand Down Expand Up @@ -502,10 +500,17 @@ export class DirectClient {
schema: hyperfiOutSchema,
});

if (!response) {
res.status(500).send(
"No response from generateMessageResponse"
);
return;
}

let hfOut;
try {
hfOut = hyperfiOutSchema.parse(response.object);
} catch (e) {
} catch {
elizaLogger.error(
"cant serialize response",
response.object
Expand All @@ -515,7 +520,7 @@ export class DirectClient {
}

// do this in the background
const rememberThis = new Promise(async (resolve) => {
new Promise((resolve) => {
const contentObj: Content = {
text: hfOut.say,
};
Expand Down Expand Up @@ -545,45 +550,38 @@ export class DirectClient {
content: contentObj,
};

await runtime.messageManager.createMemory(responseMessage); // 18.2ms

if (!response) {
res.status(500).send(
"No response from generateMessageResponse"
);
return;
}

let message = null as Content | null;

const messageId = stringToUuid(Date.now().toString());
const memory: Memory = {
id: messageId,
agentId: runtime.agentId,
userId,
roomId,
content,
createdAt: Date.now(),
};

// run evaluators (generally can be done in parallel with processActions)
// can an evaluator modify memory? it could but currently doesn't
await runtime.evaluate(memory, state); // 0.5s

// only need to call if responseMessage.content.action is set
if (contentObj.action) {
// pass memory (query) to any actions to call
const _result = await runtime.processActions(
memory,
[responseMessage],
state,
async (newMessages) => {
message = newMessages;
return [memory];
runtime.messageManager.createMemory(responseMessage).then(() => {
const messageId = stringToUuid(Date.now().toString());
const memory: Memory = {
id: messageId,
agentId: runtime.agentId,
userId,
roomId,
content,
createdAt: Date.now(),
};

// run evaluators (generally can be done in parallel with processActions)
// can an evaluator modify memory? it could but currently doesn't
runtime.evaluate(memory, state).then(() => {
// only need to call if responseMessage.content.action is set
if (contentObj.action) {
// pass memory (query) to any actions to call
runtime.processActions(
memory,
[responseMessage],
state,
async (newMessages) => {
// FIXME: this is supposed override what the LLM said/decided
// but the promise doesn't make this possible
//message = newMessages;
return [memory];
}
); // 0.674s
}
); // 0.674s
}
resolve(true);
resolve(true);
});
});
});
res.json({ response: hfOut });
}
Expand Down
1 change: 0 additions & 1 deletion packages/client-slack/src/actions/chat_with_attachments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
parseJSONObjectFromText,
getModelSettings,
} from "@elizaos/core";
import { models } from "@elizaos/core";
import {
Action,
ActionExample,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
parseJSONObjectFromText,
getModelSettings,
} from "@elizaos/core";
import { models } from "@elizaos/core";
import { getActorDetails } from "@elizaos/core";
import {
Action,
Expand Down
2 changes: 1 addition & 1 deletion packages/client-twitter/src/plugins/SttTtsSpacesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class SttTtsPlugin implements Plugin {
private ttsQueue: string[] = [];
private isSpeaking = false;

onAttach(space: Space) {
onAttach(_space: Space) {
elizaLogger.log("[SttTtsPlugin] onAttach => space was attached");
}

Expand Down
2 changes: 1 addition & 1 deletion packages/client-twitter/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function extractUrls(paragraph: string): {
function splitSentencesAndWords(text: string, maxLength: number): string[] {
// Split by periods, question marks and exclamation marks
// Note that URLs in text have been replaced with `<<URL_xxx>>` and won't be split by dots
const sentences = text.match(/[^\.!\?]+[\.!\?]+|[^\.!\?]+$/g) || [text];
const sentences = text.match(/[^.!?]+[.!?]+|[^.!?]+$/g) || [text];
const chunks: string[] = [];
let currentChunk = "";

Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import {
IVerifiableInferenceAdapter,
VerifiableInferenceOptions,
VerifiableInferenceResult,
VerifiableInferenceProvider,
//VerifiableInferenceProvider,
TelemetrySettings,
TokenizerType,
} from "./types.ts";
Expand Down Expand Up @@ -1777,9 +1777,9 @@ export async function handleProvider(
runtime,
context,
modelClass,
verifiableInference,
verifiableInferenceAdapter,
verifiableInferenceOptions,
//verifiableInference,
//verifiableInferenceAdapter,
//verifiableInferenceOptions,
} = options;
switch (provider) {
case ModelProviderName.OPENAI:
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/ragknowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,14 +299,14 @@ export class RAGKnowledgeManager implements IRAGKnowledgeManager {
};

const startTime = Date.now();
let content = file.content;
const content = file.content;

try {
const fileSizeKB = (new TextEncoder().encode(content)).length / 1024;
elizaLogger.info(`[File Progress] Starting ${file.path} (${fileSizeKB.toFixed(2)} KB)`);

// Step 1: Preprocessing
const preprocessStart = Date.now();
//const preprocessStart = Date.now();
const processedContent = this.preprocess(content);
timeMarker('Preprocessing');

Expand Down
9 changes: 3 additions & 6 deletions packages/core/src/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import {
IRAGKnowledgeManager,
IMemoryManager,
KnowledgeItem,
RAGKnowledgeItem,
Media,
//RAGKnowledgeItem,
//Media,
ModelClass,
ModelProviderName,
Plugin,
Expand Down Expand Up @@ -546,10 +546,7 @@ export class AgentRuntime implements IAgentRuntime {
agentId: this.agentId
});

let content: string;

content = await readFile(filePath, 'utf8');

const content: string = await readFile(filePath, 'utf8');
if (!content) {
hasError = true;
continue;
Expand Down
3 changes: 2 additions & 1 deletion packages/plugin-anyone/src/actions/startAnyone.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export const startAnyone: Action = {
_callback: HandlerCallback
): Promise<boolean> => {
await AnyoneClientService.initialize();
const anon = AnyoneClientService.getInstance();
//lint says unused
//const anon = AnyoneClientService.getInstance();
const proxyService = AnyoneProxyService.getInstance();
await proxyService.initialize();

Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-autonome/src/actions/launchAgent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Given the recent messages, extract the following information about the requested
export default {
name: "LAUNCH_AGENT",
similes: ["CREATE_AGENT", "DEPLOY_AGENT", "DEPLOY_ELIZA", "DEPLOY_BOT"],
validate: async (runtime: IAgentRuntime, message: Memory) => {
validate: async (_runtime: IAgentRuntime, _message: Memory) => {
return true;
},
description: "Launch an Eliza agent",
Expand Down
Loading

0 comments on commit 7187c74

Please sign in to comment.