langfuse-haystack 0.6.0__tar.gz → 0.6.1__tar.gz
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.
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/CHANGELOG.md +10 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/PKG-INFO +1 -1
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/src/haystack_integrations/tracing/langfuse/tracer.py +16 -8
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/tests/test_tracer.py +16 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/tests/test_tracing.py +1 -1
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/.gitignore +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/LICENSE.txt +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/README.md +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/example/basic_rag.py +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/example/chat.py +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/example/requirements.txt +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/pydoc/config.yml +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/pyproject.toml +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/src/haystack_integrations/components/connectors/langfuse/__init__.py +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/src/haystack_integrations/components/connectors/langfuse/langfuse_connector.py +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/src/haystack_integrations/tracing/langfuse/__init__.py +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/tests/__init__.py +0 -0
- {langfuse_haystack-0.6.0 → langfuse_haystack-0.6.1}/tests/test_langfuse_span.py +0 -0
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [integrations/langfuse-v0.6.0] - 2024-11-18
|
|
4
|
+
|
|
5
|
+
### 🚀 Features
|
|
6
|
+
|
|
7
|
+
- Add support for ttft (#1161)
|
|
8
|
+
|
|
9
|
+
### ⚙️ Miscellaneous Tasks
|
|
10
|
+
|
|
11
|
+
- Adopt uv as installer (#1142)
|
|
12
|
+
|
|
3
13
|
## [integrations/langfuse-v0.5.0] - 2024-10-01
|
|
4
14
|
|
|
5
15
|
### ⚙️ Miscellaneous Tasks
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: langfuse-haystack
|
|
3
|
-
Version: 0.6.
|
|
3
|
+
Version: 0.6.1
|
|
4
4
|
Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/langfuse#readme
|
|
5
5
|
Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
|
|
6
6
|
Project-URL: Source, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/langfuse
|
|
@@ -7,7 +7,8 @@ from typing import Any, Dict, Iterator, List, Optional, Union
|
|
|
7
7
|
from haystack import logging
|
|
8
8
|
from haystack.components.generators.openai_utils import _convert_message_to_openai_format
|
|
9
9
|
from haystack.dataclasses import ChatMessage
|
|
10
|
-
from haystack.tracing import Span, Tracer
|
|
10
|
+
from haystack.tracing import Span, Tracer
|
|
11
|
+
from haystack.tracing import tracer as proxy_tracer
|
|
11
12
|
from haystack.tracing import utils as tracing_utils
|
|
12
13
|
|
|
13
14
|
import langfuse
|
|
@@ -42,7 +43,7 @@ _COMPONENT_OUTPUT_KEY = "haystack.component.output"
|
|
|
42
43
|
|
|
43
44
|
# Context var used to keep track of tracing related info.
|
|
44
45
|
# This mainly useful for parents spans.
|
|
45
|
-
tracing_context_var: ContextVar[Dict[Any, Any]] = ContextVar("tracing_context"
|
|
46
|
+
tracing_context_var: ContextVar[Dict[Any, Any]] = ContextVar("tracing_context")
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
class LangfuseSpan(Span):
|
|
@@ -78,7 +79,7 @@ class LangfuseSpan(Span):
|
|
|
78
79
|
:param key: The content tag key.
|
|
79
80
|
:param value: The content tag value.
|
|
80
81
|
"""
|
|
81
|
-
if not
|
|
82
|
+
if not proxy_tracer.is_content_tracing_enabled:
|
|
82
83
|
return
|
|
83
84
|
if key.endswith(".input"):
|
|
84
85
|
if "messages" in value:
|
|
@@ -126,6 +127,12 @@ class LangfuseTracer(Tracer):
|
|
|
126
127
|
be publicly accessible to anyone with the tracing URL. If set to `False`, the tracing data will be private
|
|
127
128
|
and only accessible to the Langfuse account owner.
|
|
128
129
|
"""
|
|
130
|
+
if not proxy_tracer.is_content_tracing_enabled:
|
|
131
|
+
logger.warning(
|
|
132
|
+
"Traces will not be logged to Langfuse because Haystack tracing is disabled. "
|
|
133
|
+
"To enable, set the HAYSTACK_CONTENT_TRACING_ENABLED environment variable to true "
|
|
134
|
+
"before importing Haystack."
|
|
135
|
+
)
|
|
129
136
|
self._tracer = tracer
|
|
130
137
|
self._context: List[LangfuseSpan] = []
|
|
131
138
|
self._name = name
|
|
@@ -147,15 +154,16 @@ class LangfuseTracer(Tracer):
|
|
|
147
154
|
operation_name=operation_name,
|
|
148
155
|
)
|
|
149
156
|
# Create a new trace if no parent span is provided
|
|
157
|
+
context = tracing_context_var.get({})
|
|
150
158
|
span = LangfuseSpan(
|
|
151
159
|
self._tracer.trace(
|
|
152
160
|
name=self._name,
|
|
153
161
|
public=self._public,
|
|
154
|
-
id=
|
|
155
|
-
user_id=
|
|
156
|
-
session_id=
|
|
157
|
-
tags=
|
|
158
|
-
version=
|
|
162
|
+
id=context.get("trace_id"),
|
|
163
|
+
user_id=context.get("user_id"),
|
|
164
|
+
session_id=context.get("session_id"),
|
|
165
|
+
tags=context.get("tags"),
|
|
166
|
+
version=context.get("version"),
|
|
159
167
|
)
|
|
160
168
|
)
|
|
161
169
|
elif tags.get(_COMPONENT_TYPE_KEY) in _ALL_SUPPORTED_GENERATORS:
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import datetime
|
|
2
|
+
import logging
|
|
3
|
+
import sys
|
|
2
4
|
from unittest.mock import MagicMock, Mock, patch
|
|
3
5
|
|
|
4
6
|
from haystack.dataclasses import ChatMessage
|
|
@@ -149,3 +151,17 @@ class TestLangfuseTracer:
|
|
|
149
151
|
pass
|
|
150
152
|
|
|
151
153
|
assert tracer._context == []
|
|
154
|
+
|
|
155
|
+
def test_init_with_tracing_disabled(self, monkeypatch, caplog):
|
|
156
|
+
# Clear haystack modules because ProxyTracer is initialized whenever haystack is imported
|
|
157
|
+
modules_to_clear = [name for name in sys.modules if name.startswith('haystack')]
|
|
158
|
+
for name in modules_to_clear:
|
|
159
|
+
sys.modules.pop(name, None)
|
|
160
|
+
|
|
161
|
+
# Re-import LangfuseTracer and instantiate it with tracing disabled
|
|
162
|
+
with caplog.at_level(logging.WARNING):
|
|
163
|
+
monkeypatch.setenv("HAYSTACK_CONTENT_TRACING_ENABLED", "false")
|
|
164
|
+
from haystack_integrations.tracing.langfuse import LangfuseTracer
|
|
165
|
+
|
|
166
|
+
LangfuseTracer(tracer=MockTracer(), name="Haystack", public=False)
|
|
167
|
+
assert "tracing is disabled" in caplog.text
|
|
@@ -49,7 +49,7 @@ def test_tracing_integration(llm_class, env_var, expected_trace):
|
|
|
49
49
|
"tracer": {"invocation_context": {"user_id": "user_42"}},
|
|
50
50
|
}
|
|
51
51
|
)
|
|
52
|
-
assert "Berlin" in response["llm"]["replies"][0].
|
|
52
|
+
assert "Berlin" in response["llm"]["replies"][0].text
|
|
53
53
|
assert response["tracer"]["trace_url"]
|
|
54
54
|
|
|
55
55
|
trace_url = response["tracer"]["trace_url"]
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|