From 55c65af5ac338f0678537125d6fd0e92dfa689b6 Mon Sep 17 00:00:00 2001 From: Madeesh Kannan Date: Fri, 16 Aug 2024 14:48:23 +0200 Subject: [PATCH] refactor: Remove usage of deprecated `ChatMessage.to_openai_format` (#1001) --- .../src/haystack_integrations/tracing/langfuse/tracer.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py b/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py index 4bf0da2f8..7d141c08c 100644 --- a/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py +++ b/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py @@ -2,6 +2,7 @@ import os from typing import Any, Dict, Iterator, Optional, Union +from haystack.components.generators.openai_utils import _convert_message_to_openai_format from haystack.dataclasses import ChatMessage from haystack.tracing import Span, Tracer, tracer from haystack.tracing import utils as tracing_utils @@ -51,14 +52,14 @@ def set_content_tag(self, key: str, value: Any) -> None: return if key.endswith(".input"): if "messages" in value: - messages = [m.to_openai_format() for m in value["messages"]] + messages = [_convert_message_to_openai_format(m) for m in value["messages"]] self._span.update(input=messages) else: self._span.update(input=value) elif key.endswith(".output"): if "replies" in value: if all(isinstance(r, ChatMessage) for r in value["replies"]): - replies = [m.to_openai_format() for m in value["replies"]] + replies = [_convert_message_to_openai_format(m) for m in value["replies"]] else: replies = value["replies"] self._span.update(output=replies)