Skip to content

Commit

Permalink
changing to be more explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
nnshah1 committed Jul 11, 2024
1 parent 20a3c07 commit 69480bd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/c++/perf_analyzer/client_backend/openai/openai_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,6 @@ namespace openai {
void
ChatCompletionRequest::SendResponse(bool is_final, bool is_null)
{
// if final response has already been sent
// due to detecting the [DONE]
// ignore final response due to request completion
if (final_response_sent_) {
return;
}

final_response_sent_ = is_final;
response_callback_(new ChatCompletionResult(
http_code_, std::move(response_buffer_), is_final, is_null, request_id_));
Expand Down Expand Up @@ -182,9 +175,11 @@ ChatCompletionClient::AsyncInfer(
UpdateInferStat(request->timer_);

// Send final response on request completion
// Ignored if final response has already been sent
// (in the case of seeing [DONE] in streaming case)
request->SendResponse(true /* is_final */, false /* is_null */);
// if it has not already been sent.
// (e.g. in the case of seeing [DONE] in streaming case)
if (!request->IsFinalResponseSent()) {
request->SendResponse(true /* is_final */, false /* is_null */);
}
};
std::unique_ptr<HttpRequest> request(new ChatCompletionRequest(
std::move(completion_callback), std::move(callback), request_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class ChatCompletionRequest : public HttpRequest {
request_id_(request_id)
{
}
bool IsFinalResponseSent() { return final_response_sent_; };
void SendResponse(bool is_final, bool is_null);
bool is_stream_{false};
std::function<void(InferResult*)> response_callback_{nullptr};
Expand Down

0 comments on commit 69480bd

Please sign in to comment.