langfuse-haystack 0.0.1__tar.gz → 0.0.2__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.0.1 → langfuse_haystack-0.0.2}/PKG-INFO +7 -6
- langfuse_haystack-0.0.2/README.md +22 -0
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/example/basic_rag.py +1 -1
- langfuse_haystack-0.0.2/example/requirements.txt +3 -0
- langfuse_haystack-0.0.2/src/haystack_integrations/components/others/langfuse/__about__.py +1 -0
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/src/haystack_integrations/components/others/langfuse/langfuse.py +2 -1
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/src/haystack_integrations/tracing/langfuse/tracer.py +15 -1
- langfuse_haystack-0.0.1/README.md +0 -21
- langfuse_haystack-0.0.1/example/requirements.txt +0 -2
- langfuse_haystack-0.0.1/src/haystack_integrations/components/others/langfuse/__about__.py +0 -1
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/.gitignore +0 -0
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/LICENSE.txt +0 -0
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/pyproject.toml +0 -0
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/src/haystack_integrations/components/others/langfuse/__init__.py +0 -0
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/src/haystack_integrations/tracing/langfuse/__init__.py +0 -0
- {langfuse_haystack-0.0.1 → langfuse_haystack-0.0.2}/tests/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: langfuse-haystack
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.2
|
|
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
|
|
@@ -23,20 +23,21 @@ Description-Content-Type: text/markdown
|
|
|
23
23
|
|
|
24
24
|
# langfuse
|
|
25
25
|
|
|
26
|
-
[](https://pypi.org/project/langfuse)
|
|
27
|
-
[](https://pypi.org/project/langfuse)
|
|
26
|
+
[](https://pypi.org/project/langfuse-haystack)
|
|
27
|
+
[](https://pypi.org/project/langfuse-haystack)
|
|
28
28
|
|
|
29
29
|
-----
|
|
30
30
|
|
|
31
31
|
**Table of Contents**
|
|
32
32
|
|
|
33
|
-
- [
|
|
34
|
-
- [
|
|
33
|
+
- [langfuse](#langfuse)
|
|
34
|
+
- [Installation](#installation)
|
|
35
|
+
- [License](#license)
|
|
35
36
|
|
|
36
37
|
## Installation
|
|
37
38
|
|
|
38
39
|
```console
|
|
39
|
-
pip install langfuse
|
|
40
|
+
pip install langfuse-haystack
|
|
40
41
|
```
|
|
41
42
|
|
|
42
43
|
## License
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# langfuse
|
|
2
|
+
|
|
3
|
+
[](https://pypi.org/project/langfuse-haystack)
|
|
4
|
+
[](https://pypi.org/project/langfuse-haystack)
|
|
5
|
+
|
|
6
|
+
-----
|
|
7
|
+
|
|
8
|
+
**Table of Contents**
|
|
9
|
+
|
|
10
|
+
- [langfuse](#langfuse)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [License](#license)
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```console
|
|
17
|
+
pip install langfuse-haystack
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## License
|
|
21
|
+
|
|
22
|
+
`langfuse` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
|
|
@@ -41,7 +41,7 @@ def get_pipeline(document_store: InMemoryDocumentStore):
|
|
|
41
41
|
)
|
|
42
42
|
basic_rag_pipeline.add_component("retriever", retriever)
|
|
43
43
|
basic_rag_pipeline.add_component("prompt_builder", prompt_builder)
|
|
44
|
-
basic_rag_pipeline.add_component("llm", OpenAIGenerator(model="gpt-3.5-turbo"))
|
|
44
|
+
basic_rag_pipeline.add_component("llm", OpenAIGenerator(model="gpt-3.5-turbo", generation_kwargs={"n": 2}))
|
|
45
45
|
|
|
46
46
|
# Now, connect the components to each other
|
|
47
47
|
# NOTE: the tracer component doesn't need to be connected to anything in order to work
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.2"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import contextlib
|
|
2
2
|
from typing import Any, Dict, Iterator, Optional, Union
|
|
3
3
|
|
|
4
|
-
from haystack.lazy_imports import LazyImport
|
|
5
4
|
from haystack.tracing import Span, Tracer, tracer
|
|
6
5
|
from haystack.tracing import utils as tracing_utils
|
|
7
6
|
|
|
@@ -11,10 +10,13 @@ import langfuse
|
|
|
11
10
|
class LangfuseSpan(Span):
|
|
12
11
|
def __init__(self, span: "Union[langfuse.client.StatefulSpanClient, langfuse.client.StatefulTraceClient]") -> None:
|
|
13
12
|
self._span = span
|
|
13
|
+
# locally cache tags
|
|
14
|
+
self._data = {}
|
|
14
15
|
|
|
15
16
|
def set_tag(self, key: str, value: Any) -> None:
|
|
16
17
|
coerced_value = tracing_utils.coerce_tag_value(value)
|
|
17
18
|
self._span.update(metadata={key: coerced_value})
|
|
19
|
+
self._data[key] = value
|
|
18
20
|
|
|
19
21
|
def set_content_tag(self, key: str, value: Any) -> None:
|
|
20
22
|
if not tracer.is_content_tracing_enabled:
|
|
@@ -25,6 +27,8 @@ class LangfuseSpan(Span):
|
|
|
25
27
|
elif key.endswith(".output"):
|
|
26
28
|
self._span.update(output=value)
|
|
27
29
|
|
|
30
|
+
self._data[key] = value
|
|
31
|
+
|
|
28
32
|
def raw_span(self) -> Any:
|
|
29
33
|
return self._span
|
|
30
34
|
|
|
@@ -42,9 +46,11 @@ class LangfuseTracer(Tracer):
|
|
|
42
46
|
def trace(self, operation_name: str, tags: Optional[Dict[str, Any]] = None) -> Iterator[Span]:
|
|
43
47
|
tags = tags or {}
|
|
44
48
|
span_name = tags.get("haystack.component.name", operation_name)
|
|
49
|
+
is_generation = False
|
|
45
50
|
|
|
46
51
|
if tags.get("haystack.component.type") in ["OpenAIGenerator"]:
|
|
47
52
|
span = LangfuseSpan(self.current_span().raw_span().generation(name=span_name))
|
|
53
|
+
is_generation = True
|
|
48
54
|
else:
|
|
49
55
|
span = LangfuseSpan(self.current_span().raw_span().span(name=span_name))
|
|
50
56
|
|
|
@@ -53,6 +59,14 @@ class LangfuseTracer(Tracer):
|
|
|
53
59
|
|
|
54
60
|
yield span
|
|
55
61
|
|
|
62
|
+
if is_generation:
|
|
63
|
+
meta = span._data.get("haystack.component.output", {}).get("meta")
|
|
64
|
+
if meta:
|
|
65
|
+
# Haystack returns one meta dict for each message, but the 'usage' value
|
|
66
|
+
# is always the same, let's just pick the first item
|
|
67
|
+
m = meta[0]
|
|
68
|
+
span._span.update(usage=m.get("usage"), model=m.get("model"))
|
|
69
|
+
|
|
56
70
|
span.raw_span().end()
|
|
57
71
|
self._context.pop()
|
|
58
72
|
self._tracer.flush()
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# langfuse
|
|
2
|
-
|
|
3
|
-
[](https://pypi.org/project/langfuse)
|
|
4
|
-
[](https://pypi.org/project/langfuse)
|
|
5
|
-
|
|
6
|
-
-----
|
|
7
|
-
|
|
8
|
-
**Table of Contents**
|
|
9
|
-
|
|
10
|
-
- [Installation](#installation)
|
|
11
|
-
- [License](#license)
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
```console
|
|
16
|
-
pip install langfuse
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
## License
|
|
20
|
-
|
|
21
|
-
`langfuse` is distributed under the terms of the [Apache-2.0](https://spdx.org/licenses/Apache-2.0.html) license.
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.0.1"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|