Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn instead of throw error in chat template #498

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions mistralrs-core/src/pipeline/chat_template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ use std::collections::HashMap;
use anyhow::Result;
use either::Either;
use indexmap::IndexMap;
use minijinja::{context, Environment, ErrorKind};
use minijinja::{context, Environment};
use serde::{Deserialize, Serialize};
use tokenizers::Tokenizer;
use tracing::info;
use tracing::{info, warn};

use crate::MessageContent;

Expand All @@ -28,8 +28,11 @@ pub struct AddedTokensDecoder {
special: Option<bool>,
}

fn raise_exception(msg: String) -> Result<String, minijinja::Error> {
Err(minijinja::Error::new(ErrorKind::InvalidOperation, msg))
fn raise_exception(msg: String) -> Result<(), minijinja::Error> {
// We used to throw an error, now just warn.
// Err(minijinja::Error::new(ErrorKind::InvalidOperation, msg))
warn!("Chat template error: `{msg}`. Please ensure that the messages are correctly formatted.");
Ok(())
}

#[derive(Debug, Deserialize)]
Expand Down
Loading