diff --git a/packages/core/src/generation.ts b/packages/core/src/generation.ts index 657ace24b0..f93b5abe1b 100644 --- a/packages/core/src/generation.ts +++ b/packages/core/src/generation.ts @@ -146,11 +146,22 @@ export async function generateText({ elizaLogger.info("Selected model:", model); - const temperature = models[provider].settings.temperature; - const frequency_penalty = models[provider].settings.frequency_penalty; - const presence_penalty = models[provider].settings.presence_penalty; - const max_context_length = models[provider].settings.maxInputTokens; - const max_response_length = models[provider].settings.maxOutputTokens; + const modelConfiguration = runtime.character?.settings?.modelConfig; + const temperature = + modelConfiguration?.temperature || + models[provider].settings.temperature; + const frequency_penalty = + modelConfiguration?.frequency_penalty || + models[provider].settings.frequency_penalty; + const presence_penalty = + modelConfiguration?.presence_penalty || + models[provider].settings.presence_penalty; + const max_context_length = + modelConfiguration?.maxInputTokens || + models[provider].settings.maxInputTokens; + const max_response_length = + modelConfiguration.max_response_length || + models[provider].settings.maxOutputTokens; const apiKey = runtime.token; diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts index 8e98a8e93e..6786bb99f9 100644 --- a/packages/core/src/types.ts +++ b/packages/core/src/types.ts @@ -626,6 +626,14 @@ export interface IAgentConfig { [key: string]: string; } +export interface ModelConfiguration { + temperature?: number; + max_response_length?: number; + frequency_penalty?: number; + presence_penalty?: number; + maxInputTokens?: number; +} + /** * Configuration for an agent character */ @@ -738,6 +746,7 @@ export type Character = { }; }; model?: string; + modelConfig?: ModelConfiguration; embeddingModel?: string; chains?: { evm?: any[];