Skip to content

Commit d22ee0e

Browse files
authored
Merge pull request elizaOS#1455 from peersky/patch-2
feat: Add ModelConfiguration to Character to enable adjusting temperature, response length & penalties
2 parents a66d964 + f0bccd6 commit d22ee0e

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

packages/core/src/generation.ts

+16-5
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,22 @@ export async function generateText({
146146

147147
elizaLogger.info("Selected model:", model);
148148

149-
const temperature = models[provider].settings.temperature;
150-
const frequency_penalty = models[provider].settings.frequency_penalty;
151-
const presence_penalty = models[provider].settings.presence_penalty;
152-
const max_context_length = models[provider].settings.maxInputTokens;
153-
const max_response_length = models[provider].settings.maxOutputTokens;
149+
const modelConfiguration = runtime.character?.settings?.modelConfig;
150+
const temperature =
151+
modelConfiguration?.temperature ||
152+
models[provider].settings.temperature;
153+
const frequency_penalty =
154+
modelConfiguration?.frequency_penalty ||
155+
models[provider].settings.frequency_penalty;
156+
const presence_penalty =
157+
modelConfiguration?.presence_penalty ||
158+
models[provider].settings.presence_penalty;
159+
const max_context_length =
160+
modelConfiguration?.maxInputTokens ||
161+
models[provider].settings.maxInputTokens;
162+
const max_response_length =
163+
modelConfiguration.max_response_length ||
164+
models[provider].settings.maxOutputTokens;
154165

155166
const apiKey = runtime.token;
156167

packages/core/src/types.ts

+9
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,14 @@ export interface IAgentConfig {
626626
[key: string]: string;
627627
}
628628

629+
export interface ModelConfiguration {
630+
temperature?: number;
631+
max_response_length?: number;
632+
frequency_penalty?: number;
633+
presence_penalty?: number;
634+
maxInputTokens?: number;
635+
}
636+
629637
/**
630638
* Configuration for an agent character
631639
*/
@@ -738,6 +746,7 @@ export type Character = {
738746
};
739747
};
740748
model?: string;
749+
modelConfig?: ModelConfiguration;
741750
embeddingModel?: string;
742751
chains?: {
743752
evm?: any[];

0 commit comments

Comments
 (0)