Skip to content

Commit

Permalink
feat: always use stream unless set --no-stream explicitly (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigoden committed Apr 15, 2024
1 parent 16e9c64 commit 9149954
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ fn start_directive(
ensure_model_capabilities(client.as_mut(), input.required_capabilities())?;
config.read().maybe_print_send_tokens(&input);
let is_terminal_stdout = stdout().is_terminal();
let output = if !is_terminal_stdout || no_stream {
let extract_code = !is_terminal_stdout && code_mode;
let output = if no_stream || extract_code {
let output = client.send_message(input.clone())?;
let output = if code_mode && output.trim_start().starts_with("```") {
let output = if extract_code && output.trim_start().starts_with("```") {
extract_block(&output)
} else {
output.clone()
Expand Down

1 comment on commit 9149954

@johnd0e
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!
However, I've noticed a difference between streaming to a terminal and streaming to a pipe.
In a pipe, the text doesn't appear chunk by chunk, but rather line by line.

Please sign in to comment.