@@ -325,7 +325,7 @@ inline bool chaton_tmpl_kv_bool(const std::string &tmpl, const std::string &key)
325
325
// a tagged message, types string and lens vector wrt the parts that make up the returned string
326
326
//
327
327
// * a string containing the tagged message
328
- // * user -(begin+prefix) + msg + user -(suffix+end)
328
+ // * role -(begin+prefix) + msg + role -(suffix+end)
329
329
// * a string where the chars contain info about
330
330
// type of sub-strings/parts that make up the tagged message.
331
331
// * a vector of ints, which give the length of each part in the tagged message.
@@ -357,7 +357,7 @@ inline bool chaton_tmpl_apply_single_ex(
357
357
// Given the template standard, role and a message, this returns the tagged message.
358
358
//
359
359
// * a string containing the tagged message
360
- // * user -(begin+prefix) + msg + user -(suffix+end)
360
+ // * role -(begin+prefix) + msg + role -(suffix+end)
361
361
inline size_t chaton_tmpl_apply_single (
362
362
const std::string &tmpl,
363
363
const std::string &role,
@@ -403,10 +403,19 @@ inline size_t chat_tmpl_apply_single_capi(
403
403
return taggedLength;
404
404
}
405
405
406
- // global-begin + [[role-begin] + [role-prefix] + msg + role-suffix] + global-end
407
- // if there is a combination of system-user messages,
408
- // then 1st user message will have user-prefix only if systemuser-1st-user-has-prefix is true
409
- // NOTE: returns types and lens to help identify the parts of the tagged msg, which relate to passed and added tags
406
+
407
+ // Given the template standard and a bunch of messages including their roles, this returns
408
+ // tagged messages, types string and lens vector. Returned types string and lens vector help
409
+ // identify the parts of the tagged msgs string, which relate to passed msgs and added tags.
410
+ //
411
+ // * a string containing the tagged messages
412
+ // * global-begin + 1 or more [[role-begin] + [role-prefix] + msg + [role-suffix] +[role-end]] + global-end
413
+ // * a string where the chars contain info about
414
+ // type of sub-strings/parts that make up the tagged messages string.
415
+ // * a vector of ints, which give the length of each part in the tagged messages string.
416
+ //
417
+ // if a combination of system-user messages is passed, then tags between the system
418
+ // and the 1st user message, is based on the flags set wrt the corresponding template standard.
410
419
inline bool chaton_tmpl_apply_ex (
411
420
const std::string &tmpl,
412
421
const std::vector<const llama_chat_message *> &msgs,
@@ -499,9 +508,9 @@ inline bool chaton_tmpl_apply_ex(
499
508
return true ;
500
509
}
501
510
502
- // global-begin + [[role-begin] + [role-prefix] + msg + role-suffix] + global-end
503
- // if there is a combination of system-user messages,
504
- // then 1st user message will have user -prefix only if systemuser-1st-user-has-prefix is true
511
+ // Given the template standard and a bunch of messages including their roles, this returns
512
+ // the tagged messages as a string.
513
+ // global-begin + 1 or more [[role-begin] + [role -prefix] + msg + [role-suffix] +[role-end]] + global-end
505
514
inline int32_t chaton_tmpl_apply (
506
515
const std::string &tmpl,
507
516
const std::vector<const llama_chat_message *> &msgs,
@@ -516,6 +525,18 @@ inline int32_t chaton_tmpl_apply(
516
525
return tagged.size ();
517
526
}
518
527
528
+ // Given the template standard and a bunch of messages including their roles, this returns
529
+ // the tagged messages as a string.
530
+ // global-begin + 1 or more [[role-begin] + [role-prefix] + msg + [role-suffix] +[role-end]] + global-end
531
+ //
532
+ // If the passed char array is smaller than that required for the tagged messages string,
533
+ // * part of the tagged messages string which fits within dest buffer is copied
534
+ // * the returned value, indicates the size of the actual tagged message
535
+ // NOTE:
536
+ // * ideally the passed char array should be able to fit the tagged messages string + 0|null char.
537
+ // * if the return value from this function is larger than or equal to destLength,
538
+ // then you will have to increase the size of the dest buffer, and call this
539
+ // function a second time, to ensure that one gets the full tagged messages string.
519
540
inline int32_t chaton_tmpl_apply_capi (
520
541
const char *tmpl,
521
542
const struct llama_chat_message *msgs,
0 commit comments