Skip to content

Commit f557570

Browse files
committed
fix anthropic compatible api toolcall finish reason
1 parent 0940a07 commit f557570

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/BE/Services/Models/Dtos/AnthropicSegmentExtensions.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ public static class AnthropicSegmentExtensions
88
{
99
/// <summary>
1010
/// Converts DBFinishReason to Anthropic stop_reason
11+
/// Anthropic supports: end_turn, max_tokens, stop_sequence, tool_use, pause_turn, refusal
1112
/// </summary>
1213
public static string? ToAnthropicStopReason(this DBFinishReason finishReason)
1314
{
1415
return finishReason switch
1516
{
1617
DBFinishReason.Stop or DBFinishReason.Success => "end_turn",
1718
DBFinishReason.Length => "max_tokens",
18-
DBFinishReason.ToolCalls => "tool_use",
19-
DBFinishReason.ContentFilter => "end_turn", // Anthropic doesn't have content_filter
19+
DBFinishReason.ToolCalls or DBFinishReason.FunctionCall => "tool_use",
20+
DBFinishReason.ContentFilter => "refusal",
2021
_ => "end_turn"
2122
};
2223
}

0 commit comments

Comments
 (0)