Skip to content

Commit

Permalink
Move magic value to static
Browse files Browse the repository at this point in the history
  • Loading branch information
andreban committed Feb 15, 2024
1 parent 19d8da1 commit fc8fa36
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/bin/generate-text-from-text-stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use reqwest::header::{self, HeaderValue};
static MODEL_NAME: &str = "gemini-pro";
static EVENT_STREAM_HEADER: HeaderValue = HeaderValue::from_static("text/event-stream");
static DATA: &str = "data: ";
static END_OF_CHUNK: &[u8] = b"\r\n\r\n";

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
Expand Down Expand Up @@ -64,7 +65,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

// Check if the buffer ends with the end of a chunk, i.e. "\r\n\r\n". If not, keep
// appending chunks to the buffer.
if !buffer.ends_with(b"\r\n\r\n") {
if !buffer.ends_with(END_OF_CHUNK) {
continue;
}

Expand Down

0 comments on commit fc8fa36

Please sign in to comment.