File tree Expand file tree Collapse file tree 4 files changed +37
-6
lines changed Expand file tree Collapse file tree 4 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -70,6 +70,8 @@ add_library(${TARGET} STATIC
70
70
sampling.h
71
71
speculative.cpp
72
72
speculative.h
73
+ parsers/harmony.cpp
74
+ parsers/harmony.h
73
75
)
74
76
75
77
if (BUILD_SHARED_LIBS )
Original file line number Diff line number Diff line change 5
5
#include " json-schema-to-grammar.h"
6
6
#include " log.h"
7
7
#include " regex-partial.h"
8
+ #include " parsers/harmony.h"
8
9
9
10
#include < minja/chat-template.hpp>
10
11
#include < minja/minja.hpp>
@@ -1319,12 +1320,8 @@ static common_chat_params common_chat_params_init_gpt_oss(const common_chat_temp
1319
1320
return data;
1320
1321
}
1321
1322
static void common_chat_parse_gpt_oss (common_chat_msg_parser & builder) {
1322
- // TODO @ngxson : this won't work with --special enabled, we should fix that
1323
- builder.try_parse_reasoning (" <|channel|>analysis<|message|>" , " <|start|>assistant<|channel|>final<|message|>" );
1324
- if (!builder.syntax ().parse_tool_calls ) {
1325
- builder.add_content (builder.consume_rest ());
1326
- return ;
1327
- }
1323
+ harmony_msg_parser parser (builder);
1324
+ parser.parse ();
1328
1325
}
1329
1326
1330
1327
static common_chat_params common_chat_params_init_firefunction_v2 (const common_chat_template & tmpl, const struct templates_params & inputs) {
Original file line number Diff line number Diff line change
1
+ #include " harmony.h"
2
+
3
+ harmony_msg_parser::harmony_msg_parser (common_chat_msg_parser & builder)
4
+ : builder(builder)
5
+ {
6
+ // TODO
7
+ }
8
+
9
+ void harmony_msg_parser::parse () {
10
+ // TODO @ngxson : this won't work with --special enabled, we should fix that
11
+ builder.try_parse_reasoning (" <|channel|>analysis<|message|>" , " <|start|>assistant<|channel|>final<|message|>" );
12
+ if (!builder.syntax ().parse_tool_calls ) {
13
+ builder.add_content (builder.consume_rest ());
14
+ return ;
15
+ }
16
+ }
Original file line number Diff line number Diff line change
1
+ #pragma once
2
+
3
+ #include " chat-parser.h"
4
+
5
+ #include < optional>
6
+ #include < string>
7
+ #include < vector>
8
+
9
+ class harmony_msg_parser {
10
+ common_chat_msg_parser & builder;
11
+
12
+ public:
13
+ harmony_msg_parser (common_chat_msg_parser & builder);
14
+
15
+ void parse ();
16
+ };
You can’t perform that action at this time.
0 commit comments