Skip to content

Commit

Permalink
Fixed all the errors (#3063)
Browse files Browse the repository at this point in the history
  • Loading branch information
AIFlowML authored Jan 31, 2025
1 parent 3aa73fc commit 85046c5
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 38 deletions.
41 changes: 41 additions & 0 deletions packages/plugin-echochambers/biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"$schema": "https://biomejs.dev/schemas/1.5.3/schema.json",
"organizeImports": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "error"
},
"suspicious": {
"noExplicitAny": "error"
},
"style": {
"useConst": "error",
"useImportType": "off"
}
}
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 4,
"lineWidth": 100
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "es5"
}
},
"files": {
"ignore": [
"dist/**/*",
"extra/**/*",
"node_modules/**/*"
]
}
}
3 changes: 0 additions & 3 deletions packages/plugin-echochambers/eslint.config.mjs

This file was deleted.

9 changes: 8 additions & 1 deletion packages/plugin-echochambers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
"scripts": {
"build": "tsup --format esm --dts",
"dev": "tsup --format esm --dts --watch",
"lint": "eslint --fix --cache ."
"clean": "rm -rf dist",
"lint": "biome lint .",
"lint:fix": "biome check --apply .",
"format": "biome format .",
"format:fix": "biome format --write ."
},
"devDependencies": {
"@biomejs/biome": "1.9.4"
}
}
2 changes: 1 addition & 1 deletion packages/plugin-echochambers/src/echoChamberClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class EchoChamberClient {
return await operation();
} catch (error) {
if (i === retries - 1) throw error;
const delay = RETRY_DELAY * Math.pow(2, i);
const delay = RETRY_DELAY * (2 ** i);
elizaLogger.warn(`Retrying operation in ${delay}ms...`);
await new Promise((resolve) => setTimeout(resolve, delay));
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin-echochambers/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export async function validateEchoChamberConfig(
runtime.getSetting("ECHOCHAMBERS_POLL_INTERVAL") || 120
);

if (isNaN(pollInterval) || pollInterval < 1) {
if (Number.isNaN(pollInterval) || pollInterval < 1) {
elizaLogger.error(
"ECHOCHAMBERS_POLL_INTERVAL must be a positive number in seconds"
);
Expand Down
78 changes: 46 additions & 32 deletions packages/plugin-echochambers/src/interactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ import type { EchoChamberClient } from "./echoChamberClient";
import type { ChatMessage, ChatRoom } from "./types";

function createMessageTemplate(currentRoom: string, roomTopic: string) {
return (
`
return `
# About {{agentName}}:
{{bio}}
{{lore}}
Expand Down Expand Up @@ -47,13 +46,12 @@ Remember:
- Stay on topic for the current room
- Don't repeat information already shared
- Be natural and conversational
` + messageCompletionFooter
);
${messageCompletionFooter}`;
}

function createShouldRespondTemplate(currentRoom: string, roomTopic: string) {
return (
`
return `
# About {{agentName}}:
{{bio}}
{{knowledge}}
Expand Down Expand Up @@ -95,8 +93,8 @@ Consider:
2. Current conversation context
3. Time since last response
4. Value of potential contribution
` + shouldRespondFooter
);
${shouldRespondFooter}`;
}

function createConversationStarterTemplate(
Expand Down Expand Up @@ -320,11 +318,12 @@ export class InteractionClient {

private async handleMessage(message: ChatMessage, roomTopic: string) {
try {
const content = `${message.content?.substring(0, 50)}...`; // First 50 chars
elizaLogger.debug("Processing message:", {
id: message.id,
room: message.roomId,
sender: message?.sender?.username,
content: message.content?.substring(0, 50) + "...", // First 50 chars
content: `${content}`,
});

const roomId = stringToUuid(message.roomId);
Expand Down Expand Up @@ -543,24 +542,32 @@ export class InteractionClient {
);
}
}
} catch (roomError: any) {
} catch (roomError: unknown) {
// Log individual room errors without stopping the loop
elizaLogger.error(`Error processing room ${roomId}:`, {
error: roomError?.message || roomError,
stack: roomError?.stack,
});
if (roomError instanceof Error) {
elizaLogger.error(`Error processing room ${roomId}:`, {
error: roomError.message,
stack: roomError.stack,
});
} else {
elizaLogger.error(`Error processing room ${roomId}:`, roomError);
}
}
}
} catch (error: any) {
elizaLogger.error(
"Error in checkForDeadRooms:",
error?.message || error || "Unknown error"
);
elizaLogger.debug("Full error details:", {
error,
stack: error?.stack,
type: typeof error,
});
} catch (error: unknown) {
if (error instanceof Error) {
elizaLogger.error(
"Error in checkForDeadRooms:",
error.message || "Unknown error"
);
elizaLogger.debug("Full error details:", {
error,
stack: error.stack,
type: typeof error,
});
} else {
elizaLogger.error("Error in checkForDeadRooms:", String(error));
}
}
}

Expand Down Expand Up @@ -612,14 +619,21 @@ export class InteractionClient {
`Started conversation in ${room.name} (Topic: ${room.topic})`
);
}
} catch (error: any) {
elizaLogger.error(
`Error in initiateConversation for ${room.name}:`,
{
error: error?.message || error,
stack: error?.stack,
}
);
} catch (error: unknown) {
if (error instanceof Error) {
elizaLogger.error(
`Error in initiateConversation for ${room.name}:`,
{
error: error.message,
stack: error.stack,
}
);
} else {
elizaLogger.error(
`Error in initiateConversation for ${room.name}:`,
String(error)
);
}
throw error; // Re-throw to be caught by parent
}
}
Expand Down

0 comments on commit 85046c5

Please sign in to comment.