mirror of
https://github.com/LostRuins/koboldcpp.git
synced 2025-09-10 09:04:36 +00:00
back to http.server, improved implementation
This commit is contained in:
parent
4f665cd63d
commit
e6231c3055
4 changed files with 196 additions and 150 deletions
35
expose.cpp
35
expose.cpp
|
@ -24,9 +24,8 @@ std::string executable_path = "";
|
|||
std::string lora_filename = "";
|
||||
|
||||
|
||||
static std::string current_token = "";
|
||||
static bool new_token_available = false;
|
||||
static bool finished_stream = false;
|
||||
bool generation_finished;
|
||||
std::vector<std::string> generated_tokens;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
@ -213,35 +212,17 @@ extern "C"
|
|||
return gpttype_generate(inputs, output);
|
||||
}
|
||||
|
||||
const char* new_token(int idx) {
|
||||
if (generated_tokens.size() <= idx || idx < 0) return nullptr;
|
||||
|
||||
const char* new_token() {
|
||||
if (new_token_available) {
|
||||
new_token_available = false;
|
||||
return current_token.c_str();
|
||||
}
|
||||
return nullptr;
|
||||
return generated_tokens[idx].c_str();
|
||||
}
|
||||
|
||||
bool is_locked() {
|
||||
return !new_token_available;
|
||||
int get_stream_count() {
|
||||
return generated_tokens.size();
|
||||
}
|
||||
|
||||
bool has_finished() {
|
||||
return finished_stream;
|
||||
}
|
||||
|
||||
|
||||
// TODO: dont duplicate code
|
||||
void bind_set_stream_finished(bool status) {
|
||||
finished_stream = status;
|
||||
return generation_finished;
|
||||
}
|
||||
}
|
||||
|
||||
void receive_current_token(std::string token) {
|
||||
current_token = token;
|
||||
new_token_available = true;
|
||||
}
|
||||
|
||||
void set_stream_finished(bool status) {
|
||||
finished_stream = status;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue