File tree Expand file tree Collapse file tree 4 files changed +46
-9
lines changed Expand file tree Collapse file tree 4 files changed +46
-9
lines changed Original file line number Diff line number Diff line change @@ -458,6 +458,12 @@ impl BuilderIdToken {
458
458
Some ( _) => TokenType :: IamIdentityCenter ,
459
459
}
460
460
}
461
+
462
+ /// Check if the token is for the internal amzn start URL (`https://amzn.awsapps.com/start`),
463
+ /// this implies the user will use midway for private specs
464
+ pub fn is_amzn_user ( & self ) -> bool {
465
+ matches ! ( & self . start_url, Some ( url) if url == AMZN_START_URL )
466
+ }
461
467
}
462
468
463
469
pub enum PollCreateToken {
Original file line number Diff line number Diff line change @@ -21,5 +21,8 @@ pub(crate) const CLIENT_TYPE: &str = "public";
21
21
// The start URL for public builder ID users
22
22
pub const START_URL : & str = "https://view.awsapps.com/start" ;
23
23
24
+ // The start URL for internal amzn users
25
+ pub const AMZN_START_URL : & str = "https://amzn.awsapps.com/start" ;
26
+
24
27
pub ( crate ) const DEVICE_GRANT_TYPE : & str = "urn:ietf:params:oauth:grant-type:device_code" ;
25
28
pub ( crate ) const REFRESH_GRANT_TYPE : & str = "refresh_token" ;
Original file line number Diff line number Diff line change @@ -9,11 +9,16 @@ use crossterm::{
9
9
} ;
10
10
use dialoguer:: Select ;
11
11
12
+ use crate :: auth:: builder_id:: {
13
+ BuilderIdToken ,
14
+ TokenType ,
15
+ } ;
12
16
use crate :: cli:: chat:: {
13
17
ChatError ,
14
18
ChatSession ,
15
19
ChatState ,
16
20
} ;
21
+ use crate :: os:: Os ;
17
22
18
23
pub struct ModelOption {
19
24
pub name : & ' static str ,
@@ -97,7 +102,23 @@ impl ModelArgs {
97
102
}
98
103
}
99
104
100
- /// Currently, Sonnet 4 is set as the default model for non-FRA users.
101
- pub fn default_model_id ( ) -> & ' static str {
102
- "CLAUDE_3_7_SONNET_20250219_V1_0"
105
+ /// Returns Claude 3.7 for: Amazon IDC users, FRA region users
106
+ /// Returns Claude 4.0 for: Builder ID users, other regions
107
+ pub async fn default_model_id ( os : & Os ) -> & ' static str {
108
+ // Check FRA region first
109
+ if let Ok ( Some ( profile) ) = os. database . get_auth_profile ( ) {
110
+ if profile. arn . split ( ':' ) . nth ( 3 ) == Some ( "eu-central-1" ) {
111
+ return "CLAUDE_3_7_SONNET_20250219_V1_0" ;
112
+ }
113
+ }
114
+
115
+ // Check if Amazon IDC user
116
+ if let Ok ( Some ( token) ) = BuilderIdToken :: load ( & os. database ) . await {
117
+ if matches ! ( token. token_type( ) , TokenType :: IamIdentityCenter ) && token. is_amzn_user ( ) {
118
+ return "CLAUDE_3_7_SONNET_20250219_V1_0" ;
119
+ }
120
+ }
121
+
122
+ // Default to 4.0
123
+ "CLAUDE_SONNET_4_20250514_V1_0"
103
124
}
Original file line number Diff line number Diff line change @@ -524,19 +524,26 @@ impl ChatSession {
524
524
tool_permissions : ToolPermissions ,
525
525
interactive : bool ,
526
526
) -> Result < Self > {
527
- let valid_model_id = model_id
528
- . or_else ( || {
529
- os. database
527
+ let valid_model_id = match model_id {
528
+ Some ( id) => id,
529
+ None => {
530
+ let from_settings = os
531
+ . database
530
532
. settings
531
533
. get_string ( Setting :: ChatDefaultModel )
532
534
. and_then ( |model_name| {
533
535
MODEL_OPTIONS
534
536
. iter ( )
535
537
. find ( |opt| opt. name == model_name)
536
538
. map ( |opt| opt. model_id . to_owned ( ) )
537
- } )
538
- } )
539
- . unwrap_or_else ( || default_model_id ( ) . to_owned ( ) ) ;
539
+ } ) ;
540
+
541
+ match from_settings {
542
+ Some ( id) => id,
543
+ None => default_model_id ( os) . await . to_owned ( ) ,
544
+ }
545
+ } ,
546
+ } ;
540
547
541
548
// Reload prior conversation
542
549
let mut existing_conversation = false ;
You can’t perform that action at this time.
0 commit comments