import type { ChatCompletionChunk } from 'openai/resources/chat/completions' import type { CompletionUsage } from 'openai/resources/completions' import { checkForForcedToolUsageOpenAI, createOpenAICompatibleStream } from '@/providers/utils' /** * Creates a ReadableStream from a vLLM streaming response. * Uses the shared OpenAI-compatible streaming utility. */ export function createReadableStreamFromVLLMStream( vllmStream: AsyncIterable, onComplete?: (content: string, usage: CompletionUsage) => void ): ReadableStream { return createOpenAICompatibleStream(vllmStream, 'vLLM', onComplete) } /** * Checks if a forced tool was used in a vLLM response. * Uses the shared OpenAI-compatible forced tool usage helper. */ export function checkForForcedToolUsage( response: any, toolChoice: string | { type: string; function?: { name: string }; name?: string; any?: any }, forcedTools: string[], usedForcedTools: string[] ): { hasUsedForcedTool: boolean; usedForcedTools: string[] } { return checkForForcedToolUsageOpenAI(response, toolChoice, 'vLLM', forcedTools, usedForcedTools) }