diff --git a/docs/docs/guides/template-configuration.md b/docs/docs/guides/template-configuration.md index febeb02f4f..4e5376b671 100644 --- a/docs/docs/guides/template-configuration.md +++ b/docs/docs/guides/template-configuration.md @@ -15,14 +15,14 @@ Here are all the template options you can configure: ```json { "templates": { - "goalsTemplate": "", // Define character goals - "factsTemplate": "", // Specify character knowledge - "messageHandlerTemplate": "", // Handle general messages - "shouldRespondTemplate": "", // Control response triggers + "goalsTemplate": "", // Define character goals + "factsTemplate": "", // Specify character knowledge + "messageHandlerTemplate": "", // Handle general messages + "shouldRespondTemplate": "", // Control response triggers "continueMessageHandlerTemplate": "", // Manage conversation flow - "evaluationTemplate": "", // Handle response evaluation - "twitterSearchTemplate": "", // Process Twitter searches - "twitterPostTemplate": "", // Format Twitter posts + "evaluationTemplate": "", // Handle response evaluation + "twitterSearchTemplate": "", // Process Twitter searches + "twitterPostTemplate": "", // Format Twitter posts "twitterMessageHandlerTemplate": "", // Handle Twitter messages "twitterShouldRespondTemplate": "", // Control Twitter responses "telegramMessageHandlerTemplate": "", // Handle Telegram messages @@ -60,11 +60,11 @@ Configure platform-specific behaviors for your character, such as handling direc "clientConfig": { "telegram": { "shouldIgnoreDirectMessages": true, // Ignore DMs - "shouldIgnoreBotMessages": true // Ignore bot messages + "shouldIgnoreBotMessages": true // Ignore bot messages }, "discord": { - "shouldIgnoreBotMessages": true, // Ignore bot messages - "shouldIgnoreDirectMessages": true // Ignore DMs + "shouldIgnoreBotMessages": true, // Ignore bot messages + "shouldIgnoreDirectMessages": true // Ignore DMs } } } @@ -73,11 +73,13 @@ Configure platform-specific behaviors for your character, such as handling direc ## Best Practices 1. **Template Management** + - Keep templates focused and specific - Use clear, consistent formatting - Document custom template behavior 2. **Client Configuration** + - Configure per platform as needed - Test behavior in development - Monitor interaction patterns diff --git a/packages/core/src/embedding.ts b/packages/core/src/embedding.ts index c14f8b38ce..2d03d3f4bb 100644 --- a/packages/core/src/embedding.ts +++ b/packages/core/src/embedding.ts @@ -37,7 +37,7 @@ async function getRemoteEmbedding( : {}), }, body: JSON.stringify({ - input: trimTokens(input, 8191, "gpt-4o-mini"), + input: trimTokens(input, 8000, "gpt-4o-mini"), model: options.model, length: options.length || 384, }), @@ -160,9 +160,11 @@ async function getLocalEmbedding(input: string): Promise { return await import("fastembed"); } catch (error) { elizaLogger.error("Failed to load fastembed."); - throw new Error("fastembed import failed, falling back to remote embedding"); + throw new Error( + "fastembed import failed, falling back to remote embedding" + ); } - })() + })(), ]); const [fs, { fileURLToPath }, fastEmbed] = moduleImports; @@ -190,11 +192,13 @@ async function getLocalEmbedding(input: string): Promise { cacheDir: cacheDir, }); - const trimmedInput = trimTokens(input, 8191, "gpt-4o-mini"); + const trimmedInput = trimTokens(input, 8000, "gpt-4o-mini"); const embedding = await embeddingModel.queryEmbed(trimmedInput); return embedding; } catch (error) { - elizaLogger.warn("Local embedding not supported in browser, falling back to remote embedding."); + elizaLogger.warn( + "Local embedding not supported in browser, falling back to remote embedding." + ); throw new Error("Local embedding not supported in browser"); } } diff --git a/packages/core/src/generation.ts b/packages/core/src/generation.ts index 91663bdd0e..3fe3174fe8 100644 --- a/packages/core/src/generation.ts +++ b/packages/core/src/generation.ts @@ -420,6 +420,7 @@ export function trimTokens( encoding.free(); } } + /** * Sends a message to the model to determine if it should respond to the given context. * @param opts - The options for the generateText request