5757 _create_trtllm_generate_request ,
5858 _create_vllm_embedding_request ,
5959 _create_vllm_generate_request ,
60- _get_openai_chat_format_logprobs_from_vllm_response ,
61- _get_openai_completion_format_logprobs_from_vllm_response ,
6260 _get_output ,
6361 _get_usage_from_response ,
6462 _get_vllm_lora_names ,
6866from schemas .openai import (
6967 ChatCompletionChoice ,
7068 ChatCompletionFinishReason ,
71- ChatCompletionLogprobs ,
7269 ChatCompletionMessageToolCall ,
7370 ChatCompletionMessageToolCallChunk ,
7471 ChatCompletionNamedToolChoice ,
@@ -258,22 +255,13 @@ async def chat(
258255 response , metadata .backend , RequestKind .GENERATION
259256 )
260257
261- # Parse logprobs if requested
262- logprobs_data = None
263- if request .logprobs :
264- openai_logprobs = _get_openai_chat_format_logprobs_from_vllm_response (
265- response
266- )
267- if openai_logprobs :
268- logprobs_data = ChatCompletionLogprobs (content = openai_logprobs )
269-
270258 return CreateChatCompletionResponse (
271259 id = request_id ,
272260 choices = [
273261 ChatCompletionChoice (
274262 index = 0 ,
275263 message = response_message ,
276- logprobs = logprobs_data ,
264+ logprobs = None ,
277265 finish_reason = finish_reason ,
278266 )
279267 ],
@@ -372,17 +360,10 @@ async def completion(
372360 response , metadata .backend , RequestKind .GENERATION
373361 )
374362
375- # Parse logprobs if requested
376- logprobs_data = None
377- if request .logprobs is not None and request .logprobs > 0 :
378- logprobs_data = _get_openai_completion_format_logprobs_from_vllm_response (
379- response
380- )
381-
382363 choice = Choice (
383364 finish_reason = FinishReason .stop ,
384365 index = 0 ,
385- logprobs = logprobs_data ,
366+ logprobs = None ,
386367 text = text ,
387368 )
388369 return CreateCompletionResponse (
@@ -624,15 +605,6 @@ async def _streaming_chat_iterator(
624605 )
625606 previous_text = current_text
626607
627- # Parse logprobs for this chunk if requested
628- chunk_logprobs = None
629- if request .logprobs :
630- openai_logprobs = _get_openai_chat_format_logprobs_from_vllm_response (
631- response
632- )
633- if openai_logprobs :
634- chunk_logprobs = ChatCompletionLogprobs (content = openai_logprobs )
635-
636608 # if the response delta is None (e.g. because it was a
637609 # "control token" for tool calls or the parser otherwise
638610 # wasn't ready to send a token, then
@@ -646,7 +618,7 @@ async def _streaming_chat_iterator(
646618 choice = ChatCompletionStreamingResponseChoice (
647619 index = 0 ,
648620 delta = response_delta ,
649- logprobs = chunk_logprobs ,
621+ logprobs = None ,
650622 finish_reason = finish_reason ,
651623 )
652624
@@ -819,19 +791,8 @@ def _validate_chat_request(
819791 f"Received n={ request .n } , but only single choice (n=1) is currently supported"
820792 )
821793
822- if request .logit_bias is not None :
823- raise ClientError ("logit bias is not currently supported" )
824-
825- # Logprobs are only supported for vLLM backend currently
826- if metadata .backend != "vllm" and (
827- request .logprobs is not None or request .top_logprobs is not None
828- ):
829- raise ClientError (
830- "logprobs are currently available only for the vLLM backend"
831- )
832-
833- if request .top_logprobs is not None and not request .logprobs :
834- raise ClientError ("`top_logprobs` can only be used when `logprobs` is True" )
794+ if request .logit_bias is not None or request .logprobs :
795+ raise ClientError ("logit bias and log probs not currently supported" )
835796
836797 self ._verify_chat_tool_call_settings (request = request )
837798
@@ -886,32 +847,16 @@ async def _streaming_completion_iterator(
886847 model = request .model
887848 include_usage = request .stream_options and request .stream_options .include_usage
888849 usage_accumulator = _StreamingUsageAccumulator (backend )
889- current_offset = 0
890850
891851 async for response in responses :
892852 if include_usage :
893853 usage_accumulator .update (response )
894854
895855 text = _get_output (response )
896-
897- # Parse logprobs for this chunk if requested
898- chunk_logprobs = None
899- if request .logprobs is not None and request .logprobs > 0 :
900- chunk_logprobs = (
901- _get_openai_completion_format_logprobs_from_vllm_response (response )
902- )
903- # Adjust text offsets based on accumulated output
904- if chunk_logprobs and chunk_logprobs .text_offset :
905- chunk_logprobs .text_offset = [
906- offset + current_offset for offset in chunk_logprobs .text_offset
907- ]
908-
909- current_offset += len (text )
910-
911856 choice = Choice (
912857 finish_reason = FinishReason .stop if response .final else None ,
913858 index = 0 ,
914- logprobs = chunk_logprobs ,
859+ logprobs = None ,
915860 text = text ,
916861 )
917862 chunk = CreateCompletionResponse (
@@ -997,18 +942,8 @@ def _validate_completion_request(
997942 f"Received best_of={ request .best_of } , but only single choice (best_of=1) is currently supported"
998943 )
999944
1000- if request .logit_bias is not None :
1001- raise ClientError ("logit bias is not supported" )
1002-
1003- # Logprobs are only supported for vLLM backend currently
1004- if (
1005- request .logprobs is not None
1006- and request .logprobs > 0
1007- and metadata .backend != "vllm"
1008- ):
1009- raise ClientError (
1010- "logprobs are currently available only for the vLLM backend"
1011- )
945+ if request .logit_bias is not None or request .logprobs is not None :
946+ raise ClientError ("logit bias and log probs not supported" )
1012947
1013948 if request .stream_options and not request .stream :
1014949 raise ClientError ("`stream_options` can only be used when `stream` is True" )
0 commit comments