char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
9e40df63b
char/aliceai-t5-moe
1#pragma once 2 3#include <optional> 4#include <string> 5#include <vector> 6 7#include "utils.h" 8 9namespace jinja { 10 11// allow differentiate between user input strings and template strings 12// transformations should handle this information as follows: 13// - one-to-one (e.g., uppercase, lowercase): preserve is_input flag 14// - one-to-many (e.g., strip): if input string is marked as is_input, all resulting parts should be marked as is_input 15// - many-to-one (e.g., concat): if ALL input parts are marked as is_input, resulting part should be marked as is_input 16struct string_part { 17bool is_input = false;// may skip parsing special tokens if true 18std ::string val ; 19 20bool is_uppercase ()const ; 21bool is_lowercase ()const ; 22}; 23 24struct string { 25std ::vector < string_part > parts ; 26string ()= default ; 27string (const std ::string & v ,bool user_input = false) { 28parts .push_back ({user_input ,v }); 29 } 30string (int v ) { 31parts .push_back ({false,std ::to_string (v )}); 32 } 33string (double v ) { 34parts .push_back ({false,std ::to_string (v )}); 35 } 36 37// mark all parts as user input 38void mark_input (); 39 40std ::string str ()const ; 41size_t length ()const ; 42void hash_update (hasher & hash )const noexcept ; 43bool all_parts_are_input ()const ; 44bool is_uppercase ()const ; 45bool is_lowercase ()const ; 46 47// mark this string as input if other has ALL parts as input 48void mark_input_based_on (const string & other ); 49 50string & append (const string & other ); 51 52// in-place transformations 53 54string uppercase (); 55string lowercase (); 56string capitalize (); 57string titlecase (); 58string strip (bool left ,bool right ,std ::optional < const std ::string_view > chars = std ::nullopt ); 59}; 60 61}// namespace jinja