Skip to content

Commit

Permalink
Handle errors in rust examples (#513)
Browse files Browse the repository at this point in the history
  • Loading branch information
EricLBuehler committed Jul 1, 2024
1 parent af18834 commit 21ed180
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mistralrs/examples/gemma2/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/gguf_locally/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/grammar/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/idefics2/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/isq/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/lora/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/lora_activation/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/phi3v/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/quantized/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/simple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down
8 changes: 8 additions & 0 deletions mistralrs/examples/xlora/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ fn main() -> anyhow::Result<()> {
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
Response::InternalError(e) => panic!("Internal error: {e}"),
Response::ValidationError(e) => panic!("Validation error: {e}"),
Response::ModelError(e, c) => panic!(
"Model error: {e}. Response: Text: {}, Prompt T/s: {}, Completion T/s: {}",
c.choices[0].message.content,
c.usage.avg_prompt_tok_per_sec,
c.usage.avg_compl_tok_per_sec
),
_ => unreachable!(),
}
Ok(())
Expand Down

0 comments on commit 21ed180

Please sign in to comment.