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

[tool] Fix tool calling output formatter #2721

Merged
merged 1 commit into from
Feb 5, 2025
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
11 changes: 5 additions & 6 deletions engines/python/setup/djl_python/output_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,8 @@ def _json_chat_output_formatter(request_output: TextGenerationOutput):
"finish_reason": best_sequence.finish_reason,
}
elif chat_params and chat_params.tools and (
parameters.get("tool_choice") == "auto"
or parameters.get("tool_choice")
is None) and parameters.get("tool_parser"):
chat_params.tool_choice == "auto"
or chat_params.tool_choice is None) and tool_parser:
tool_call_info = tool_parser.extract_tool_calls(generated_text,
request=chat_params)
auto_tools_called = tool_call_info.tools_called
Expand Down Expand Up @@ -408,9 +407,9 @@ def _jsonlines_chat_output_formatter(request_output: TextGenerationOutput):
}
}]
delta = {"tool_calls": tool_calls}
elif parameters.get("tools") and (parameters.get("tool_choice") == "auto"
or parameters.get("tool_choice") is None
) and parameters.get("tool_parser"):
elif chat_params and chat_params.tools and (
chat_params.tool_choice == "auto"
or chat_params.tool_choice is None) and tool_parser:
current_text = get_generated_text(best_sequence, request_output)
previous_text = current_text[0:-len(next_token.text)]
current_token_ids = [t.id for t in best_sequence.tokens]
Expand Down
Loading