@@ -51,9 +51,15 @@ APIService::APIService(Master* master,
5151 embedding_service_impl_ =
5252 ServiceImplFactory<EmbeddingServiceImpl>::create_service_impl (
5353 llm_master, model_names);
54- rerank_service_impl_ =
55- ServiceImplFactory<RerankServiceImpl>::create_service_impl (llm_master,
56- model_names);
54+ if (FLAGS_enable_qwen3_reranker) {
55+ rerank_service_impl_ =
56+ ServiceImplFactory<Qwen3RerankServiceImpl>::create_service_impl (
57+ llm_master, model_names);
58+ } else {
59+ rerank_service_impl_ =
60+ ServiceImplFactory<RerankServiceImpl>::create_service_impl (
61+ llm_master, model_names);
62+ }
5763 } else if (FLAGS_backend == " vlm" ) {
5864 auto vlm_master = dynamic_cast <VLMMaster*>(master);
5965 mm_chat_service_impl_ =
@@ -95,9 +101,11 @@ void APIService::CompletionsHttp(::google::protobuf::RpcController* controller,
95101 google::protobuf::Arena::CreateMessage<proto::CompletionResponse>(arena);
96102
97103 auto ctrl = reinterpret_cast <brpc::Controller*>(controller);
98- std::string attachment = std::move (ctrl->request_attachment ().to_string ());
99104 std::string error;
100- auto st = json2pb::JsonToProtoMessage (attachment, req_pb, &error);
105+ json2pb::Json2PbOptions options;
106+ butil::IOBuf& buf = ctrl->request_attachment ();
107+ butil::IOBufAsZeroCopyInputStream iobuf_stream (buf);
108+ auto st = json2pb::JsonToProtoMessage (&iobuf_stream, req_pb, options, &error);
101109 if (!st) {
102110 ctrl->SetFailed (error);
103111 LOG (ERROR) << " parse json to proto failed: " << error;
@@ -127,16 +135,14 @@ void ChatCompletionsImpl(std::unique_ptr<Service>& service,
127135 auto resp_pb =
128136 google::protobuf::Arena::CreateMessage<typename ChatCall::ResType>(arena);
129137
130- std::string attachment = std::move (ctrl->request_attachment ().to_string ());
131138 std::string error;
132-
133- google::protobuf::util::JsonParseOptions options;
134- options.ignore_unknown_fields = true ;
135- auto json_status =
136- google::protobuf::util::JsonStringToMessage (attachment, req_pb, options);
137- if (!json_status.ok ()) {
138- ctrl->SetFailed (json_status.ToString ());
139- LOG (ERROR) << " parse json to proto failed: " << json_status.ToString ();
139+ json2pb::Json2PbOptions options;
140+ butil::IOBuf& buf = ctrl->request_attachment ();
141+ butil::IOBufAsZeroCopyInputStream iobuf_stream (buf);
142+ auto st = json2pb::JsonToProtoMessage (&iobuf_stream, req_pb, options, &error);
143+ if (!st) {
144+ ctrl->SetFailed (error);
145+ LOG (ERROR) << " parse json to proto failed: " << buf.to_string ();
140146 return ;
141147 }
142148
@@ -201,9 +207,11 @@ void APIService::EmbeddingsHttp(::google::protobuf::RpcController* controller,
201207 google::protobuf::Arena::CreateMessage<proto::EmbeddingResponse>(arena);
202208
203209 auto ctrl = reinterpret_cast <brpc::Controller*>(controller);
204- std::string attachment = std::move (ctrl->request_attachment ().to_string ());
205210 std::string error;
206- auto st = json2pb::JsonToProtoMessage (attachment, req_pb, &error);
211+ json2pb::Json2PbOptions options;
212+ butil::IOBuf& buf = ctrl->request_attachment ();
213+ butil::IOBufAsZeroCopyInputStream iobuf_stream (buf);
214+ auto st = json2pb::JsonToProtoMessage (&iobuf_stream, req_pb, options, &error);
207215 if (!st) {
208216 ctrl->SetFailed (error);
209217 LOG (ERROR) << " parse json to proto failed: " << error;
@@ -248,10 +256,13 @@ void APIService::ImageGenerationHttp(
248256 auto resp_pb =
249257 google::protobuf::Arena::CreateMessage<proto::ImageGenerationResponse>(
250258 arena);
259+
251260 auto ctrl = reinterpret_cast <brpc::Controller*>(controller);
252- std::string attachment = std::move (ctrl->request_attachment ().to_string ());
253261 std::string error;
254- auto st = json2pb::JsonToProtoMessage (attachment, req_pb, &error);
262+ json2pb::Json2PbOptions options;
263+ butil::IOBuf& buf = ctrl->request_attachment ();
264+ butil::IOBufAsZeroCopyInputStream iobuf_stream (buf);
265+ auto st = json2pb::JsonToProtoMessage (&iobuf_stream, req_pb, options, &error);
255266 if (!st) {
256267 ctrl->SetFailed (error);
257268 LOG (ERROR) << " parse json to proto failed: " << error;
@@ -290,9 +301,11 @@ void APIService::RerankHttp(::google::protobuf::RpcController* controller,
290301 google::protobuf::Arena::CreateMessage<proto::RerankResponse>(arena);
291302
292303 auto ctrl = reinterpret_cast <brpc::Controller*>(controller);
293- std::string attachment = std::move (ctrl->request_attachment ().to_string ());
294304 std::string error;
295- auto st = json2pb::JsonToProtoMessage (attachment, req_pb, &error);
305+ json2pb::Json2PbOptions options;
306+ butil::IOBuf& buf = ctrl->request_attachment ();
307+ butil::IOBufAsZeroCopyInputStream iobuf_stream (buf);
308+ auto st = json2pb::JsonToProtoMessage (&iobuf_stream, req_pb, options, &error);
296309 if (!st) {
297310 ctrl->SetFailed (error);
298311 LOG (ERROR) << " parse json to proto failed: " << error;
@@ -398,9 +411,11 @@ void APIService::LinkCluster(::google::protobuf::RpcController* controller,
398411 google::protobuf::Arena::CreateMessage<proto::RpcStatus>(arena);
399412
400413 auto ctrl = reinterpret_cast <brpc::Controller*>(controller);
401- std::string attachment = std::move (ctrl->request_attachment ().to_string ());
402414 std::string error;
403- auto st = json2pb::JsonToProtoMessage (attachment, req_pb, &error);
415+ json2pb::Json2PbOptions options;
416+ butil::IOBuf& buf = ctrl->request_attachment ();
417+ butil::IOBufAsZeroCopyInputStream iobuf_stream (buf);
418+ auto st = json2pb::JsonToProtoMessage (&iobuf_stream, req_pb, options, &error);
404419 if (!st) {
405420 ctrl->SetFailed (error);
406421 LOG (ERROR) << " parse json to proto failed: " << error;
@@ -452,9 +467,11 @@ void APIService::UnlinkCluster(::google::protobuf::RpcController* controller,
452467 google::protobuf::Arena::CreateMessage<proto::RpcStatus>(arena);
453468
454469 auto ctrl = reinterpret_cast <brpc::Controller*>(controller);
455- std::string attachment = std::move (ctrl->request_attachment ().to_string ());
456470 std::string error;
457- auto st = json2pb::JsonToProtoMessage (attachment, req_pb, &error);
471+ json2pb::Json2PbOptions options;
472+ butil::IOBuf& buf = ctrl->request_attachment ();
473+ butil::IOBufAsZeroCopyInputStream iobuf_stream (buf);
474+ auto st = json2pb::JsonToProtoMessage (&iobuf_stream, req_pb, options, &error);
458475 if (!st) {
459476 ctrl->SetFailed (error);
460477 LOG (ERROR) << " parse json to proto failed: " << error;
0 commit comments