--- /tmp/evalscope-sync/src-v191/evalscope/models/utils/openai.py 2026-07-21 03:18:18.000000000 +0000 +++ /data1/syy/evalscope/evalstone/evalscope/evalscope/models/utils/openai.py 2026-08-21 03:03:19.641323740 +0000 @@ -256,6 +256,8 @@ params['timeout'] = config.timeout if config.max_tokens is not None: params['max_tokens'] = config.max_tokens + if config.max_completion_tokens is not None: + params['max_completion_tokens'] = config.max_completion_tokens if config.frequency_penalty is not None: params['frequency_penalty'] = config.frequency_penalty if config.stop_seqs is not None: @@ -822,6 +824,8 @@ continue collected_chunks.append(chunk) for choice in chunk.choices: + # Some proxies (e.g. Vectron) omit choice.index; default to 0. + choice_index = choice.index if choice.index is not None else 0 reasoning_content = getattr(choice.delta, 'reasoning_content', None) if reasoning_content is None or reasoning_content == '': reasoning_content = getattr(choice.delta, 'reasoning', None) @@ -835,11 +839,11 @@ # Handle reasoning content if reasoning_content is not None: - collected_reasoning[choice.index].append(str(reasoning_content)) + collected_reasoning[choice_index].append(str(reasoning_content)) # Handle regular content if choice.delta.content is not None: - collected_messages[choice.index].append(choice.delta.content) + collected_messages[choice_index].append(choice.delta.content) # Handle tool calls if hasattr(choice.delta, 'tool_calls') and choice.delta.tool_calls: @@ -847,8 +851,8 @@ tool_id = tool_call.index # Initialize tool call if not present - if tool_id not in collected_tool_calls[choice.index]: - collected_tool_calls[choice.index][tool_id] = { + if tool_id not in collected_tool_calls[choice_index]: + collected_tool_calls[choice_index][tool_id] = { 'id': tool_call.id if hasattr(tool_call, 'id') and tool_call.id else None, 'type': tool_call.type if hasattr(tool_call, 'type') and tool_call.type else None, 'function': { @@ -860,15 +864,15 @@ # Update tool call with new chunks if hasattr(tool_call, 'function'): if hasattr(tool_call.function, 'name') and tool_call.function.name: - collected_tool_calls[choice.index][tool_id]['function']['name'] = tool_call.function.name + collected_tool_calls[choice_index][tool_id]['function']['name'] = tool_call.function.name if hasattr(tool_call.function, 'arguments') and tool_call.function.arguments: - collected_tool_calls[choice.index + collected_tool_calls[choice_index ][tool_id]['function']['arguments'] += tool_call.function.arguments # Update ID if it was received later if hasattr(tool_call, 'id') and tool_call.id: - collected_tool_calls[choice.index][tool_id]['id'] = tool_call.id + collected_tool_calls[choice_index][tool_id]['id'] = tool_call.id # Get all unique choice indices from all collections all_indices = set(collected_messages.keys()) | set(collected_reasoning.keys()) | set(collected_tool_calls.keys()) @@ -953,6 +957,8 @@ continue collected_chunks.append(chunk) for choice in chunk.choices: + # Some proxies (e.g. Vectron) omit choice.index; default to 0. + choice_index = choice.index if choice.index is not None else 0 reasoning_content = getattr(choice.delta, 'reasoning_content', None) if reasoning_content is None or reasoning_content == '': reasoning_content = getattr(choice.delta, 'reasoning', None) @@ -966,11 +972,11 @@ # Handle reasoning content if reasoning_content is not None: - collected_reasoning[choice.index].append(str(reasoning_content)) + collected_reasoning[choice_index].append(str(reasoning_content)) # Handle regular content if choice.delta.content is not None: - collected_messages[choice.index].append(choice.delta.content) + collected_messages[choice_index].append(choice.delta.content) # Handle tool calls if hasattr(choice.delta, 'tool_calls') and choice.delta.tool_calls: @@ -978,8 +984,8 @@ tool_id = tool_call.index # Initialize tool call if not present - if tool_id not in collected_tool_calls[choice.index]: - collected_tool_calls[choice.index][tool_id] = { + if tool_id not in collected_tool_calls[choice_index]: + collected_tool_calls[choice_index][tool_id] = { 'id': tool_call.id if hasattr(tool_call, 'id') and tool_call.id else None, 'type': tool_call.type if hasattr(tool_call, 'type') and tool_call.type else None, 'function': { @@ -991,15 +997,15 @@ # Update tool call with new chunks if hasattr(tool_call, 'function'): if hasattr(tool_call.function, 'name') and tool_call.function.name: - collected_tool_calls[choice.index][tool_id]['function']['name'] = tool_call.function.name + collected_tool_calls[choice_index][tool_id]['function']['name'] = tool_call.function.name if hasattr(tool_call.function, 'arguments') and tool_call.function.arguments: - collected_tool_calls[choice.index + collected_tool_calls[choice_index ][tool_id]['function']['arguments'] += tool_call.function.arguments # Update ID if it was received later if hasattr(tool_call, 'id') and tool_call.id: - collected_tool_calls[choice.index][tool_id]['id'] = tool_call.id + collected_tool_calls[choice_index][tool_id]['id'] = tool_call.id # Get all unique choice indices from all collections all_indices = set(collected_messages.keys()) | set(collected_reasoning.keys()) | set(collected_tool_calls.keys())