| 1690 | } |
| 1691 | |
| 1692 | static common_chat_params common_chat_params_init_without_tools(const common_chat_template & tmpl, const struct templates_params & inputs) { |
| 1693 | common_chat_params data; |
| 1694 | data.prompt = apply(tmpl, inputs.messages, inputs.tools.empty() ? json() : inputs.tools, inputs.add_generation_prompt); |
| 1695 | data.format = COMMON_CHAT_FORMAT_CONTENT_ONLY; |
| 1696 | data.grammar_lazy = false; |
| 1697 | if (!inputs.json_schema.is_null()) { |
| 1698 | if (!inputs.grammar.empty()) { |
| 1699 | throw std::runtime_error("Either \"json_schema\" or \"grammar\" can be specified, but not both"); |
| 1700 | } |
| 1701 | data.grammar = json_schema_to_grammar(inputs.json_schema); |
| 1702 | } else { |
| 1703 | data.grammar = inputs.grammar; |
| 1704 | } |
| 1705 | return data; |
| 1706 | } |
| 1707 | |
| 1708 | static common_chat_params common_chat_templates_apply_jinja( |
| 1709 | const struct common_chat_templates * tmpls, |
no test coverage detected