diff --git a/integrations/langfuse/src/haystack_integrations/components/others/langfuse/component.py b/integrations/langfuse/src/haystack_integrations/components/others/langfuse/component.py index 1725e7392..d6ba93820 100644 --- a/integrations/langfuse/src/haystack_integrations/components/others/langfuse/component.py +++ b/integrations/langfuse/src/haystack_integrations/components/others/langfuse/component.py @@ -1,5 +1,4 @@ -from haystack import tracing, component - +from haystack import component, tracing from haystack_integrations.tracing.langfuse import LangfuseTracer from langfuse import Langfuse @@ -14,5 +13,4 @@ def __init__(self, name: str): @component.output_types(name=str, trace_url=str) def run(self): - return {"name": self.name, - "trace_url": self.tracer.get_trace_url()} + return {"name": self.name, "trace_url": self.tracer.get_trace_url()} diff --git a/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py b/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py index 95fb053ac..826519d77 100644 --- a/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py +++ b/integrations/langfuse/src/haystack_integrations/tracing/langfuse/tracer.py @@ -12,7 +12,7 @@ class LangfuseSpan(Span): def __init__(self, span: "Union[langfuse.client.StatefulSpanClient, langfuse.client.StatefulTraceClient]") -> None: self._span = span # locally cache tags - self._data = {} + self._data: Dict[str, Any] = {} def set_tag(self, key: str, value: Any) -> None: coerced_value = tracing_utils.coerce_tag_value(value) @@ -106,4 +106,4 @@ def current_span(self) -> Span: return self._context[-1] def get_trace_url(self) -> str: - return self._tracer.get_trace_url() \ No newline at end of file + return self._tracer.get_trace_url() diff --git a/integrations/langfuse/tests/test_tracing.py b/integrations/langfuse/tests/test_tracing.py index 130bbec2d..6855792f9 100644 --- a/integrations/langfuse/tests/test_tracing.py +++ b/integrations/langfuse/tests/test_tracing.py @@ -15,9 +15,9 @@ @pytest.mark.integration @pytest.mark.skipif( - not os.environ.get("LANGFUSE_SECRET_KEY", None) and not os.environ.get("LANGFUSE_PUBLIC_KEY", None), - reason="Export an env var called LANGFUSE_SECRET_KEY and LANGFUSE_PUBLIC_KEY containing Langfuse credentials.", - ) + not os.environ.get("LANGFUSE_SECRET_KEY", None) and not os.environ.get("LANGFUSE_PUBLIC_KEY", None), + reason="Export an env var called LANGFUSE_SECRET_KEY and LANGFUSE_PUBLIC_KEY containing Langfuse credentials.", +) def test_tracing_integration(): pipe = Pipeline() @@ -46,9 +46,10 @@ def test_tracing_integration(): try: # GET request with Basic Authentication on the Langfuse API - response = requests.get(url+uuid, auth=HTTPBasicAuth(os.environ.get("LANGFUSE_PUBLIC_KEY"), - os.environ.get("LANGFUSE_SECRET_KEY"))) + response = requests.get( + url + uuid, auth=HTTPBasicAuth(os.environ.get("LANGFUSE_PUBLIC_KEY"), os.environ.get("LANGFUSE_SECRET_KEY")) + ) assert response.status_code == 200, f"Failed to retrieve data from Langfuse API: {response.status_code}" except requests.exceptions.RequestException as e: - assert False, f"Failed to retrieve data from Langfuse API: {e}" \ No newline at end of file + assert False, f"Failed to retrieve data from Langfuse API: {e}"