arize-phoenix 1.7.2rc3__py3-none-any.whl → 1.8.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of arize-phoenix might be problematic. Click here for more details.

@@ -615,17 +615,32 @@ def _accumulate_messages(
615
615
  """
616
616
  if not chunks:
617
617
  return []
618
- tokens: DefaultDict[int, List[str]] = defaultdict(list)
619
- roles: DefaultDict[int, str] = defaultdict()
618
+ content_token_lists: DefaultDict[int, List[str]] = defaultdict(list)
619
+ function_argument_token_lists: DefaultDict[int, List[str]] = defaultdict(list)
620
+ function_names: Dict[int, str] = {}
621
+ roles: Dict[int, str] = {}
620
622
  for chunk in chunks:
621
623
  for choice in chunk.choices:
622
624
  choice_index = choice.index
623
- if content := choice.delta.content:
624
- tokens[choice_index].append(content)
625
+ if content_token := choice.delta.content:
626
+ content_token_lists[choice_index].append(content_token)
627
+ if function_call := choice.delta.function_call:
628
+ if function_name := function_call.name:
629
+ function_names[choice_index] = function_name
630
+ if (function_argument_token := function_call.arguments) is not None:
631
+ function_argument_token_lists[choice_index].append(function_argument_token)
625
632
  if role := choice.delta.role:
626
633
  roles[choice_index] = role
627
634
  messages: List[OpenInferenceMessage] = [{} for _ in range(num_choices)]
628
- for choice_index in range(len(tokens)):
629
- messages[choice_index][MESSAGE_CONTENT] = "".join(tokens.get(choice_index, []))
630
- messages[choice_index][MESSAGE_ROLE] = roles.get(choice_index, "")
635
+ for choice_index in range(num_choices):
636
+ if (role_ := roles.get(choice_index)) is not None:
637
+ messages[choice_index][MESSAGE_ROLE] = role_
638
+ if content_token_list := content_token_lists[choice_index]:
639
+ messages[choice_index][MESSAGE_CONTENT] = "".join(content_token_list)
640
+ if (function_name := function_names.get(choice_index)) is not None:
641
+ messages[choice_index][MESSAGE_FUNCTION_CALL_NAME] = function_name
642
+ if function_argument_token_list := function_argument_token_lists[choice_index]:
643
+ messages[choice_index][MESSAGE_FUNCTION_CALL_ARGUMENTS_JSON] = "".join(
644
+ function_argument_token_list
645
+ )
631
646
  return messages