Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Treat HTTP request completion as final response #748

Merged
merged 18 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/c++/perf_analyzer/client_backend/openai/openai_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ namespace openai {
void
ChatCompletionRequest::SendResponse(bool is_final, bool is_null)
{
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 @@ -172,7 +173,11 @@ ChatCompletionClient::AsyncInfer(
request->timer_.CaptureTimestamp(
triton::client::RequestTimers::Kind::REQUEST_END);
UpdateInferStat(request->timer_);
if (!request->is_stream_) {

// Send final response on request completion
// if it has not already been sent.
// (e.g. in the case of seeing [DONE] in streaming case)
if (!request->IsFinalResponseSent()) {
dyastremsky marked this conversation as resolved.
Show resolved Hide resolved
request->SendResponse(true /* is_final */, false /* is_null */);
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/c++/perf_analyzer/client_backend/openai/openai_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,14 @@ 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};
// The timers for infer request.
triton::client::RequestTimers timer_;
const std::string request_id_;
bool final_response_sent_{false};
};

class ChatCompletionClient : public HttpClient {
Expand Down
Loading