langfuse-lite 0.1.0__py3-none-win_amd64.whl
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_lite/THIRD_PARTY_NOTICES.md +188 -0
- langfuse_lite/__init__.py +113 -0
- langfuse_lite/__main__.py +17 -0
- langfuse_lite/bin/langfuse-lite.exe +4 -0
- langfuse_lite/pytest_plugin.py +25 -0
- langfuse_lite-0.1.0.dist-info/LICENSE +21 -0
- langfuse_lite-0.1.0.dist-info/METADATA +173 -0
- langfuse_lite-0.1.0.dist-info/RECORD +10 -0
- langfuse_lite-0.1.0.dist-info/WHEEL +4 -0
- langfuse_lite-0.1.0.dist-info/entry_points.txt +5 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Third-party notices
|
|
2
|
+
|
|
3
|
+
langfuse-lite bundles the following software.
|
|
4
|
+
|
|
5
|
+
## Langfuse (vendor/langfuse: OTel conversion, cost calculation, model prices)
|
|
6
|
+
|
|
7
|
+
Copyright (c) 2023-2026 ClickHouse, Inc.
|
|
8
|
+
|
|
9
|
+
Portions of this software are licensed as follows:
|
|
10
|
+
|
|
11
|
+
- All content that resides under the "ee/", "web/src/ee/", "worker/src/ee/", and/or "packages/shared/src/server/ee/" directories of this repository, if these directories exist, is licensed under the license defined in "ee/LICENSE".
|
|
12
|
+
- All third party components incorporated into the Langfuse Software are licensed under the original license provided by the owner of the applicable component.
|
|
13
|
+
- Content outside of the above mentioned directories or restrictions above is available under the "MIT Expat" license as defined below.
|
|
14
|
+
|
|
15
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
in the Software without restriction, including without limitation the rights
|
|
18
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
furnished to do so, subject to the following conditions:
|
|
21
|
+
|
|
22
|
+
The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
copies or substantial portions of the Software.
|
|
24
|
+
|
|
25
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
SOFTWARE.
|
|
32
|
+
|
|
33
|
+
## Lucide icons (observation type icons in the viewer)
|
|
34
|
+
|
|
35
|
+
ISC License
|
|
36
|
+
|
|
37
|
+
Copyright (c) 2026 Lucide Icons and Contributors
|
|
38
|
+
|
|
39
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
40
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
41
|
+
copyright notice and this permission notice appear in all copies.
|
|
42
|
+
|
|
43
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
44
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
45
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
46
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
47
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
48
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
49
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
The following Lucide icons are derived from the Feather project:
|
|
54
|
+
|
|
55
|
+
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
|
|
56
|
+
|
|
57
|
+
The MIT License (MIT) (for the icons listed above)
|
|
58
|
+
|
|
59
|
+
Copyright (c) 2013-present Cole Bemis
|
|
60
|
+
|
|
61
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
62
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
63
|
+
in the Software without restriction, including without limitation the rights
|
|
64
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
65
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
66
|
+
furnished to do so, subject to the following conditions:
|
|
67
|
+
|
|
68
|
+
The above copyright notice and this permission notice shall be included in all
|
|
69
|
+
copies or substantial portions of the Software.
|
|
70
|
+
|
|
71
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
72
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
73
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
74
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
75
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
76
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
77
|
+
SOFTWARE.
|
|
78
|
+
|
|
79
|
+
## Lodash
|
|
80
|
+
|
|
81
|
+
Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
82
|
+
|
|
83
|
+
Based on Underscore.js, copyright Jeremy Ashkenas,
|
|
84
|
+
DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
|
|
85
|
+
|
|
86
|
+
This software consists of voluntary contributions made by many
|
|
87
|
+
individuals. For exact contribution history, see the revision history
|
|
88
|
+
available at https://github.com/lodash/lodash
|
|
89
|
+
|
|
90
|
+
The following license applies to all parts of this software except as
|
|
91
|
+
documented below:
|
|
92
|
+
|
|
93
|
+
====
|
|
94
|
+
|
|
95
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
96
|
+
a copy of this software and associated documentation files (the
|
|
97
|
+
"Software"), to deal in the Software without restriction, including
|
|
98
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
99
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
100
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
101
|
+
the following conditions:
|
|
102
|
+
|
|
103
|
+
The above copyright notice and this permission notice shall be
|
|
104
|
+
included in all copies or substantial portions of the Software.
|
|
105
|
+
|
|
106
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
107
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
108
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
109
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
110
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
111
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
112
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
113
|
+
|
|
114
|
+
====
|
|
115
|
+
|
|
116
|
+
Copyright and related rights for sample code are waived via CC0. Sample
|
|
117
|
+
code is defined as all source code displayed within the prose of the
|
|
118
|
+
documentation.
|
|
119
|
+
|
|
120
|
+
CC0: http://creativecommons.org/publicdomain/zero/1.0/
|
|
121
|
+
|
|
122
|
+
====
|
|
123
|
+
|
|
124
|
+
Files located in the node_modules and vendor directories are externally
|
|
125
|
+
maintained libraries used by this software which have their own
|
|
126
|
+
licenses; we recommend you read them, as their terms may differ from the
|
|
127
|
+
terms above.
|
|
128
|
+
|
|
129
|
+
## zod
|
|
130
|
+
|
|
131
|
+
MIT License
|
|
132
|
+
|
|
133
|
+
Copyright (c) 2025 Colin McDonnell
|
|
134
|
+
|
|
135
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
136
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
137
|
+
in the Software without restriction, including without limitation the rights
|
|
138
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
139
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
140
|
+
furnished to do so, subject to the following conditions:
|
|
141
|
+
|
|
142
|
+
The above copyright notice and this permission notice shall be included in all
|
|
143
|
+
copies or substantial portions of the Software.
|
|
144
|
+
|
|
145
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
146
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
147
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
148
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
149
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
150
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
151
|
+
SOFTWARE.
|
|
152
|
+
|
|
153
|
+
## decimal.js
|
|
154
|
+
|
|
155
|
+
The MIT Licence.
|
|
156
|
+
|
|
157
|
+
Copyright (c) 2025 Michael Mclaughlin
|
|
158
|
+
|
|
159
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
160
|
+
a copy of this software and associated documentation files (the
|
|
161
|
+
'Software'), to deal in the Software without restriction, including
|
|
162
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
163
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
164
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
165
|
+
the following conditions:
|
|
166
|
+
|
|
167
|
+
The above copyright notice and this permission notice shall be
|
|
168
|
+
included in all copies or substantial portions of the Software.
|
|
169
|
+
|
|
170
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
171
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
172
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
173
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
174
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
175
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
176
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
177
|
+
|
|
178
|
+
## lossless-json
|
|
179
|
+
|
|
180
|
+
The MIT License (MIT)
|
|
181
|
+
|
|
182
|
+
Copyright (c) 2016-2023 Jos de Jong
|
|
183
|
+
|
|
184
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
185
|
+
|
|
186
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
187
|
+
|
|
188
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"""langfuse-lite: a local Langfuse for experiment runs and agent tracing.
|
|
2
|
+
|
|
3
|
+
The wheel ships the langfuse-lite executable for this platform. Use it from
|
|
4
|
+
the command line (``langfuse-lite serve``, ``uvx langfuse-lite observations``) or
|
|
5
|
+
start a server from Python:
|
|
6
|
+
|
|
7
|
+
from langfuse_lite import serve
|
|
8
|
+
|
|
9
|
+
with serve() as lite: # random free port, temporary database
|
|
10
|
+
os.environ.update(lite.env) # LANGFUSE_BASE_URL and keys for the SDK
|
|
11
|
+
...
|
|
12
|
+
|
|
13
|
+
In pytest, the ``langfuse_lite`` fixture does the same for a test session.
|
|
14
|
+
"""
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import re
|
|
19
|
+
import subprocess
|
|
20
|
+
import sys
|
|
21
|
+
import tempfile
|
|
22
|
+
import threading
|
|
23
|
+
import time
|
|
24
|
+
import urllib.request
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
__version__ = "0.1.0"
|
|
28
|
+
__all__ = ["binary", "serve", "LangfuseLite"]
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def binary() -> str:
|
|
32
|
+
"""Path of the bundled langfuse-lite executable."""
|
|
33
|
+
name = "langfuse-lite.exe" if sys.platform == "win32" else "langfuse-lite"
|
|
34
|
+
path = Path(__file__).parent / "bin" / name
|
|
35
|
+
if not path.exists():
|
|
36
|
+
raise RuntimeError(f"langfuse-lite executable missing at {path}; this wheel does not match the platform")
|
|
37
|
+
return str(path)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class LangfuseLite:
|
|
41
|
+
"""A running langfuse-lite server; stop() or use as a context manager."""
|
|
42
|
+
|
|
43
|
+
def __init__(self, port: int = 0, db: str | os.PathLike | None = None, host: str = "127.0.0.1"):
|
|
44
|
+
self._tmp = None
|
|
45
|
+
if db is None:
|
|
46
|
+
self._tmp = tempfile.TemporaryDirectory(prefix="langfuse-lite-")
|
|
47
|
+
db = Path(self._tmp.name) / "lite.db"
|
|
48
|
+
self.db = str(db)
|
|
49
|
+
env = dict(os.environ)
|
|
50
|
+
if self._tmp:
|
|
51
|
+
# A temporary database is a test run: no usage telemetry for those.
|
|
52
|
+
env["TELEMETRY_ENABLED"] = "false"
|
|
53
|
+
self.process = subprocess.Popen(
|
|
54
|
+
[binary(), "serve", "--host", host, "--port", str(port), "--db", self.db],
|
|
55
|
+
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, bufsize=1, env=env,
|
|
56
|
+
)
|
|
57
|
+
self.log: list[str] = []
|
|
58
|
+
line = self.process.stdout.readline() if self.process.stdout else ""
|
|
59
|
+
match = re.search(r"listening on (http://\S+)", line)
|
|
60
|
+
if not match:
|
|
61
|
+
rest = self.process.stdout.read() if self.process.stdout else ""
|
|
62
|
+
self.process.kill()
|
|
63
|
+
raise RuntimeError(f"langfuse-lite did not start: {line}{rest}")
|
|
64
|
+
self.url = match.group(1)
|
|
65
|
+
threading.Thread(target=self._drain, daemon=True).start()
|
|
66
|
+
self._wait_healthy()
|
|
67
|
+
|
|
68
|
+
def _drain(self):
|
|
69
|
+
for line in self.process.stdout or []:
|
|
70
|
+
self.log.append(line.rstrip("\n"))
|
|
71
|
+
|
|
72
|
+
def _wait_healthy(self, timeout: float = 10):
|
|
73
|
+
deadline = time.time() + timeout
|
|
74
|
+
while time.time() < deadline:
|
|
75
|
+
try:
|
|
76
|
+
with urllib.request.urlopen(self.url + "/api/public/health", timeout=1):
|
|
77
|
+
return
|
|
78
|
+
except OSError:
|
|
79
|
+
time.sleep(0.05)
|
|
80
|
+
raise RuntimeError("langfuse-lite did not become healthy")
|
|
81
|
+
|
|
82
|
+
@property
|
|
83
|
+
def env(self) -> dict[str, str]:
|
|
84
|
+
"""Settings for the Langfuse SDKs (any keys are accepted)."""
|
|
85
|
+
return {"LANGFUSE_BASE_URL": self.url, "LANGFUSE_HOST": self.url,
|
|
86
|
+
"LANGFUSE_PUBLIC_KEY": "pk-lf-local", "LANGFUSE_SECRET_KEY": "sk-lf-local"}
|
|
87
|
+
|
|
88
|
+
def cli(self, *args: str) -> str:
|
|
89
|
+
"""Runs a langfuse-lite command (observations, tree, runs, compare, sql) on this server's database."""
|
|
90
|
+
out = subprocess.run([binary(), *args, "--db", self.db], capture_output=True, text=True, check=True)
|
|
91
|
+
return out.stdout
|
|
92
|
+
|
|
93
|
+
def stop(self):
|
|
94
|
+
if self.process.poll() is None:
|
|
95
|
+
self.process.terminate()
|
|
96
|
+
try:
|
|
97
|
+
self.process.wait(timeout=5)
|
|
98
|
+
except subprocess.TimeoutExpired:
|
|
99
|
+
self.process.kill()
|
|
100
|
+
if self._tmp:
|
|
101
|
+
self._tmp.cleanup()
|
|
102
|
+
self._tmp = None
|
|
103
|
+
|
|
104
|
+
def __enter__(self):
|
|
105
|
+
return self
|
|
106
|
+
|
|
107
|
+
def __exit__(self, *exc):
|
|
108
|
+
self.stop()
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def serve(port: int = 0, db: str | os.PathLike | None = None, host: str = "127.0.0.1") -> LangfuseLite:
|
|
112
|
+
"""Starts langfuse-lite; port 0 picks a free port, db None uses a temporary database."""
|
|
113
|
+
return LangfuseLite(port=port, db=db, host=host)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""`langfuse-lite` / `python -m langfuse_lite`: runs the bundled executable."""
|
|
2
|
+
import os
|
|
3
|
+
import subprocess
|
|
4
|
+
import sys
|
|
5
|
+
|
|
6
|
+
from . import binary
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def main() -> None:
|
|
10
|
+
args = [binary(), *sys.argv[1:]]
|
|
11
|
+
if sys.platform == "win32":
|
|
12
|
+
sys.exit(subprocess.call(args))
|
|
13
|
+
os.execv(args[0], args)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__":
|
|
17
|
+
main()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"""pytest fixtures (registered automatically when langfuse-lite is installed).
|
|
2
|
+
|
|
3
|
+
def test_my_agent(langfuse_lite_env):
|
|
4
|
+
run_my_agent() # traced with the Langfuse SDK as usual
|
|
5
|
+
assert "my-agent" in langfuse_lite_env.cli("observations")
|
|
6
|
+
|
|
7
|
+
``langfuse_lite``: one server per test session, temporary database.
|
|
8
|
+
``langfuse_lite_env``: the same server, with LANGFUSE_* set for the test.
|
|
9
|
+
"""
|
|
10
|
+
import pytest
|
|
11
|
+
|
|
12
|
+
from . import serve
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@pytest.fixture(scope="session")
|
|
16
|
+
def langfuse_lite():
|
|
17
|
+
with serve() as lite:
|
|
18
|
+
yield lite
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@pytest.fixture
|
|
22
|
+
def langfuse_lite_env(langfuse_lite, monkeypatch):
|
|
23
|
+
for key, value in langfuse_lite.env.items():
|
|
24
|
+
monkeypatch.setenv(key, value)
|
|
25
|
+
yield langfuse_lite
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ClickHouse, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: langfuse-lite
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A local Langfuse for experiment runs and agent tracing: one process, one SQLite file, the Langfuse SDKs unchanged.
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Project-URL: Source, https://github.com/langfuse/langfuse-lite
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
|
|
11
|
+
# langfuse-lite
|
|
12
|
+
|
|
13
|
+
A local Langfuse for code agents: **tracing and experiment runs** in one
|
|
14
|
+
process and one SQLite file, with the official Langfuse SDKs unchanged.
|
|
15
|
+
No Docker, no account, no databases to run.
|
|
16
|
+
|
|
17
|
+
> **Status: beta, an experiment.** Published on
|
|
18
|
+
> [npm](https://www.npmjs.com/package/langfuse-lite); not on PyPI yet. Not
|
|
19
|
+
> proven that agents will pick it.
|
|
20
|
+
|
|
21
|
+
> **Before you use it.** langfuse-lite is a local emulator of Langfuse for
|
|
22
|
+
> development, not a way to run Langfuse.
|
|
23
|
+
>
|
|
24
|
+
> - **No authentication, single tenant.** API keys are not checked: any key, or
|
|
25
|
+
> none, is accepted (the SDKs only need a placeholder to start). There is one
|
|
26
|
+
> project and no users. Anyone who can reach the port can read and write all
|
|
27
|
+
> data, prompts and outputs included.
|
|
28
|
+
> - **Not security hardened** like Langfuse Cloud or a self-hosted Langfuse. It
|
|
29
|
+
> listens on `127.0.0.1` only; never expose it to a network you do not trust.
|
|
30
|
+
> - **No compatibility guarantee.** It implements part of the Langfuse public
|
|
31
|
+
> API and may differ from Langfuse Cloud or lag behind it.
|
|
32
|
+
> - **Not built for load.** For performance, scale and production use, switch
|
|
33
|
+
> to [Langfuse Cloud](https://cloud.langfuse.com) or
|
|
34
|
+
> [self-host Langfuse](https://langfuse.com/self-hosting).
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx -y langfuse-lite serve # needs Node 22.13+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
export LANGFUSE_BASE_URL=http://localhost:3000 LANGFUSE_PUBLIC_KEY=pk-lf-local LANGFUSE_SECRET_KEY=sk-lf-local
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Trace and run experiments with the Langfuse SDKs as usual, or send any
|
|
45
|
+
OpenTelemetry spans to `/api/public/otel/v1/traces`. Data goes to
|
|
46
|
+
`./.langfuse/lite.db`; the viewer is at http://localhost:3000.
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
## Why
|
|
51
|
+
|
|
52
|
+
When code agents add observability or evals to a project, they often name
|
|
53
|
+
Langfuse as the default choice and then build something themselves instead.
|
|
54
|
+
The reasons they give are the same each time: Langfuse needs an account and
|
|
55
|
+
API keys they do not have, they cannot verify from inside their sandbox that
|
|
56
|
+
it works, and self-hosting means running several databases.
|
|
57
|
+
|
|
58
|
+
> "Langfuse is the leading candidate." … "both platforms require external API
|
|
59
|
+
> keys and accounts." … "I'm pivoting to a self-contained implementation."
|
|
60
|
+
>
|
|
61
|
+
> "I will implement the pipeline in-repo rather than using external SaaS, so it actually runs."
|
|
62
|
+
>
|
|
63
|
+
> <sub>Code agents in our test sessions.</sub>
|
|
64
|
+
|
|
65
|
+
langfuse-lite removes those reasons: an agent starts it with one command,
|
|
66
|
+
needs no keys, and can read the results back itself.
|
|
67
|
+
|
|
68
|
+
- **Same SDKs, same code.** To continue in Langfuse Cloud or a self-hosted
|
|
69
|
+
Langfuse, change the host and API keys; `push` copies the local data over.
|
|
70
|
+
- **Small on purpose.** It covers only tracing, scores, datasets and
|
|
71
|
+
experiments, and reuses Langfuse's own span conversion and cost code. We
|
|
72
|
+
expect it to need an update only for major releases of Langfuse or the SDKs.
|
|
73
|
+
|
|
74
|
+
## Commands
|
|
75
|
+
|
|
76
|
+
They read the database directly, so they work while the server runs or after.
|
|
77
|
+
Every command takes `--json`; `--db <path>` or `LANGFUSE_LITE_DB` picks another database.
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
langfuse-lite observations # root observations, newest first
|
|
81
|
+
langfuse-lite observations --level ERROR --io # filter: --level --name --type --trace --experiment --since
|
|
82
|
+
langfuse-lite tree <trace id> # every observation of one trace, as a tree
|
|
83
|
+
langfuse-lite runs # experiment runs with average scores
|
|
84
|
+
langfuse-lite compare <run> <run> # runs side by side, item by item
|
|
85
|
+
langfuse-lite sql "SELECT ..." # read-only SQL on observations, scores, datasets
|
|
86
|
+
langfuse-lite export --out run.html # the viewer and its data in one file
|
|
87
|
+
langfuse-lite push --to https://cloud.langfuse.com # copy everything to a full Langfuse
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```text
|
|
91
|
+
$ langfuse-lite tree 478d02 --io
|
|
92
|
+
trace id 478d02b45e251eadf418f4546f2e2827 · support-agent · 5 observations · 1.2s · 4720 tokens · $0.0107 · 1 error
|
|
93
|
+
└─ AGENT support-agent 1.2s
|
|
94
|
+
├─ GENERATION plan claude-sonnet-5-5 2010→64 tok $0.0047 460ms
|
|
95
|
+
├─ RETRIEVER search_help_center 71ms
|
|
96
|
+
├─ TOOL send_email 140ms ERROR: SMTP timeout after 3 retries
|
|
97
|
+
└─ GENERATION answer claude-sonnet-5-5 2550→96 tok $0.0061 520ms
|
|
98
|
+
scores: resolved=no, helpfulness=0.4 "tool failed, offered a workaround"
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The Python package (not on PyPI yet; build the wheels from this repository)
|
|
102
|
+
registers pytest fixtures (`langfuse_lite`, `langfuse_lite_env`) and a
|
|
103
|
+
`serve()` context manager that start a server on a free port with a temporary
|
|
104
|
+
database.
|
|
105
|
+
|
|
106
|
+
## What it serves
|
|
107
|
+
|
|
108
|
+
The part of the Langfuse public API that the SDKs (Python 5.x, JS 6.x) use for
|
|
109
|
+
tracing and experiments. Everything else answers 501.
|
|
110
|
+
|
|
111
|
+
| Endpoint | |
|
|
112
|
+
|---|---|
|
|
113
|
+
| `POST /api/public/otel/v1/traces` | OTLP over HTTP, protobuf or JSON |
|
|
114
|
+
| `POST /api/public/scores`, `GET /api/public/v3/scores` | |
|
|
115
|
+
| `/api/public/v2/datasets`, `/api/public/dataset-items` | create, list, get, delete |
|
|
116
|
+
| `GET /api/public/v2/observations` | |
|
|
117
|
+
| `GET /api/public/experiments`, `/api/public/experiment-items` | |
|
|
118
|
+
|
|
119
|
+
Not included: prompt management, evaluators running in Langfuse, dashboards,
|
|
120
|
+
the metrics API, access control, media, annotation queues.
|
|
121
|
+
|
|
122
|
+
## How it works
|
|
123
|
+
|
|
124
|
+
- OTel spans become observations through Langfuse's own conversion and cost
|
|
125
|
+
code, vendored unchanged from the official worker image (`vendor/langfuse/`).
|
|
126
|
+
- One SQLite file on Langfuse v4's data model: an `observations` table, plus
|
|
127
|
+
`scores`, `datasets` and `dataset_items`. Raw OTLP requests are kept, which
|
|
128
|
+
is what `push` replays.
|
|
129
|
+
- TypeScript on Node's and Bun's built-in SQLite, with no runtime dependencies.
|
|
130
|
+
Ships as one JS file on npm; standalone executables and PyPI wheels build
|
|
131
|
+
from this repository but are not published yet.
|
|
132
|
+
|
|
133
|
+
## Security and limits
|
|
134
|
+
|
|
135
|
+
- **No authentication.** API keys are not checked, and `serve` listens on
|
|
136
|
+
`127.0.0.1` only; whoever can reach the port can read and write everything.
|
|
137
|
+
`--host` opens it to the network: do that on a trusted network only.
|
|
138
|
+
- Requests from other websites are refused; set `LANGFUSE_LITE_ALLOWED_HOSTS`
|
|
139
|
+
to serve it under another host name.
|
|
140
|
+
- For local use: one request at a time, bodies up to 64 MB. For more, use
|
|
141
|
+
Langfuse Cloud or a self-hosted Langfuse.
|
|
142
|
+
- Cost uses Langfuse's default model prices only.
|
|
143
|
+
|
|
144
|
+
## Telemetry
|
|
145
|
+
|
|
146
|
+
`serve` and `push` send anonymous usage counts to Langfuse (via PostHog EU), so
|
|
147
|
+
we can tell whether langfuse-lite is used at all. Like self-hosted Langfuse,
|
|
148
|
+
it never sends traces, prompts, outputs, names, ids, paths or host names.
|
|
149
|
+
|
|
150
|
+
- **Sent:** langfuse-lite, Langfuse and runtime versions, OS, the number of
|
|
151
|
+
observations, traces, scores, datasets and experiment runs, which SDKs sent
|
|
152
|
+
data, and after `push` the counts moved and whether the target was Langfuse
|
|
153
|
+
Cloud. Each database gets a random id.
|
|
154
|
+
- **When:** at `serve` start, once after the first trace of a session, hourly
|
|
155
|
+
while data keeps arriving, and after `push`. The read commands send nothing.
|
|
156
|
+
- **Always off** in CI (`CI` is set) and for the temporary databases of the
|
|
157
|
+
Python fixtures.
|
|
158
|
+
|
|
159
|
+
To turn it off, set either variable before starting the server:
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
export TELEMETRY_ENABLED=false # or: export DO_NOT_TRACK=1
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
The code is in [`src/telemetry.ts`](src/telemetry.ts).
|
|
166
|
+
|
|
167
|
+
Development setup, the conformance tests against a full Langfuse and
|
|
168
|
+
measurements are in [docs/development.md](docs/development.md); the original
|
|
169
|
+
design plan is in [docs/slim-server.md](docs/slim-server.md).
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT. The vendored Langfuse code is MIT as well (`vendor/LICENSE-langfuse`).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
langfuse_lite/__init__.py,sha256=l7NItzTuE1GU1lK33Qptn5JzHXvUCz3O8xKqDTA2ytk,4236
|
|
2
|
+
langfuse_lite/__main__.py,sha256=ijOTg8PuKcnfykMcPQiJLHD7w2gUbSYgeUaMuz5R17E,340
|
|
3
|
+
langfuse_lite/pytest_plugin.py,sha256=MTGbvYX4TzbAEQS3TVrQU24oZvshdK65UwK02zERtwE,737
|
|
4
|
+
langfuse_lite/THIRD_PARTY_NOTICES.md,sha256=o6KCrVhlC-ShqB5zFvCHG5Kj1yJ2LoASvJF1717WdE8,10325
|
|
5
|
+
langfuse_lite/bin/langfuse-lite.exe,sha256=LS7IRD4Ih3o8wSKf8WSNHN5zsvkA82-uwmYmbMUOrek,115411968
|
|
6
|
+
langfuse_lite-0.1.0.dist-info/METADATA,sha256=LYWYnqRvUfxNXj6qw8AcEc6UbNWSuBN9LgrTwqEq8zg,8000
|
|
7
|
+
langfuse_lite-0.1.0.dist-info/WHEEL,sha256=58lCXZ5A3uQ_2Kvw4YS3dA5GdjbXRngSJFAjMWZj00o,107
|
|
8
|
+
langfuse_lite-0.1.0.dist-info/entry_points.txt,sha256=kYhE1ZphXp2XGDlMPFB681kqYVnER1DcOJEj9MzKDWU,118
|
|
9
|
+
langfuse_lite-0.1.0.dist-info/LICENSE,sha256=QxvS0shJaYNOPhNsRH66NtwOOFpMuwf350WIVu9uHlk,1073
|
|
10
|
+
langfuse_lite-0.1.0.dist-info/RECORD,,
|