mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-22 00:31:44 +00:00
style: black format streaming_chunk_builder_utils.py
This commit is contained in:
parent
c2ef164396
commit
c351c691c3
1 changed files with 10 additions and 12 deletions
|
|
@ -119,9 +119,7 @@ class ChunkProcessor:
|
|||
model = ChunkProcessor._get_model_from_chunks(chunks, first_chunk_model)
|
||||
system_fingerprint = chunk.get("system_fingerprint", None)
|
||||
|
||||
first_chunk_with_choices = next(
|
||||
(c for c in chunks if c.get("choices")), chunk
|
||||
)
|
||||
first_chunk_with_choices = next((c for c in chunks if c.get("choices")), chunk)
|
||||
role = first_chunk_with_choices["choices"][0]["delta"]["role"]
|
||||
finish_reason = "stop"
|
||||
for chunk in chunks:
|
||||
|
|
@ -166,9 +164,9 @@ class ChunkProcessor:
|
|||
self, tool_call_chunks: List[Dict[str, Any]]
|
||||
) -> List[ChatCompletionMessageToolCall]:
|
||||
tool_calls_list: List[ChatCompletionMessageToolCall] = []
|
||||
tool_call_map: Dict[
|
||||
int, Dict[str, Any]
|
||||
] = {} # Map to store tool calls by index
|
||||
tool_call_map: Dict[int, Dict[str, Any]] = (
|
||||
{}
|
||||
) # Map to store tool calls by index
|
||||
|
||||
for chunk in tool_call_chunks:
|
||||
choices = chunk["choices"]
|
||||
|
|
@ -649,12 +647,12 @@ class ChunkProcessor:
|
|||
web_search_requests: Optional[int] = calculated_usage_per_chunk[
|
||||
"web_search_requests"
|
||||
]
|
||||
completion_tokens_details: Optional[
|
||||
CompletionTokensDetails
|
||||
] = calculated_usage_per_chunk["completion_tokens_details"]
|
||||
prompt_tokens_details: Optional[
|
||||
PromptTokensDetailsWrapper
|
||||
] = calculated_usage_per_chunk["prompt_tokens_details"]
|
||||
completion_tokens_details: Optional[CompletionTokensDetails] = (
|
||||
calculated_usage_per_chunk["completion_tokens_details"]
|
||||
)
|
||||
prompt_tokens_details: Optional[PromptTokensDetailsWrapper] = (
|
||||
calculated_usage_per_chunk["prompt_tokens_details"]
|
||||
)
|
||||
|
||||
try:
|
||||
returned_usage.prompt_tokens = prompt_tokens or token_counter(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue