Skip to content

Commit

Permalink
fix(graphql): coerce to string when output.value is not None (e.g. bo…
Browse files Browse the repository at this point in the history
…ol) (#5892)
  • Loading branch information
RogerHYang authored Jan 3, 2025
1 parent 8c8271e commit 5c7e6d3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/phoenix/server/api/types/Span.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,14 @@ async def invocation_parameters(self, info: Info[Context, None]) -> list[Invocat

def to_gql_span(span: models.Span) -> Span:
events: list[SpanEvent] = list(map(SpanEvent.from_dict, span.events))
input_value = cast(Optional[str], get_attribute_value(span.attributes, INPUT_VALUE))
output_value = cast(Optional[str], get_attribute_value(span.attributes, OUTPUT_VALUE))
input_value = get_attribute_value(span.attributes, INPUT_VALUE)
if input_value is not None:
input_value = str(input_value)
assert input_value is None or isinstance(input_value, str)
output_value = get_attribute_value(span.attributes, OUTPUT_VALUE)
if output_value is not None:
output_value = str(output_value)
assert output_value is None or isinstance(output_value, str)
retrieval_documents = get_attribute_value(span.attributes, RETRIEVAL_DOCUMENTS)
num_documents = len(retrieval_documents) if isinstance(retrieval_documents, Sized) else None
return Span(
Expand Down

0 comments on commit 5c7e6d3

Please sign in to comment.