Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
9ddc018
init commit
nimarb Aug 11, 2025
1bc90b0
Use as_type
nimarb Aug 12, 2025
7f71789
clean
nimarb Aug 12, 2025
df8ff8e
cleanup
nimarb Aug 12, 2025
c3be3d8
cleanup
nimarb Aug 12, 2025
c1bd882
Merge branch 'main' into nimar/lfe-6153-generalized-graphs-python
nimarb Aug 12, 2025
2f34092
todo clarifty case sensitivity
nimarb Aug 12, 2025
6b36bd1
format
nimarb Aug 12, 2025
6e0695b
revert
nimarb Aug 12, 2025
ab0cbf3
add test
nimarb Aug 12, 2025
81b255a
lower case
nimarb Aug 12, 2025
b164e41
fix lint
nimarb Aug 12, 2025
ef49cde
format
nimarb Aug 12, 2025
89b1b3e
Merge branch 'main' into nimar/lfe-6153-generalized-graphs-python
nimarb Aug 12, 2025
8af5b67
types
nimarb Aug 12, 2025
bdb8147
cleanup
nimarb Aug 12, 2025
0898095
fix test
nimarb Aug 13, 2025
abd14de
update
nimarb Aug 15, 2025
0d696ea
Merge branch 'main' into nimar/lfe-6153-generalized-graphs-python
nimarb Aug 15, 2025
53a9bff
update
nimarb Aug 15, 2025
180cb96
fix cases
nimarb Aug 15, 2025
e41c018
fix some more types
nimarb Aug 15, 2025
5c3a510
update SDK
nimarb Aug 15, 2025
dc5e199
fix types
nimarb Aug 15, 2025
60f124b
add type checing isntructions
nimarb Aug 15, 2025
649da3a
restore
nimarb Aug 15, 2025
31c524c
restore 2
nimarb Aug 15, 2025
0d403e9
restore
nimarb Aug 15, 2025
df71a69
restore 3
nimarb Aug 15, 2025
c07a95a
simplify
nimarb Aug 15, 2025
abddc45
simplift
nimarb Aug 15, 2025
0b25836
simplify
nimarb Aug 15, 2025
a09044a
fix case
nimarb Aug 15, 2025
e4bcc7b
rearrange spans
nimarb Aug 15, 2025
f0a3224
restrucure a bit
nimarb Aug 18, 2025
04d6576
cleanup
nimarb Aug 18, 2025
79cb0a5
make mypy happy
nimarb Aug 18, 2025
8756e11
py3.9 compat
nimarb Aug 18, 2025
9f510ad
happy mypy
nimarb Aug 18, 2025
4498380
cleanup
nimarb Aug 18, 2025
0267755
a bit more clean
nimarb Aug 18, 2025
5aba0ba
cleanup
nimarb Aug 18, 2025
14f73bd
overload all the things
nimarb Aug 19, 2025
55dce5b
overload
nimarb Aug 19, 2025
37c284b
rename spanwrapper to observation wrapper
nimarb Aug 19, 2025
c08055d
don't update events
nimarb Aug 19, 2025
717c302
fix test
nimarb Aug 19, 2025
dc7d7ff
fix span
nimarb Aug 19, 2025
b6b1b01
fix test
nimarb Aug 19, 2025
e537231
langchain
nimarb Aug 19, 2025
f7481d6
formatting
nimarb Aug 19, 2025
0206b4e
add langchain test
nimarb Aug 20, 2025
12b806f
add core test
nimarb Aug 20, 2025
881a65b
Merge branch 'main' into nimar/lfe-6153-generalized-graphs-python
nimarb Aug 20, 2025
1ce911f
cleanup
nimarb Aug 20, 2025
d66d003
add deprecation warning
nimarb Aug 20, 2025
2e0b7a8
fix types
nimarb Aug 20, 2025
0f2c731
change generation like and span like
nimarb Aug 21, 2025
b4fb6a6
fix
nimarb Aug 21, 2025
e7f34fe
test format
nimarb Aug 21, 2025
3aa4af8
from review
nimarb Aug 22, 2025
ddb767e
format
nimarb Aug 22, 2025
599ee51
add generation-like test
nimarb Aug 22, 2025
fa5346c
chore: update auto gen SDK (#1300)
nimarb Aug 22, 2025
bb4cfab
fix lint
nimarb Aug 22, 2025
6da68c9
fix tests
nimarb Aug 22, 2025
34298e8
embedding correct attrs
nimarb Aug 22, 2025
cc7820b
fix typing
nimarb Aug 22, 2025
9f3349f
fix bug
nimarb Aug 22, 2025
9512f06
fix mypy
nimarb Aug 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ poetry install --all-extras
poetry run pre-commit install
```

### Type Checking

To run type checking on the langfuse package, run:
```sh
poetry run mypy langfuse --no-error-summary
```

### Tests

#### Setup
Expand Down
22 changes: 21 additions & 1 deletion langfuse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,38 @@

from ._client import client as _client_module
from ._client.attributes import LangfuseOtelSpanAttributes
from ._client.constants import ObservationTypeLiteral
from ._client.get_client import get_client
from ._client.observe import observe
from ._client.span import LangfuseEvent, LangfuseGeneration, LangfuseSpan
from ._client.span import (
LangfuseEvent,
LangfuseGeneration,
LangfuseSpan,
LangfuseAgent,
LangfuseTool,
LangfuseChain,
LangfuseEmbedding,
LangfuseEvaluator,
LangfuseRetriever,
LangfuseGuardrail,
)

Langfuse = _client_module.Langfuse

__all__ = [
"Langfuse",
"get_client",
"observe",
"ObservationTypeLiteral",
"LangfuseSpan",
"LangfuseGeneration",
"LangfuseEvent",
"LangfuseOtelSpanAttributes",
"LangfuseAgent",
"LangfuseTool",
"LangfuseChain",
"LangfuseEmbedding",
"LangfuseEvaluator",
"LangfuseRetriever",
"LangfuseGuardrail",
]
13 changes: 11 additions & 2 deletions langfuse/_client/attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
from datetime import datetime
from typing import Any, Dict, List, Literal, Optional, Union

from langfuse._client.constants import (
ObservationTypeGenerationLike,
ObservationTypeSpanLike,
)

from langfuse._utils.serializer import EventSerializer
from langfuse.model import PromptClient
from langfuse.types import MapValue, SpanLevel
Expand Down Expand Up @@ -93,9 +98,12 @@ def create_span_attributes(
level: Optional[SpanLevel] = None,
status_message: Optional[str] = None,
version: Optional[str] = None,
observation_type: Optional[
Union[ObservationTypeSpanLike, Literal["event"]]
] = "span",
) -> dict:
attributes = {
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: "span",
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: observation_type,
LangfuseOtelSpanAttributes.OBSERVATION_LEVEL: level,
LangfuseOtelSpanAttributes.OBSERVATION_STATUS_MESSAGE: status_message,
LangfuseOtelSpanAttributes.VERSION: version,
Expand All @@ -122,9 +130,10 @@ def create_generation_attributes(
usage_details: Optional[Dict[str, int]] = None,
cost_details: Optional[Dict[str, float]] = None,
prompt: Optional[PromptClient] = None,
observation_type: Optional[ObservationTypeGenerationLike] = "generation",
) -> dict:
attributes = {
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: "generation",
LangfuseOtelSpanAttributes.OBSERVATION_TYPE: observation_type,
LangfuseOtelSpanAttributes.OBSERVATION_LEVEL: level,
LangfuseOtelSpanAttributes.OBSERVATION_STATUS_MESSAGE: status_message,
LangfuseOtelSpanAttributes.VERSION: version,
Expand Down
Loading
Loading