@@ -428,9 +428,7 @@ inline bool chaton_tmpl_apply_ex(
428
428
return false ;
429
429
}
430
430
ChatParts cp = {};
431
- std::stringstream ss;
432
431
std::string globalBegin = chaton_tmpl_role_kv (tmpl, K_GLOBAL, {K_BEGIN});
433
- ss << globalBegin;
434
432
cp.add_part (ChatParts::S, globalBegin);
435
433
int cntSystem = 0 ;
436
434
int cntUser = 0 ;
@@ -444,63 +442,47 @@ inline bool chaton_tmpl_apply_ex(
444
442
auto end = chaton_tmpl_role_kv (tmpl, role, {K_END});
445
443
if (role == K_SYSTEM) {
446
444
cntSystem += 1 ;
447
- ss << begin << prefix;
448
445
cp.add_part (ChatParts::S, begin);
449
446
cp.add_part (ChatParts::S, prefix);
450
447
} else if (role == K_USER) {
451
448
cntUser += 1 ;
452
449
if ((cntSystem == 1 ) && (cntUser == 1 )) {
453
450
if (conMeta[tmpl][K_SYSTEMUSER_1ST_USER_HAS_BEGIN]) {
454
- ss << begin;
455
451
cp.add_part (ChatParts::S, begin);
456
452
}
457
453
if (conMeta[tmpl][K_SYSTEMUSER_1ST_USER_HAS_PREFIX]) {
458
- ss << prefix;
459
454
cp.add_part (ChatParts::S, prefix);
460
455
}
461
456
} else {
462
- ss << begin << prefix;
463
457
cp.add_part (ChatParts::S, begin);
464
458
cp.add_part (ChatParts::S, prefix);
465
459
}
466
460
} else {
467
461
cntOthers += 1 ;
468
- ss << begin << prefix;
469
462
cp.add_part (ChatParts::S, begin);
470
463
cp.add_part (ChatParts::S, prefix);
471
464
}
472
- ss << content;
473
465
cp.add_part (ChatParts::N, content);
474
466
if (role == K_SYSTEM) {
475
467
if (chaton_tmpl_kv_bool (tmpl, K_SYSTEMUSER_SYSTEM_HAS_SUFFIX)) {
476
- ss << suffix;
477
468
cp.add_part (ChatParts::S, suffix);
478
469
}
479
470
if (chaton_tmpl_kv_bool (tmpl, K_SYSTEMUSER_SYSTEM_HAS_END)) {
480
- ss << end;
481
471
cp.add_part (ChatParts::S, end);
482
472
}
483
473
} else {
484
- ss << suffix << end;
485
474
cp.add_part (ChatParts::S, suffix);
486
475
cp.add_part (ChatParts::S, end);
487
476
}
488
477
}
489
478
if (alertAssistantAtEnd) {
490
479
auto assistantBeginPrefix = chaton_tmpl_role_kv (tmpl, K_ASSISTANT, {K_BEGIN, K_PREFIX});
491
- ss << assistantBeginPrefix;
492
480
cp.add_part (ChatParts::S, assistantBeginPrefix);
493
481
}
494
482
auto globalEnd = chaton_tmpl_role_kv (tmpl, K_GLOBAL, {K_END});
495
- ss << globalEnd;
496
483
cp.add_part (ChatParts::S, globalEnd);
497
484
cp.dump ();
498
- tagged = ss.str ();
499
- std::string cpStr = cp.str ();
500
- if (tagged != cpStr) {
501
- LOG_TEELN (" DBUG:%s:Mismatch between CP[%s] and SS[%s]" , __func__, cpStr.c_str (), tagged.c_str ());
502
- exit (2 );
503
- }
485
+ tagged = cp.str ();
504
486
LOGLN (" DBUG:%s:%s:%s" , __func__, tmpl.c_str (), tagged.c_str ());
505
487
LOGLN (" DBUG:%s:%s:CntSys[%d]:CntUsr[%d]:CntOthers[%d]" , __func__, tmpl.c_str (), cntSystem, cntUser, cntOthers);
506
488
types = cp.get_types ();
0 commit comments