diff --git a/litellm/llms/openai/chat/gpt_transformation.py b/litellm/llms/openai/chat/gpt_transformation.py index 04a10bd7fbe..6cc09dafc2f 100644 --- a/litellm/llms/openai/chat/gpt_transformation.py +++ b/litellm/llms/openai/chat/gpt_transformation.py @@ -25,6 +25,7 @@ from litellm.litellm_core_utils.llm_response_utils.convert_dict_to_response impo _handle_invalid_parallel_tool_calls, _should_convert_tool_call_to_json_mode, ) +from litellm.litellm_core_utils.core_helpers import map_finish_reason from litellm.litellm_core_utils.prompt_templates.common_utils import get_tool_call_names from litellm.litellm_core_utils.prompt_templates.image_handling import ( async_convert_url_to_base64, @@ -586,8 +587,10 @@ class OpenAIGPTConfig(BaseLLMModelInfo, BaseConfig): enhancements=None, ) - translated_choice.finish_reason = self._get_finish_reason( - translated_message, choice["finish_reason"] + translated_choice.finish_reason = map_finish_reason( + self._get_finish_reason( + translated_message, choice["finish_reason"] + ) ) transformed_choices.append(translated_choice) diff --git a/ui/litellm-dashboard/src/components/CostTrackingSettings/pricing_calculator/multi_cost_results.tsx b/ui/litellm-dashboard/src/components/CostTrackingSettings/pricing_calculator/multi_cost_results.tsx index 624c297f266..db8c065d18a 100644 --- a/ui/litellm-dashboard/src/components/CostTrackingSettings/pricing_calculator/multi_cost_results.tsx +++ b/ui/litellm-dashboard/src/components/CostTrackingSettings/pricing_calculator/multi_cost_results.tsx @@ -181,7 +181,7 @@ const MultiCostResults: React.FC = ({ multiResult, timePe title: "Model", dataIndex: "model", key: "model", - render: (text: string, record: { id: string; provider?: string | null; error?: string | null; loading?: boolean; hasZeroCost?: boolean }) => ( + render: (text: string, record: { id: string; provider?: string | null; error?: string | null; loading?: boolean; hasZeroCost?: boolean | null }) => (
{text} diff --git a/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.tsx b/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.tsx index 17cddc3ab16..efcf7504b28 100644 --- a/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.tsx +++ b/ui/litellm-dashboard/src/components/playground/llm_calls/chat_completion.tsx @@ -33,7 +33,7 @@ export async function makeOpenAIChatCompletionRequest( // base url should be the current base_url const isLocal = process.env.NODE_ENV === "development"; if (isLocal !== true) { - console.log = function () {}; + console.log = function () { }; } console.log("isLocal:", isLocal); const proxyBaseUrl = customBaseUrl || getProxyBaseUrl(); @@ -58,7 +58,7 @@ export async function makeOpenAIChatCompletionRequest( // For collecting complete response text let fullResponseContent = ""; let fullReasoningContent = ""; - + // Track MCP metadata from final chunk let mcpMetadata: { mcp_list_tools?: any[]; @@ -224,15 +224,15 @@ export async function makeOpenAIChatCompletionRequest( } // Convert mcp_tool_calls and mcp_call_results to MCPEvent[] - if (mcpMetadata.mcp_tool_calls && mcpMetadata.mcp_tool_calls.length > 0) { - mcpMetadata.mcp_tool_calls.forEach((toolCall: any, index: number) => { + if (mcpMetadata?.mcp_tool_calls && mcpMetadata?.mcp_tool_calls.length > 0) { + mcpMetadata?.mcp_tool_calls.forEach((toolCall: any, index: number) => { const functionName = toolCall.function?.name || toolCall.name || ""; const functionArgs = toolCall.function?.arguments || toolCall.arguments || "{}"; - + // Find corresponding result - const result = mcpMetadata.mcp_call_results?.find( + const result = mcpMetadata?.mcp_call_results?.find( (r: any) => r.tool_call_id === toolCall.id || r.tool_call_id === toolCall.call_id - ) || mcpMetadata.mcp_call_results?.[index]; + ) || mcpMetadata?.mcp_call_results?.[index]; const callEvent: MCPEvent = { type: "response.output_item.done",