diff --git a/common/chat-parser.cpp b/common/chat-parser.cpp index fe3e80037f4..d3f763756db 100644 --- a/common/chat-parser.cpp +++ b/common/chat-parser.cpp @@ -1399,7 +1399,7 @@ static void common_chat_parse_content_only(common_chat_msg_parser & builder) { builder.add_content(builder.consume_rest()); } -static void common_chat_parse(common_chat_msg_parser & builder) { +static void common_chat_msg_parse(common_chat_msg_parser & builder) { LOG_DBG("Parsing input with format %s: %s\n", common_chat_format_name(builder.syntax().format), builder.input().c_str()); switch (builder.syntax().format) { @@ -1492,7 +1492,7 @@ common_chat_msg common_chat_parse(const std::string & input, bool is_partial, co } common_chat_msg_parser builder(input, is_partial, syntax); try { - common_chat_parse(builder); + common_chat_msg_parse(builder); } catch (const common_chat_msg_partial_exception & ex) { LOG_DBG("Partial parse: %s\n", ex.what()); if (!is_partial) { diff --git a/common/chat-parser.h b/common/chat-parser.h index 78c4b74c2db..d35533b1604 100644 --- a/common/chat-parser.h +++ b/common/chat-parser.h @@ -1,6 +1,7 @@ #pragma once #include "chat.h" +#include "peg-parser.h" #include "chat-parser-xml-toolcall.h" #include "json-partial.h" #include "regex-partial.h" @@ -131,3 +132,7 @@ class common_chat_msg_parser { void clear_tools(); }; + +common_chat_msg common_chat_parse(const std::string & input, bool is_partial, const common_chat_syntax & syntax); +common_chat_msg common_chat_peg_parse(const common_peg_arena & parser, const std::string & input, bool is_partial, const common_chat_syntax & syntax); + diff --git a/common/chat.h b/common/chat.h index 6085510a402..7729885961d 100644 --- a/common/chat.h +++ b/common/chat.h @@ -213,8 +213,6 @@ std::string common_chat_format_example( const char* common_chat_format_name(common_chat_format format); const char* common_reasoning_format_name(common_reasoning_format format); common_reasoning_format common_reasoning_format_from_name(const std::string & format); -common_chat_msg common_chat_parse(const std::string & input, bool is_partial, const common_chat_syntax & syntax); -common_chat_msg common_chat_peg_parse(const common_peg_arena & parser, const std::string & input, bool is_partial, const common_chat_syntax & syntax); common_chat_tool_choice common_chat_tool_choice_parse_oaicompat(const std::string & tool_choice); diff --git a/tests/test-chat.cpp b/tests/test-chat.cpp index 62dd1583fa1..10fff792498 100644 --- a/tests/test-chat.cpp +++ b/tests/test-chat.cpp @@ -6,6 +6,7 @@ // cmake -B build && cmake --build build --parallel && ./build/bin/test-chat ../minja/build/tests/*.jinja 2>/dev/null // #include "chat.h" +#include "chat-parser.h" #include "log.h" diff --git a/tools/server/server-task.cpp b/tools/server/server-task.cpp index df066264778..e7b3cf8d51b 100644 --- a/tools/server/server-task.cpp +++ b/tools/server/server-task.cpp @@ -4,6 +4,7 @@ #include "common.h" #include "llama.h" #include "chat.h" +#include "chat-parser.h" #include "sampling.h" #include "json-schema-to-grammar.h"