Skip to content

Commit da8d5bd

Browse files
authored
feat: binary mm input compatible with stream mode. (#615)
1 parent d616d77 commit da8d5bd

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

xllm/api_service/call.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ void Call::init() {
3535
x_request_time_ =
3636
*controller_->http_request().GetHeader("x-request-timems");
3737
}
38-
}
3938

40-
bool Call::get_binary_payload(std::string& payload) {
41-
payload.clear();
39+
init_request_payload();
40+
}
4241

42+
void Call::init_request_payload() {
4343
const auto infer_content_len =
4444
controller_->http_request().GetHeader(kInferContentLength);
4545
const auto content_len =
4646
controller_->http_request().GetHeader(kContentLength);
4747

48-
if (infer_content_len == nullptr || content_len == nullptr) return false;
48+
if (infer_content_len == nullptr || content_len == nullptr) return;
4949

5050
auto infer_len = std::stoul(*infer_content_len);
5151
auto len = std::stoul(*content_len);
@@ -54,12 +54,11 @@ bool Call::get_binary_payload(std::string& payload) {
5454
LOG(ERROR) << " content length is invalid:"
5555
<< " infer content len is " << infer_len
5656
<< " , content length is " << len;
57-
return false;
57+
return;
5858
}
5959

6060
controller_->request_attachment().copy_to(
61-
&payload, len - infer_len, infer_len);
62-
return true;
61+
&request_payload_, len - infer_len, infer_len);
6362
}
6463

6564
} // namespace xllm

xllm/api_service/call.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class Call {
2929
std::string get_x_request_id() { return x_request_id_; }
3030
std::string get_x_request_time() { return x_request_time_; }
3131

32-
bool get_binary_payload(std::string& payload);
32+
std::string& get_request_payload() { return request_payload_; }
33+
void init_request_payload();
3334

3435
virtual bool is_disconnected() const = 0;
3536

@@ -41,6 +42,8 @@ class Call {
4142

4243
std::string x_request_id_;
4344
std::string x_request_time_;
45+
46+
std::string request_payload_;
4447
};
4548

4649
} // namespace xllm

xllm/api_service/chat_service_impl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,7 @@ void MMChatServiceImpl::process_async_impl(std::shared_ptr<MMChatCall> call) {
751751
auto saved_streaming = request_params.streaming;
752752
auto saved_request_id = request_params.request_id;
753753

754-
std::string payload;
755-
call->get_binary_payload(payload);
754+
auto& payload = call->get_request_payload();
756755

757756
// schedule the request
758757
master_->handle_request(

xllm/api_service/embedding_service_impl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,7 @@ void MMEmbeddingServiceImpl::process_async_impl(
163163
}
164164
auto request_id = request_params.request_id;
165165

166-
std::string payload;
167-
call->get_binary_payload(payload);
166+
auto& payload = call->get_request_payload();
168167

169168
// schedule the request
170169
master_->handle_request(

0 commit comments

Comments
 (0)