Skip to content
Merged
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
13 changes: 7 additions & 6 deletions xllm/api_service/chat_service_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ bool send_delta_to_client_brpc(
std::shared_ptr<StreamOutputParser> stream_parser = nullptr) {
auto& response = call->response();

if (output.outputs.size() > 0) {
if (stream_parser && output.outputs.size() > 0) {
stream_parser->check_resize_for_index(output.outputs.size() - 1);
}
// send delta to client
Expand All @@ -371,7 +371,7 @@ bool send_delta_to_client_brpc(

// Handle reasoning text
if (!cur_text.empty()) {
if (stream_parser->is_reasoning()) {
if (stream_parser && stream_parser->is_reasoning()) {
auto parser = stream_parser->get_reasoning_parser(index);
auto result = parser->parse_stream_chunk(cur_text);
if (result.normal_text.has_value()) {
Expand All @@ -392,7 +392,7 @@ bool send_delta_to_client_brpc(

if (!cur_text.empty()) {
// Handle tool call text
if (stream_parser->is_tool_call()) {
if (stream_parser && stream_parser->is_tool_call()) {
if (!process_tool_call_stream(call,
stream_parser,
index,
Expand Down Expand Up @@ -422,7 +422,7 @@ bool send_delta_to_client_brpc(
// Handle finish reason
if (seq_output.finish_reason.has_value()) {
// Check for unstreamed tool args before sending finish reason
if (stream_parser->get_has_tool_call(index)) {
if (stream_parser && stream_parser->get_has_tool_call(index)) {
if (!check_for_unstreamed_tool_args(
call, stream_parser, index, request_id, created_time, model)) {
return false;
Expand All @@ -438,7 +438,7 @@ bool send_delta_to_client_brpc(
choice->set_index(index);
choice->mutable_delta();

if (stream_parser->get_has_tool_call(index) &&
if (stream_parser && stream_parser->get_has_tool_call(index) &&
seq_output.finish_reason.value() == "stop") {
choice->set_finish_reason("tool_calls");
} else {
Expand Down Expand Up @@ -615,7 +615,8 @@ void ChatServiceImpl::process_async_impl(std::shared_ptr<ChatCall> call) {
request_params.chat_template_kwargs, reasoning_parser_format_);

std::shared_ptr<StreamOutputParser> stream_parser;
if (request_params.streaming) {
if (request_params.streaming && (!tool_call_parser_format_.empty() ||
!reasoning_parser_format_.empty())) {
stream_parser =
std::make_shared<StreamOutputParser>(request_params.tools,
tool_call_parser_format_,
Expand Down