Skip to content

Commit

Permalink
use existing util
Browse files Browse the repository at this point in the history
  • Loading branch information
angus-langchain committed Dec 9, 2024
1 parent 7367a8a commit 79ec2c6
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions python/langsmith/_internal/_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

from langsmith import schemas as ls_schemas
from langsmith._internal import _orjson
from langsmith._internal._multipart import MultipartPart, MultipartPartsAndContext
from langsmith._internal._multipart import MultipartPart, MultipartPartsAndContext, join_multipart_parts_and_context
from langsmith._internal._serde import dumps_json as _dumps_json

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -275,30 +275,6 @@ def serialized_run_operation_to_multipart_parts_and_context(
f"trace={op.trace_id},id={op.id}",
)


def combine_multipart_parts_and_context_for_compression(
parts_and_contexts: Sequence[MultipartPartsAndContext],
) -> MultipartPartsAndContext:
"""Combine multiple MultipartPartsAndContext objects for streaming compression.
Args:
parts_and_contexts: Sequence of MultipartPartsAndContext objects to combine
Returns:
Combined MultipartPartsAndContext with all parts and contexts
"""
all_parts = []
contexts = []

for pc in parts_and_contexts:
all_parts.extend(pc.parts)
contexts.append(pc.context)

return MultipartPartsAndContext(
all_parts,
";".join(contexts)
)

class StreamingMultipartCompressor:
"""Incrementally compress multipart form data from multiple traces."""

Expand Down Expand Up @@ -422,7 +398,7 @@ def get_multipart_parts(
parts_and_contexts.append(
serialized_run_operation_to_multipart_parts_and_context(op)
)
return combine_multipart_parts_and_context_for_compression(
return join_multipart_parts_and_context(
parts_and_contexts
)

Expand Down

0 comments on commit 79ec2c6

Please sign in to comment.