Skip to content

Commit

Permalink
Removed chat functionality as it is incomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
AsyaPronina committed Dec 24, 2024
1 parent c52bd12 commit bef8ca8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
26 changes: 3 additions & 23 deletions src/cpp/src/llm_pipeline_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,16 +745,7 @@ DecodedResults StatefulLLMPipeline::generate(
prompt = std::get<std::string>(inputs);
}

ov::genai::TokenizedInputs tokenized_input;
if (m_is_chat_conversation) {
m_history.push_back({{"role", "user"}, {"content", prompt}});
constexpr bool add_generation_prompt = true;
prompt = m_tokenizer.apply_chat_template(m_history, add_generation_prompt);
// for chat ov::genai::add_special_tokens(false) is aligned with stateful pipeline and HF
tokenized_input = m_tokenizer.encode(prompt, ov::genai::add_special_tokens(false));
} else {
tokenized_input = m_tokenizer.encode(prompt);
}
ov::genai::TokenizedInputs tokenized_input = m_tokenizer.encode(prompt);

auto encode_stop_time = std::chrono::steady_clock::now();
auto encoded_results = generate(tokenized_input, config, streamer);
Expand All @@ -763,11 +754,6 @@ DecodedResults StatefulLLMPipeline::generate(
DecodedResults decoded_results = {m_tokenizer.decode(encoded_results.tokens), encoded_results.scores};
auto decode_stop_time = std::chrono::steady_clock::now();

if (m_is_chat_conversation) {
auto answer = decoded_results.texts[0];
m_history.push_back({{"role", "assistant"}, {"content", answer}});
}

// generate_durations
decoded_results.perf_metrics = encoded_results.perf_metrics;
auto& raw_counters = decoded_results.perf_metrics.raw_metrics;
Expand Down Expand Up @@ -876,8 +862,6 @@ EncodedResults StatefulLLMPipeline::generate(
if (last_token == config.eos_token_id && !config.ignore_eos) {
break;
}

// TODO: How to check that KV-Cache is full?
}

if (streamer_ptr) {
Expand All @@ -895,15 +879,11 @@ EncodedResults StatefulLLMPipeline::generate(
}

void StatefulLLMPipeline::start_chat(const std::string& system_message) {
if (!system_message.empty()) {
m_history.push_back({{"role", "system"}, {"content", system_message}});
}
m_is_chat_conversation = true;
// FIXME: Implement later
};

void StatefulLLMPipeline::finish_chat() {
m_is_chat_conversation = false;
m_history.clear();
// FIXME: Implement later
};

StatelessLLMPipeline::StatelessLLMPipeline(
Expand Down
2 changes: 0 additions & 2 deletions src/cpp/src/llm_pipeline_static.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ class StatefulLLMPipeline : public LLMPipelineImplBase {

private:
ov::InferRequest m_request;
bool m_is_chat_conversation = false;
ChatHistory m_history;
};

class StatelessLLMPipeline final : public LLMPipelineImplBase {
Expand Down

0 comments on commit bef8ca8

Please sign in to comment.