mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 09:04:36 +00:00
token count includes ids
This commit is contained in:
parent
0ca814e544
commit
6570a2005b
5 changed files with 26 additions and 9 deletions
11
expose.cpp
11
expose.cpp
|
@ -194,7 +194,7 @@ extern "C"
|
|||
return gpttype_generate(inputs, output);
|
||||
}
|
||||
|
||||
const char* new_token(int idx) {
|
||||
const char * new_token(int idx) {
|
||||
if (generated_tokens.size() <= idx || idx < 0) return nullptr;
|
||||
|
||||
return generated_tokens[idx].c_str();
|
||||
|
@ -232,9 +232,14 @@ extern "C"
|
|||
return gpttype_generate_abort();
|
||||
}
|
||||
|
||||
int token_count(const char * input)
|
||||
static std::vector<int> toks; //just share a static object for token counting
|
||||
token_count_outputs token_count(const char * input)
|
||||
{
|
||||
std::string inputstr = input;
|
||||
return gpttype_token_count(inputstr);
|
||||
token_count_outputs output;
|
||||
toks = gpttype_get_token_arr(inputstr);
|
||||
output.count = toks.size();
|
||||
output.ids = toks.data(); //this may be slightly unsafe
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue