@@ -95,10 +95,6 @@ use parser::{
95
95
RecvErrorKind ,
96
96
ResponseParser ,
97
97
} ;
98
- use rand:: distr:: {
99
- Alphanumeric ,
100
- SampleString ,
101
- } ;
102
98
use regex:: Regex ;
103
99
use serde_json:: Map ;
104
100
use spinners:: {
@@ -146,7 +142,6 @@ use util::{
146
142
animate_output,
147
143
drop_matched_context_files,
148
144
play_notification_bell,
149
- region_check,
150
145
} ;
151
146
use uuid:: Uuid ;
152
147
use winnow:: Partial ;
@@ -171,7 +166,6 @@ use crate::telemetry::{
171
166
TelemetryResult ,
172
167
TelemetryThread ,
173
168
} ;
174
- use crate :: util:: CLI_BINARY_NAME ;
175
169
176
170
#[ derive( Debug , Clone , PartialEq , Eq , Default , Args ) ]
177
171
pub struct ChatArgs {
@@ -205,15 +199,6 @@ pub struct ChatArgs {
205
199
206
200
impl ChatArgs {
207
201
pub async fn execute ( self , database : & mut Database , telemetry : & TelemetryThread ) -> Result < ExitCode > {
208
- if !crate :: util:: system_info:: in_cloudshell ( ) && !crate :: auth:: is_logged_in ( database) . await {
209
- bail ! (
210
- "You are not logged in, please log in with {}" ,
211
- format!( "{CLI_BINARY_NAME} login" ) . bold( )
212
- ) ;
213
- }
214
-
215
- region_check ( "chat" ) ?;
216
-
217
202
let ctx = Context :: new ( ) ;
218
203
219
204
let stdin = std:: io:: stdin ( ) ;
@@ -299,7 +284,8 @@ impl ChatArgs {
299
284
// if let Some(ref id) = model_id {
300
285
// database.set_last_used_model_id(id.clone())?;
301
286
// }
302
- let conversation_id = Alphanumeric . sample_string ( & mut rand:: rng ( ) , 9 ) ;
287
+
288
+ let conversation_id = uuid:: Uuid :: new_v4 ( ) . to_string ( ) ;
303
289
info ! ( ?conversation_id, "Generated new conversation id" ) ;
304
290
let ( prompt_request_sender, prompt_request_receiver) = std:: sync:: mpsc:: channel :: < Option < String > > ( ) ;
305
291
let ( prompt_response_sender, prompt_response_receiver) = std:: sync:: mpsc:: channel :: < Vec < String > > ( ) ;
@@ -1482,9 +1468,10 @@ impl ChatContext {
1482
1468
self . send_tool_use_telemetry ( telemetry) . await ;
1483
1469
1484
1470
if self . interactive {
1485
- // Print newlines before starting the assistant response
1486
- execute ! ( self . output, style:: Print ( " \n \n " ) ) ?;
1471
+ queue ! ( self . output , style :: SetForegroundColor ( Color :: Magenta ) ) ? ;
1472
+ queue ! ( self . output, style:: SetForegroundColor ( Color :: Reset ) ) ?;
1487
1473
queue ! ( self . output, cursor:: Hide ) ?;
1474
+ execute ! ( self . output, style:: Print ( "\n " ) ) ?;
1488
1475
self . spinner = Some ( Spinner :: new ( Spinners :: Dots , "Thinking..." . to_owned ( ) ) ) ;
1489
1476
}
1490
1477
@@ -3382,18 +3369,6 @@ impl ChatContext {
3382
3369
) ?;
3383
3370
}
3384
3371
3385
- // Add assistant indicator at the beginning of the response
3386
- if self . interactive {
3387
- queue ! (
3388
- self . output,
3389
- style:: SetForegroundColor ( Color :: Yellow ) ,
3390
- style:: SetAttribute ( Attribute :: Bold ) ,
3391
- style:: Print ( "Amazon Q > " ) ,
3392
- style:: SetAttribute ( Attribute :: Reset ) ,
3393
- style:: SetForegroundColor ( Color :: Reset ) ,
3394
- ) ?;
3395
- }
3396
-
3397
3372
loop {
3398
3373
match parser. recv ( ) . await {
3399
3374
Ok ( msg_event) => {
@@ -3482,37 +3457,12 @@ impl ChatContext {
3482
3457
tool_use_id,
3483
3458
name,
3484
3459
message,
3485
- time_elapsed ,
3460
+ ..
3486
3461
} => {
3487
3462
error ! (
3488
3463
recv_error. request_id,
3489
3464
tool_use_id, name, "The response stream ended before the entire tool use was received"
3490
3465
) ;
3491
- if self . interactive {
3492
- drop ( self . spinner . take ( ) ) ;
3493
- queue ! (
3494
- self . output,
3495
- terminal:: Clear ( terminal:: ClearType :: CurrentLine ) ,
3496
- cursor:: MoveToColumn ( 0 ) ,
3497
- style:: SetForegroundColor ( Color :: Yellow ) ,
3498
- style:: SetAttribute ( Attribute :: Bold ) ,
3499
- style:: Print ( format!(
3500
- "Warning: received an unexpected error from the model after {:.2}s" ,
3501
- time_elapsed. as_secs_f64( )
3502
- ) ) ,
3503
- ) ?;
3504
- if let Some ( request_id) = recv_error. request_id {
3505
- queue ! (
3506
- self . output,
3507
- style:: Print ( format!( "\n request_id: {}" , request_id) )
3508
- ) ?;
3509
- }
3510
- execute ! ( self . output, style:: Print ( "\n \n " ) , style:: SetAttribute ( Attribute :: Reset ) ) ?;
3511
- self . spinner = Some ( Spinner :: new (
3512
- Spinners :: Dots ,
3513
- "Trying to divide up the work..." . to_string ( ) ,
3514
- ) ) ;
3515
- }
3516
3466
3517
3467
self . conversation_state . push_assistant_message ( * message, database) ;
3518
3468
let tool_results = vec ! [ ToolUseResult {
@@ -3570,7 +3520,7 @@ impl ChatContext {
3570
3520
3571
3521
// TODO: We should buffer output based on how much we have to parse, not as a constant
3572
3522
// Do not remove unless you are nabochay :)
3573
- std :: thread :: sleep ( Duration :: from_millis ( 8 ) ) ;
3523
+ tokio :: time :: sleep ( Duration :: from_millis ( 8 ) ) . await ;
3574
3524
}
3575
3525
3576
3526
// Set spinner after showing all of the assistant text content so far.
0 commit comments