Skip to content

Commit e31e666

Browse files
Merge pull request #515 from ai16z/fix/trim
fix: lint
2 parents 02b5145 + 8d32603 commit e31e666

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

docs/docs/guides/template-configuration.md

+12-10
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ Here are all the template options you can configure:
1515
```json
1616
{
1717
"templates": {
18-
"goalsTemplate": "", // Define character goals
19-
"factsTemplate": "", // Specify character knowledge
20-
"messageHandlerTemplate": "", // Handle general messages
21-
"shouldRespondTemplate": "", // Control response triggers
18+
"goalsTemplate": "", // Define character goals
19+
"factsTemplate": "", // Specify character knowledge
20+
"messageHandlerTemplate": "", // Handle general messages
21+
"shouldRespondTemplate": "", // Control response triggers
2222
"continueMessageHandlerTemplate": "", // Manage conversation flow
23-
"evaluationTemplate": "", // Handle response evaluation
24-
"twitterSearchTemplate": "", // Process Twitter searches
25-
"twitterPostTemplate": "", // Format Twitter posts
23+
"evaluationTemplate": "", // Handle response evaluation
24+
"twitterSearchTemplate": "", // Process Twitter searches
25+
"twitterPostTemplate": "", // Format Twitter posts
2626
"twitterMessageHandlerTemplate": "", // Handle Twitter messages
2727
"twitterShouldRespondTemplate": "", // Control Twitter responses
2828
"telegramMessageHandlerTemplate": "", // Handle Telegram messages
@@ -60,11 +60,11 @@ Configure platform-specific behaviors for your character, such as handling direc
6060
"clientConfig": {
6161
"telegram": {
6262
"shouldIgnoreDirectMessages": true, // Ignore DMs
63-
"shouldIgnoreBotMessages": true // Ignore bot messages
63+
"shouldIgnoreBotMessages": true // Ignore bot messages
6464
},
6565
"discord": {
66-
"shouldIgnoreBotMessages": true, // Ignore bot messages
67-
"shouldIgnoreDirectMessages": true // Ignore DMs
66+
"shouldIgnoreBotMessages": true, // Ignore bot messages
67+
"shouldIgnoreDirectMessages": true // Ignore DMs
6868
}
6969
}
7070
}
@@ -73,11 +73,13 @@ Configure platform-specific behaviors for your character, such as handling direc
7373
## Best Practices
7474

7575
1. **Template Management**
76+
7677
- Keep templates focused and specific
7778
- Use clear, consistent formatting
7879
- Document custom template behavior
7980

8081
2. **Client Configuration**
82+
8183
- Configure per platform as needed
8284
- Test behavior in development
8385
- Monitor interaction patterns

packages/core/src/embedding.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ async function getRemoteEmbedding(
3737
: {}),
3838
},
3939
body: JSON.stringify({
40-
input: trimTokens(input, 8191, "gpt-4o-mini"),
40+
input: trimTokens(input, 8000, "gpt-4o-mini"),
4141
model: options.model,
4242
length: options.length || 384,
4343
}),
@@ -160,9 +160,11 @@ async function getLocalEmbedding(input: string): Promise<number[]> {
160160
return await import("fastembed");
161161
} catch (error) {
162162
elizaLogger.error("Failed to load fastembed.");
163-
throw new Error("fastembed import failed, falling back to remote embedding");
163+
throw new Error(
164+
"fastembed import failed, falling back to remote embedding"
165+
);
164166
}
165-
})()
167+
})(),
166168
]);
167169

168170
const [fs, { fileURLToPath }, fastEmbed] = moduleImports;
@@ -190,11 +192,13 @@ async function getLocalEmbedding(input: string): Promise<number[]> {
190192
cacheDir: cacheDir,
191193
});
192194

193-
const trimmedInput = trimTokens(input, 8191, "gpt-4o-mini");
195+
const trimmedInput = trimTokens(input, 8000, "gpt-4o-mini");
194196
const embedding = await embeddingModel.queryEmbed(trimmedInput);
195197
return embedding;
196198
} catch (error) {
197-
elizaLogger.warn("Local embedding not supported in browser, falling back to remote embedding.");
199+
elizaLogger.warn(
200+
"Local embedding not supported in browser, falling back to remote embedding."
201+
);
198202
throw new Error("Local embedding not supported in browser");
199203
}
200204
}

packages/core/src/generation.ts

+1
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ export function trimTokens(
420420
encoding.free();
421421
}
422422
}
423+
423424
/**
424425
* Sends a message to the model to determine if it should respond to the given context.
425426
* @param opts - The options for the generateText request

0 commit comments

Comments
 (0)