mirror of
https://github.com/ikawrakow/ik_llama.cpp.git
synced 2026-01-26 17:20:01 +00:00
* Tool calls support from mainline * update cmake * revert api for /completions * Fix broken thinking process for gpt-oss * add missing args and fix webui bugs * add missing args and fix webui bugs2 * Fix reasoning format error * add usage * change default post_sampling_probs to true * add back generated_text * Remove server endpoints tests * add log * Chat fixes * Remove logs * webui: revert extra handling of thinking process --------- Co-authored-by: firecoperana <firecoperana> Co-authored-by: Iwan Kawrakow <iwan.kawrakow@gmail.com>
31 lines
896 B
C++
31 lines
896 B
C++
// Implements a parser for an extended Backus-Naur form (BNF), producing the
|
|
// binary context-free grammar format specified by llama.h. Supports character
|
|
// ranges, grouping, and repetition operators. As an example, a grammar for
|
|
// arithmetic might look like:
|
|
//
|
|
// root ::= expr
|
|
// expr ::= term ([-+*/] term)*
|
|
// term ::= num | "(" space expr ")" space
|
|
// num ::= [0-9]+ space
|
|
// space ::= [ \t\n]*
|
|
|
|
#pragma once
|
|
#include "llama.h"
|
|
#include <vector>
|
|
#include <map>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
namespace grammar_parser {
|
|
struct parse_state {
|
|
std::map<std::string, uint32_t> symbol_ids;
|
|
std::vector<std::vector<llama_grammar_element>> rules;
|
|
|
|
std::vector<const llama_grammar_element *> c_rules();
|
|
bool success;
|
|
};
|
|
|
|
parse_state parse(const char * src);
|
|
void print_grammar(FILE * file, const parse_state & state);
|
|
}
|