Forward decl minja::chat_template to avoid eager json dep

This commit is contained in:
ochafik 2025-01-18 10:37:56 +00:00
parent ee1e10e21e
commit e63520f37a
5 changed files with 40 additions and 21 deletions

View file

@ -3,7 +3,6 @@
#pragma once
#include "llama-cpp.h"
#include "chat-template.hpp"
#include <optional>
#include <string>
@ -601,8 +600,18 @@ struct common_chat_msg {
// Check if the template supplied via "--chat-template" is supported or not. Returns true if it's valid
bool common_chat_verify_template(const std::string & tmpl, bool use_jinja);
namespace minja {
class chat_template;
}
typedef minja::chat_template llama_chat_template;
struct llama_chat_templates {
bool has_explicit_template; // Model had builtin template or template overridde was specified.
std::unique_ptr<llama_chat_template> default_template; // always set (defaults to chatml)
std::unique_ptr<llama_chat_template> tool_use_template;
};
// CPP wrapper for llama_chat_apply_template
// If the built-in template is not supported, we default to chatml
// If the custom "tmpl" is not supported, we throw an error
@ -624,11 +633,6 @@ std::string common_chat_format_single(
std::string common_chat_format_example(
const llama_chat_template & tmpl, bool use_jinja);
struct llama_chat_templates {
llama_chat_template default_template;
std::optional<llama_chat_template> tool_use_template;
};
llama_chat_templates llama_chat_templates_from_model(const struct llama_model * model, const std::string & chat_template_override);
//