Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions extension/llm/tokenizer/tiktoken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,11 @@ Tiktoken::_split_with_allowed_special_token(
return std::make_pair(std::nullopt, input);
}

#if __cplusplus >= 202002L
auto start = input.begin();
#else
const char* start = input.data();
#endif
std::string special;
while (true) {
if (!re2::RE2::FindAndConsume(&input, *_special_token_regex, &special)) {
Expand All @@ -262,9 +266,15 @@ Tiktoken::_split_with_allowed_special_token(

if (allowed_special.count(special) == 1) {
// Found an allowed special token, split the text with it.
#if __cplusplus >= 202002L
return std::make_pair(
special,
re2::StringPiece(start, input.begin() - start - special.size()));
#else
return std::make_pair(
special,
re2::StringPiece(start, (input.data() - start) - special.size()));
#endif
} // else try to find the next special token
}

Expand Down
Loading