Skip to content

Commit

Permalink
fix: non-stream inference bugfix (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: sangjanai <[email protected]>
  • Loading branch information
vansangpfiev and sangjanai authored Jun 5, 2024
1 parent 9943d78 commit c90a3a9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/onnx_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void OnnxEngine::HandleChatCompletion(
}
formatted_output += ai_prompt_;

LOG_DEBUG << formatted_output;
// LOG_DEBUG << formatted_output;

try {
if (req.stream) {
Expand Down Expand Up @@ -259,18 +259,19 @@ void OnnxEngine::HandleChatCompletion(
params->SetSearchOption("max_length", req.max_tokens);
params->SetSearchOption("top_p", req.top_p);
params->SetSearchOption("temperature", req.temperature);
params->SetSearchOption("repetition_penalty", req.frequency_penalty);
// params->SetSearchOption("repetition_penalty", req.frequency_penalty);
params->SetInputSequences(*sequences);

auto output_sequences = oga_model_->Generate(*params);
const auto output_sequence_length = output_sequences->SequenceCount(0);
const auto* output_sequence_data = output_sequences->SequenceData(0);
const auto output_sequence_length =
output_sequences->SequenceCount(0) - sequences->SequenceCount(0);
const auto* output_sequence_data =
output_sequences->SequenceData(0) + sequences->SequenceCount(0);
auto out_string =
tokenizer_->Decode(output_sequence_data, output_sequence_length);

std::cout << "Output: " << std::endl << out_string << std::endl;
// std::cout << "Output: " << std::endl << out_string << std::endl;

// TODO(sang)
std::string to_send = out_string.p_;
auto resp_data = CreateFullReturnJson(GenerateRandomString(20), "_",
to_send, "_", 0, 0);
Expand Down

0 comments on commit c90a3a9

Please sign in to comment.