imseldrith's picture
Initial upload from Colab
9e27976 verified
raw
history blame contribute delete
459 Bytes
import { type AnthropicResponse } from "./anthropic-types"
export function mapOpenAIStopReasonToAnthropic(
finishReason: "stop" | "length" | "tool_calls" | "content_filter" | null,
): AnthropicResponse["stop_reason"] {
if (finishReason === null) {
return null
}
const stopReasonMap = {
stop: "end_turn",
length: "max_tokens",
tool_calls: "tool_use",
content_filter: "end_turn",
} as const
return stopReasonMap[finishReason]
}