Skip to content

Commit afb6cac

Browse files
committed
use '%llguidance' as marker to enable llg lark syntax
1 parent f4dc4b8 commit afb6cac

File tree

3 files changed

+4
-10
lines changed

3 files changed

+4
-10
lines changed

common/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ if (LLAMA_LLGUIDANCE)
9696
set(LLGUIDANCE_PATH ${LLGUIDANCE_SRC}/target/release)
9797
ExternalProject_Add(llguidance_ext
9898
GIT_REPOSITORY https://github.com/guidance-ai/llguidance
99-
GIT_TAG 0cbe6b3a6ee72e5726c76f13fe67e21a5895f679
99+
GIT_TAG d7b382916c466e6f26869671b8480229dc930423
100100
PREFIX ${CMAKE_BINARY_DIR}/llguidance
101101
SOURCE_DIR ${LLGUIDANCE_SRC}
102102
BUILD_IN_SOURCE TRUE

common/json-schema-to-grammar.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ class SchemaConverter {
992992

993993
std::string json_schema_to_grammar(const json & schema) {
994994
#ifdef LLAMA_USE_LLGUIDANCE
995-
return "llg:json:" + schema.dump();
995+
return "%llguidance {}\nstart: %json " + schema.dump();
996996
#else
997997
return build_grammar([&](const llama_grammar_builder & callbacks) {
998998
auto copy = schema;

common/sampling.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,9 @@ struct common_sampler * common_sampler_init(const struct llama_model * model, co
152152
lparams.no_perf = params.no_perf;
153153

154154
struct llama_sampler * grmr;
155-
if (params.grammar.compare(0, 4, "llg:") == 0) {
155+
if (params.grammar.compare(0, 11, "%llguidance") == 0) {
156156
#ifdef LLAMA_USE_LLGUIDANCE
157-
auto gp = params.grammar.find(':', 4);
158-
if (gp == std::string::npos) {
159-
GGML_ABORT("invalid serialized grammar");
160-
}
161-
auto grm_type = params.grammar.substr(4, gp - 4);
162-
auto grm_data = params.grammar.c_str() + gp + 1;
163-
grmr = llama_sampler_init_llg(model, grm_type.c_str(), grm_data);
157+
grmr = llama_sampler_init_llg(model, "lark", params.grammar.c_str());
164158
#else
165159
GGML_ABORT("llguidance (cmake -DLLAMA_LLGUIDANCE=ON) is not enabled");
166160
#endif

0 commit comments

Comments
 (0)