Skip to content

Commit

Permalink
[BYOM] Support Azure-style Streamed Completions (#26635)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathansampson authored Nov 19, 2024
1 parent a633545 commit 1ffc6cc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions components/ai_chat/core/browser/engine/oai_api_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,20 @@ void OAIAPIClient::OnQueryDataReceived(

const base::Value::List* choices = result->GetDict().FindList("choices");

if (!choices) {
DVLOG(2) << "No choices list found in response.";
if (!choices || choices->empty()) {
VLOG(2) << "No choices list found in response, or it is empty.";
return;
}

if (choices->front().is_dict()) {
const base::Value::Dict* delta =
choices->front().GetDict().FindDict("delta");

if (!delta) {
VLOG(2) << "No delta info found in first completion choice.";
return;
}

const std::string* content = delta->FindString("content");

if (content) {
Expand Down

0 comments on commit 1ffc6cc

Please sign in to comment.