Skip to content

Commit a995889

Browse files
authored
bugfix: resolve google.protobuf.Struct parsing failures which broke tool_call and think toggle functionality. (jd-opensource#359)
1 parent 1c25438 commit a995889

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

xllm/api_service/api_service.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ void ChatCompletionsImpl(std::unique_ptr<Service>& service,
135135
auto resp_pb =
136136
google::protobuf::Arena::CreateMessage<typename ChatCall::ResType>(arena);
137137

138+
std::string attachment = std::move(ctrl->request_attachment().to_string());
138139
std::string error;
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();
140+
141+
google::protobuf::util::JsonParseOptions options;
142+
options.ignore_unknown_fields = true;
143+
auto json_status =
144+
google::protobuf::util::JsonStringToMessage(attachment, req_pb, options);
145+
if (!json_status.ok()) {
146+
ctrl->SetFailed(json_status.ToString());
147+
LOG(ERROR) << "parse json to proto failed: " << json_status.ToString();
146148
return;
147149
}
148150

0 commit comments

Comments
 (0)