@@ -748,23 +748,6 @@ export function createManageApiRouter(
748
748
return ;
749
749
}
750
750
751
- // if(runtime.character.modelProvider !== modelProvider) {
752
- // runtime.character.modelProvider = modelProvider;
753
- // runtime.modelProvider = modelProvider;
754
- // if(secrets) {
755
- // Object.assign(runtime.character.settings, secrets);
756
- // }
757
- // elizaLogger.log(`runtime model provider changed to ${modelProvider}`);
758
- // }
759
-
760
- await runtime . ensureConnection (
761
- userId ,
762
- roomId ,
763
- runtime . character . username ,
764
- runtime . character . name ,
765
- "direct"
766
- ) ;
767
-
768
751
const tpl = await directClient . loadCharacterTryPath ( 'characters/lpmanager.character.json' ) ;
769
752
if ( ! tpl ) {
770
753
res . status ( 500 ) . send ( { error : "Failed to load template" } ) ;
@@ -776,6 +759,21 @@ export function createManageApiRouter(
776
759
tpl . settings . secrets = secrets ;
777
760
}
778
761
762
+ if ( runtime . character . modelProvider !== modelProvider ) {
763
+ runtime . character . modelProvider = modelProvider ;
764
+ runtime . modelProvider = modelProvider ;
765
+ runtime . token = directClient . getTokenForProvider ( modelProvider , tpl ) ;
766
+ elizaLogger . log ( `runtime model provider changed to ${ modelProvider } ` ) ;
767
+ }
768
+
769
+ await runtime . ensureConnection (
770
+ userId ,
771
+ roomId ,
772
+ runtime . character . username ,
773
+ runtime . character . name ,
774
+ "direct"
775
+ ) ;
776
+
779
777
const text = `According to the user-provided [description] in accordance with the provided json format [template] to generate the user's json content.
780
778
[description]: ${ description } .
781
779
[template]: ${ JSON . stringify ( tpl ) } ` ;
0 commit comments