Skip to content

Commit

Permalink
moves page-content to own entry
Browse files Browse the repository at this point in the history
By moving the page_content to its own conversation entry, we prevent the chat history within Leo from being inundated with distilled content for BYOM users.
  • Loading branch information
jonathansampson committed Oct 3, 2024
1 parent 9727b80 commit 1ddc29d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions components/ai_chat/core/browser/engine/engine_consumer_oai.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,10 @@ base::Value::List BuildMessages(
: IDS_AI_CHAT_LLAMA2_ARTICLE_PROMPT_SEGMENT),
{page_content}, nullptr);

auto human_turn_iter = base::ranges::find_if(
conversation_history, [&](const mojom::ConversationTurnPtr& turn) {
return turn->character_type == CharacterType::HUMAN;
});

if (human_turn_iter != conversation_history.end()) {
human_turn_iter->get()->text =
base::StrCat({prompt_segment_article, human_turn_iter->get()->text});
}
base::Value::Dict message;
message.Set("role", "user");
message.Set("content", prompt_segment_article);
messages.Append(std::move(message));
}

for (const mojom::ConversationTurnPtr& turn : conversation_history) {
Expand Down

0 comments on commit 1ddc29d

Please sign in to comment.