Skip to content

Commit

Permalink
Merge pull request elizaOS#953 from odilitime/fix-openrouter
Browse files Browse the repository at this point in the history
feat: allow character.json settings models for open router
  • Loading branch information
shakkernerd authored Dec 10, 2024
2 parents cbb5680 + 703bc54 commit ca885a8
Showing 1 changed file with 43 additions and 21 deletions.
64 changes: 43 additions & 21 deletions packages/core/src/generation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,49 @@ export async function generateText({
runtime.character.modelEndpointOverride || models[provider].endpoint;
let model = models[provider].model[modelClass];

// if runtime.getSetting("LLAMACLOUD_MODEL_LARGE") is true and modelProvider is LLAMACLOUD, then use the large model
if (
(runtime.getSetting("LLAMACLOUD_MODEL_LARGE") &&
provider === ModelProviderName.LLAMACLOUD) ||
(runtime.getSetting("TOGETHER_MODEL_LARGE") &&
provider === ModelProviderName.TOGETHER)
) {
model =
runtime.getSetting("LLAMACLOUD_MODEL_LARGE") ||
runtime.getSetting("TOGETHER_MODEL_LARGE");
}

if (
(runtime.getSetting("LLAMACLOUD_MODEL_SMALL") &&
provider === ModelProviderName.LLAMACLOUD) ||
(runtime.getSetting("TOGETHER_MODEL_SMALL") &&
provider === ModelProviderName.TOGETHER)
) {
model =
runtime.getSetting("LLAMACLOUD_MODEL_SMALL") ||
runtime.getSetting("TOGETHER_MODEL_SMALL");
// allow character.json settings => secrets to override models
// FIXME: add MODEL_MEDIUM support
switch(provider) {
// if runtime.getSetting("LLAMACLOUD_MODEL_LARGE") is true and modelProvider is LLAMACLOUD, then use the large model
case ModelProviderName.LLAMACLOUD: {
switch(modelClass) {
case ModelClass.LARGE: {
model = runtime.getSetting("LLAMACLOUD_MODEL_LARGE") || model;
}
break;
case ModelClass.SMALL: {
model = runtime.getSetting("LLAMACLOUD_MODEL_SMALL") || model;
}
break;
}
}
break;
case ModelProviderName.TOGETHER: {
switch(modelClass) {
case ModelClass.LARGE: {
model = runtime.getSetting("TOGETHER_MODEL_LARGE") || model;
}
break;
case ModelClass.SMALL: {
model = runtime.getSetting("TOGETHER_MODEL_SMALL") || model;
}
break;
}
}
break;
case ModelProviderName.OPENROUTER: {
switch(modelClass) {
case ModelClass.LARGE: {
model = runtime.getSetting("LARGE_OPENROUTER_MODEL") || model;
}
break;
case ModelClass.SMALL: {
model = runtime.getSetting("SMALL_OPENROUTER_MODEL") || model;
}
break;
}
}
break;
}

elizaLogger.info("Selected model:", model);
Expand Down

0 comments on commit ca885a8

Please sign in to comment.